
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
CodecContext(CodecOptions, CodecRegistry)
ByteOffsetBase
Current byte offset base (for decompression sub-stream tracking).
CurrentPath
Current diagnostic path, computed lazily.
Depth
Current nesting depth.
InScope
Whether we are inside a delimited scope.
Options
Current codec options.
Registry
Current codec registry.
RemainingInScope
Remaining bytes in the current delimited scope, or -1 if not in a scope.
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.
ConsumeScope(long)
Consumes bytes from the current scope.
EnterScope(long)
Enters a delimited scope of the given byte length. Returns a disposable guard that exits the scope on dispose.
GetByteOffset(ref SequenceReader<byte>)
Computes the current byte offset relative to the offset base.
PushDepth()
Increments nesting depth. Returns a disposable guard that decrements on dispose. Throws LimitExceededException if MaxNestingDepth is exceeded.
PushPath(string)
Pushes a path segment. Returns a disposable guard that pops on dispose.
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.
SetByteOffsetBase(long)
Sets the byte offset base for decompression sub-streams. Returns a disposable guard that restores the old base.