pub trait ExtentCodec:
Debug
+ Send
+ Sync {
// Required methods
fn encode(&self, body: &[u8], out: &mut Vec<u8>);
fn decode(&self, stored: &[u8], body: &mut [u8]);
// Provided method
fn is_identity(&self) -> bool { ... }
}pool only.Expand description
A chunk-provided transform between a chunk’s body bytes and the stored
bytes its extent holds. The pool owns scheduling: spill threads, the
residency state machine, cancellation, and the ledger. It invokes the
codec on opaque bytes at the extent boundary, encode when backing a
chunk (on a spill thread, or inline under overload) and decode when
reading an evicted one, possibly under the chunk’s state lock. The pool
itself has no opinion on the stored form: framing, compression, and
validation all belong to the codec.
Implementations must be pure transforms: no locking, no calls back into
the pool (the state lock may be held at decode sites), and no panic on
bytes their own encode produced. decode must exactly invert
encode, and encode’s output must never exceed
max_stored_len(body.len()), the bound the extent store’s size
classes are provisioned to.
Required Methods§
Sourcefn encode(&self, body: &[u8], out: &mut Vec<u8>)
fn encode(&self, body: &[u8], out: &mut Vec<u8>)
Transforms body into its stored form, replacing out’s contents.
out’s capacity is reused across calls; implementations size it
themselves.
Sourcefn decode(&self, stored: &[u8], body: &mut [u8])
fn decode(&self, stored: &[u8], body: &mut [u8])
Inverts ExtentCodec::encode: reconstructs into body exactly
the bytes whose encoding produced stored. body is exactly the
original body’s length, and implementations must panic on a length
mismatch rather than truncate or pad.
Provided Methods§
Sourcefn is_identity(&self) -> bool
fn is_identity(&self) -> bool
Whether the stored form is the body itself, for splitting the pool’s write-bytes counters by codec.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".