Skip to main content

IRtDeserializeStream

Namespace: Meshmakers.Octo.Runtime.Contracts.Serialization

Interface of a stream that contains deserialized data.

public interface IRtDeserializeStream : IDisposable

Implements IDisposable

Properties​

Dependencies​

Returns dependencies of the model. Supports version ranges.

public abstract IReadOnlyCollection<CkModelIdVersionRange> Dependencies { get; }

Property Value​

IReadOnlyCollection<CkModelIdVersionRange>

Methods​

ReadAsync(Nullable<CancellationToken>)​

Reads the entities array of the stream and returns the entities as event in IRtDeserializeStream.BulkDeserialized. Every entity is handed out exactly once.

Task ReadAsync(Nullable<CancellationToken> cancellationToken)

Parameters​

cancellationToken Nullable<CancellationToken>
Cancels the read.

Returns​

Task
A task that completes when the whole array was read and every event handler returned.

ReadBulksAsync(CancellationToken)​

Reads the entities array of the stream and returns the entities in bulks, in file order; every entity is handed out exactly once. The next bulk is read only when the consumer asks for it, so a consumer that awaits its work per bulk (await foreach) processes the file in sequence and sees every exception of that work.

IAsyncEnumerable<IReadOnlyList<RtEntityTcDto>> ReadBulksAsync(CancellationToken cancellationToken)

Parameters​

cancellationToken CancellationToken
Cancels the read.

Returns​

IAsyncEnumerable<IReadOnlyList<RtEntityTcDto>>
The bulks of deserialized entities.

Remarks:

The default implementation keeps existing implementers of this interface compatible: it reads the whole stream through IRtDeserializeStream.ReadAsync(Nullable<CancellationToken>) and IRtDeserializeStream.BulkDeserialized first and then hands the collected bulks out, so it holds all entities in memory. Implementers should override it to stream.

Events​

BulkDeserialized​

Indicates that a bulk of entities has been deserialized. The event is raised synchronously by IRtDeserializeStream.ReadAsync(Nullable<CancellationToken>); a handler must finish its work before it returns. Never subscribe an async handler (an async void lambda): IRtDeserializeStream.ReadAsync(Nullable<CancellationToken>) would not wait for it and its exceptions would be lost. Use IRtDeserializeStream.ReadBulksAsync(CancellationToken) to process a bulk asynchronously.

public abstract event EventHandler<RtDeserializeEventArgs> BulkDeserialized;