Documentation
¶
Overview ¶
Package codecutil owns the built-in codecs' bounded I/O, cancellation checkpoints, borrowed adoption callbacks, and acquired iterator cleanup. It does not change the public reader/writer contract.
Index ¶
Constants ¶
const ChunkSize = 4096
ChunkSize bounds payload writes and reader requests between checkpoints.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferWriter ¶
BufferWriter borrows an exact bytes.Buffer and shares all cancellation, error, and byte-accounting state with its embedded base writer.
func (*BufferWriter) WriteByte ¶
func (w *BufferWriter) WriteByte(value byte) error
type Iterator ¶
Iterator owns only a distinct iterator acquired for encoding. An iterator sharing the borrowed source's identity remains with the source's owner.
func NewIterator ¶
NewIterator acquires an iterator without taking ownership of the source.
type Operation ¶
type Operation struct {
// contains filtered or unexported fields
}
Operation samples traversal cancellation every 256 values or tokens. I/O and fallback boundaries can check directly without adding ctx.Err to hot loops.
func NewOperation ¶
NewOperation validates arguments and initializes borrowed operation state. Callers check cancellation explicitly: encoders first bind the adopter and discover the stored root; decoders check before hooks or reads.
func (*Operation) Adopt ¶
Adopt registers a visit, optionally discovering concrete stored descendants. Acquisition boundaries and abandoned containers request discovery; ordinary recursive visits register directly to keep hook-free traversal linear.
func (*Operation) CacheValueAdopter ¶
func (op *Operation) CacheValueAdopter()
CacheValueAdopter binds a borrowed callback once after operation validation. It changes neither the cancellation lifetime nor the context passed to hooks.
func (*Operation) HasValueAdopter ¶
HasValueAdopter reports whether native values must pass through the visitor.
type Reader ¶
Reader observes non-EOF errors even when a decoder accepts accompanying data.