Section navigation

Public classSealed CodecContext

Namespace
Rowles.LeanCorpus.Codecs.CodecKit.Codecs
Assembly
Rowles.LeanCorpus.dll

Per-operation mutable state for codec decode/encode operations. Tracks nesting depth, diagnostic path, byte offsets, delimited scopes, and scratch buffers. Created per top-level codec call; never shared across concurrent operations.

public sealed class CodecContext
Inheritance
CodecContext

Public constructor CodecContext(CodecOptions, CodecRegistry)

Public property ByteOffsetBase

Current byte offset base (for decompression sub-stream tracking).

Public property CurrentPath

Current diagnostic path, computed lazily.

Public property Depth

Current nesting depth.

Public property InScope

Whether we are inside a delimited scope.

Public property Options

Current codec options.

Public property Registry

Current codec registry.

Public property RemainingInScope

Remaining bytes in the current delimited scope, or -1 if not in a scope.

Public method Checkpoint(ref SequenceReader<byte>)

Captures the current reader position alongside the sequence it belongs to. Both are required for a correct rewind: the position is only valid within the sequence it was captured from, so nested codecs that narrow reader.Sequence cannot invalidate an outer checkpoint.

Public method ConsumeScope(long)

Consumes bytes from the current scope.

Public method EnterScope(long)

Enters a delimited scope of the given byte length. Returns a disposable guard that exits the scope on dispose.

Public method GetByteOffset(ref SequenceReader<byte>)

Computes the current byte offset relative to the offset base.

Public method PushDepth()

Increments nesting depth. Returns a disposable guard that decrements on dispose. Throws LimitExceededException if MaxNestingDepth is exceeded.

Public method PushPath(string)

Pushes a path segment. Returns a disposable guard that pops on dispose.

Public method Rewind(ref SequenceReader<byte>, CodecCheckpoint)

Rewinds the reader to a previously captured checkpoint. The reader is reconstructed from the sequence stored in the checkpoint so that nested rewinds (which may have narrowed reader.Sequence) do not affect the restoration of outer checkpoints.

Public method SetByteOffsetBase(long)

Sets the byte offset base for decompression sub-streams. Returns a disposable guard that restores the old base.