Class MemoryByteReader
- Namespace
- CStructSharp.Memory
- Assembly
- CStructSharp.dll
Prepared raw storage reader for a fixed array of one-byte scalars, independent of text interpretation.
public sealed class MemoryByteReader
- Inheritance
-
MemoryByteReader
- Inherited Members
Remarks
Signed and unsigned one-byte storage is returned bit-for-bit. Raw reads deliberately do not invoke element codecs. Decode text separately with an explicit encoding, termination and invalid-byte policy. No bytes or contexts are retained.
Properties
Length
Gets the exact storage byte count, without a terminator or truncation interpretation.
public int Length { get; }
Property Value
Selection
Gets the prepared schema path and its required byte extent.
public MemoryPath Selection { get; }
Property Value
Methods
Read(MemorySession, MemoryRegion, Span<byte>, MemoryAccessContext)
Copies raw storage into caller-owned bytes, preserving a confirmed prefix on unavailable input.
public MemoryReadResult Read(MemorySession session, MemoryRegion region, Span<byte> destination, MemoryAccessContext context)
Parameters
sessionMemorySessionSession owning the identical schema instance.
regionMemoryRegionFinite root record storage.
destinationSpan<byte>Capacity at least Length. Bytes beyond Length remain untouched.
contextMemoryAccessContextShared source budget and cancellation.
Returns
- MemoryReadResult
Copied prefix and source failure, with no padding.
Exceptions
- ArgumentException
The schema differs or destination is too short.
- MemoryAccessException
The shared budget is exhausted.
- OperationCanceledException
Cancellation was requested.
TryReadBuffer(ReadOnlySpan<byte>, MemoryAccessContext, out ReadOnlySpan<byte>, MemoryValidity?)
Borrows raw field storage from stable caller bytes, without copies, decoding or pointer follows.
public bool TryReadBuffer(ReadOnlySpan<byte> source, MemoryAccessContext context, out ReadOnlySpan<byte> bytes, MemoryValidity? validity = null)
Parameters
sourceReadOnlySpan<byte>Captured bytes beginning at the root's logical start.
contextMemoryAccessContextShared local decoding budget and cancellation.
bytesReadOnlySpan<byte>Borrowed field bytes on success; empty on false. They cannot outlive source.
validityMemoryValidityKnown-byte intervals for this exact buffer, or null for fully known input.
Returns
- bool
Whether the entire selected byte extent is known.
Exceptions
- NotSupportedException
The path follows a pointer.
- ArgumentException
Validity describes another buffer length.