pub enum TermValue<'a, const INLINE_BYTES: usize> {
Inline {
bytes: [u8; INLINE_BYTES],
len: usize,
},
Borrowed(&'a [u8]),
Stream(&'a dyn ChunkSource),
}Expand description
Wiki ADR-029 + ADR-060: a single Term variant’s evaluated value, carried as a source-polymorphic carrier const-generic over its inline width. ADR-060 replaces the pre-0.5.0 fixed-4096-byte buffer with three variants:
Inline— a stack buffer ofINLINE_BYTES(foundation-derived viacarrier_inline_bytes) carrying derived structural content: integer literals at any admitted Witt level, cryptographic digests at the application’s hasher output width, the κ-label ASCII form, and primitive-op single-value outputs.Borrowed— a slice into an upstream byte source (input bytes, a sibling ψ-stage’s scratch, an axis-kernel output region). Its carrier width issize_of::<&[u8]>(), independent of payload size.Stream— a chunk-emitting source for unbounded payloads, no ceiling.
INLINE_BYTES is a free const-generic parameter; the application
instantiates it at the boundary via carrier_inline_bytes::<MyBounds>()
(per the min-const-generics pattern, stable Rust, no generic_const_exprs).
Variants§
Inline
Stack-allocated inline buffer (zero-padded beyond len).
Fields
bytes: [u8; INLINE_BYTES]Fixed-capacity inline byte buffer.
Borrowed(&'a [u8])
Borrowed slice into an upstream byte source — no byte-width ceiling.
Stream(&'a dyn ChunkSource)
Chunk-emitting source for unbounded payloads — no byte-width ceiling.
Implementations§
Source§impl<'a, const INLINE_BYTES: usize> TermValue<'a, INLINE_BYTES>
impl<'a, const INLINE_BYTES: usize> TermValue<'a, INLINE_BYTES>
Sourcepub const fn empty() -> TermValue<'a, INLINE_BYTES>
pub const fn empty() -> TermValue<'a, INLINE_BYTES>
Construct an empty inline TermValue (length zero).
Sourcepub const fn inline_from_slice(bytes: &[u8]) -> TermValue<'a, INLINE_BYTES>
pub const fn inline_from_slice(bytes: &[u8]) -> TermValue<'a, INLINE_BYTES>
ADR-060: construct an Inline TermValue by copying up to
INLINE_BYTES bytes from bytes. For payloads exceeding the inline
width use TermValue::Borrowed / TermValue::Stream instead.
Sourcepub const fn borrowed(bytes: &'a [u8]) -> TermValue<'a, INLINE_BYTES>
pub const fn borrowed(bytes: &'a [u8]) -> TermValue<'a, INLINE_BYTES>
Construct a zero-copy Borrowed TermValue referencing bytes.
Sourcepub const fn stream(source: &'a dyn ChunkSource) -> TermValue<'a, INLINE_BYTES>
pub const fn stream(source: &'a dyn ChunkSource) -> TermValue<'a, INLINE_BYTES>
Construct a Stream TermValue over an unbounded chunk source.
Sourcepub const fn from_u64_be(
value: u64,
width: usize,
) -> TermValue<'a, INLINE_BYTES>
pub const fn from_u64_be( value: u64, width: usize, ) -> TermValue<'a, INLINE_BYTES>
ADR-051: construct an Inline TermValue from a u64 at a declared byte width.
Sourcepub const fn from_inline_const(
bytes: &[u8; INLINE_BYTES],
len: usize,
) -> TermValue<'a, INLINE_BYTES>
pub const fn from_inline_const( bytes: &[u8; INLINE_BYTES], len: usize, ) -> TermValue<'a, INLINE_BYTES>
ADR-060: const-constructor from a prepared inline buffer of width INLINE_BYTES.
Sourcepub fn as_slice(&self) -> Option<&[u8]>
pub fn as_slice(&self) -> Option<&[u8]>
Returns the active byte prefix for materializable carriers
(Inline / Borrowed), or None for Stream (which has no single
contiguous slice — read it via TermValue::for_each_chunk).
Sourcepub fn bytes(&self) -> &[u8]
pub fn bytes(&self) -> &[u8]
Returns the active byte prefix for Inline / Borrowed, or the empty
slice for Stream. Structural fold-rules that never produce Stream
use this; Stream-aware consumers use TermValue::for_each_chunk.
Sourcepub fn for_each_chunk(&self, f: &mut dyn FnMut(&[u8]))
pub fn for_each_chunk(&self, f: &mut dyn FnMut(&[u8]))
ADR-060: fold every byte of the carrier into f in canonical order,
dispatching on the variant — Inline / Borrowed emit a single chunk,
Stream delegates to ChunkSource::for_each_chunk. This is the
universal reader the σ-projection folds through Hasher::fold_bytes.
Sourcepub fn len_hint(&self) -> Option<usize>
pub fn len_hint(&self) -> Option<usize>
Total byte length if known: Inline/Borrowed always; Stream only
when its source reports ChunkSource::total_bytes.