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
sourceBytesThe source stream.
destinationBytes.WriterThe destination stream.
poolMemoryPool<byte>The pool to allocate buffers from.
filterFunc<TypeId, ReadOnlyMemory<byte>, Promise<bool>>Returns true if a record should be copied, false otherwise.
Returns
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
stmBytesThe stream to read from.
poolMemoryPool<byte>The pool to allocate buffers from.
visitRecordFunc<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
stmBytesThe stream to read from.
poolMemoryPool<byte>The pool to allocate buffers from.
visitRecordFunc<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
sourceFileProxyThe source stream.
destinationFileProxyThe destination stream.
poolMemoryPool<byte>The pool to allocate buffers from.
itemTThe item to be written.
Returns
Type Parameters
TThe 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
sourceBytesThe source stream.
destinationBytes.WriterThe destination stream.
poolMemoryPool<byte>The pool to allocate buffers from.
itemTThe item to be written.
Returns
Type Parameters
TThe 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
destinationBytes.WriterThe byte stream to write to.
poolMemoryPool<byte>The pool to allocate buffers from.
itemTThe item to be written.
Returns
Type Parameters
TThe type of the item to write.