Table of Contents

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

int

Selection

Gets the prepared schema path and its required byte extent.

public MemoryPath Selection { get; }

Property Value

MemoryPath

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

session MemorySession

Session owning the identical schema instance.

region MemoryRegion

Finite root record storage.

destination Span<byte>

Capacity at least Length. Bytes beyond Length remain untouched.

context MemoryAccessContext

Shared 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

source ReadOnlySpan<byte>

Captured bytes beginning at the root's logical start.

context MemoryAccessContext

Shared local decoding budget and cancellation.

bytes ReadOnlySpan<byte>

Borrowed field bytes on success; empty on false. They cannot outlive source.

validity MemoryValidity

Known-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.