Table of Contents

Method OpenAsync

Namespace
AvroSharp.Containers
Assembly
AvroSharp.dll

OpenAsync<T>(Stream, Func<AvroSchema, AvroReadFunc<T>>, AvroFileReaderOptions?, CancellationToken)

Reads a file's header asynchronously and returns a reader of its objects.

public static ValueTask<AvroFileReader<T>> OpenAsync<T>(Stream stream, Func<AvroSchema, AvroReadFunc<T>> createReader, AvroFileReaderOptions? options = null, CancellationToken cancellationToken = default)

Parameters

stream Stream

The source, positioned at the start of the file.

createReader Func<AvroSchema, AvroReadFunc<T>>

Called once with the file's schema; returns the function that reads one object (see Open<T>(Stream, Func<AvroSchema, AvroReadFunc<T>>, AvroFileReaderOptions?)).

options AvroFileReaderOptions

The file options, or null for the defaults.

cancellationToken CancellationToken

Cancels reading the header.

Returns

ValueTask<AvroFileReader<T>>

Type Parameters

T

The type of the objects.

Exceptions

AvroDataException

The header is malformed.

AvroException

The file's codec is not available.

OpenAsync<T>(Stream, AvroFileReaderOptions?, CancellationToken)

Opens a container file of a generated type, reading its header asynchronously.

public static ValueTask<AvroFileReader<T>> OpenAsync<T>(Stream stream, AvroFileReaderOptions? options = null, CancellationToken cancellationToken = default) where T : IAvroSerializable<T>

Parameters

stream Stream

The source, positioned at the start of the file.

options AvroFileReaderOptions

The file options, or null for the defaults.

cancellationToken CancellationToken

Cancels reading the header.

Returns

ValueTask<AvroFileReader<T>>

Type Parameters

T

A generated type.

Exceptions

AvroDataException

The header is malformed.

AvroException

The file's codec is not available.