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
streamStreamThe source, positioned at the start of the file.
createReaderFunc<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?)).
optionsAvroFileReaderOptionsThe file options, or null for the defaults.
cancellationTokenCancellationTokenCancels reading the header.
Returns
Type Parameters
TThe 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
streamStreamThe source, positioned at the start of the file.
optionsAvroFileReaderOptionsThe file options, or null for the defaults.
cancellationTokenCancellationTokenCancels reading the header.
Returns
Type Parameters
TA generated type.
Exceptions
- AvroDataException
The header is malformed.
- AvroException
The file's codec is not available.