Table of Contents

Class RecordIO

Namespace
MarymoorStudios.Core.Promises.IO
Assembly
MarymoorStudios.Core.Promises.IO.dll
public static class RecordIO
Inheritance
RecordIO
Inherited Members

Methods

CopyRecordIO(Bytes, Writer, MemoryPool<byte>, Func<TypeId, ReadOnlyMemory<byte>, Promise<bool>>)

Copies records from one RecordIO stream to another, optionally with filtering.

public static Promise CopyRecordIO(this Bytes source, Bytes.Writer destination, MemoryPool<byte> pool, Func<TypeId, ReadOnlyMemory<byte>, Promise<bool>> filter)

Parameters

source Bytes

The source stream.

destination Bytes.Writer

The destination stream.

pool MemoryPool<byte>

The pool to allocate buffers from.

filter Func<TypeId, ReadOnlyMemory<byte>, Promise<bool>>

Returns true if a record should be copied, false otherwise.

Returns

Promise

ReadRecordIO(Bytes, MemoryPool<byte>, Func<TypeId, ReadOnlyMemory<byte>, Promise>)

Reads an entire RecordIO stream.

public static Promise ReadRecordIO(this Bytes stm, MemoryPool<byte> pool, Func<TypeId, ReadOnlyMemory<byte>, Promise> visitRecord)

Parameters

stm Bytes

The stream to read from.

pool MemoryPool<byte>

The pool to allocate buffers from.

visitRecord Func<TypeId, ReadOnlyMemory<byte>, Promise>

Called once for each record.

Returns

Promise

Success if the stream is parsed without error, the error code otherwise.

Remarks

pool defines the maximum record policy. No records will be processed larger than its maximum buffer size.

visitRecord is passed a ReadOnlyMemory<T> of the record body.

If visitRecord returns an error then the sequence is aborted.

ReadRecordIO(Bytes, MemoryPool<byte>, Func<TypeId, uint, ReadOnlyMemory<byte>, Promise>)

Reads an entire RecordIO stream.

public static Promise ReadRecordIO(this Bytes stm, MemoryPool<byte> pool, Func<TypeId, uint, ReadOnlyMemory<byte>, Promise> visitRecord)

Parameters

stm Bytes

The stream to read from.

pool MemoryPool<byte>

The pool to allocate buffers from.

visitRecord Func<TypeId, uint, ReadOnlyMemory<byte>, Promise>

Called once for each record.

Returns

Promise

Success if the stream is parsed without error, the error code otherwise.

Remarks

pool defines the maximum record policy. No records will be processed larger than its maximum buffer size.

visitRecord is passed a ReadOnlyMemory<T> of the record body.

If visitRecord returns an error then the sequence is aborted.

ReplaceRecordIO<T>(FileProxy, FileProxy, MemoryPool<byte>, T)

Copies records from one RecordIO stream to another, while deleting all records of the same type as item and replacing them with a single record of item at the end.

public static Promise ReplaceRecordIO<T>(this FileProxy source, FileProxy destination, MemoryPool<byte> pool, T item)

Parameters

source FileProxy

The source stream.

destination FileProxy

The destination stream.

pool MemoryPool<byte>

The pool to allocate buffers from.

item T

The item to be written.

Returns

Promise

Type Parameters

T

The type of the item to write.

ReplaceRecordIO<T>(Bytes, Writer, MemoryPool<byte>, T)

Copies records from one RecordIO stream to another, while deleting all records of the same type as item and replacing them with a single record of item at the end.

public static Promise ReplaceRecordIO<T>(this Bytes source, Bytes.Writer destination, MemoryPool<byte> pool, T item)

Parameters

source Bytes

The source stream.

destination Bytes.Writer

The destination stream.

pool MemoryPool<byte>

The pool to allocate buffers from.

item T

The item to be written.

Returns

Promise

Type Parameters

T

The type of the item to write.

WriteRecordIO<T>(Writer, MemoryPool<byte>, T)

Write a serializable item as a record.

public static Promise WriteRecordIO<T>(this Bytes.Writer destination, MemoryPool<byte> pool, T item)

Parameters

destination Bytes.Writer

The byte stream to write to.

pool MemoryPool<byte>

The pool to allocate buffers from.

item T

The item to be written.

Returns

Promise

Type Parameters

T

The type of the item to write.