pub struct ContentKey<T> { /* private fields */ }Expand description
A content address derived by construction from a value of type T.
§The type-level seal (M3 — the stale-key/decoupling axis)
The general ContentMemo::get_or_compute lets the key and the
compute closure disagree: a caller can pass a key that is not a
function of what compute actually reads (the stale-key footgun — the
Sharing::PerSite/libxcrypt divergence class). ContentKey<T> removes
that footgun structurally: its sole constructor is ContentKey::of,
which hashes T’s structural read-set. So “the key IS the content of the
input” is not a caller obligation — it holds by construction, and a
key decoupled from its input has no way to be built.
Paired with ContentMemo::get_or_compute_keyed, which derives the key
from the same &T it hands to compute, the key↔content decoupling axis
is parse-time-rejected (there is no expressible program that memoizes
under a key not derived from the computed input).
§Honest ceiling — what this does NOT seal
This seals the KEY↔CONTENT structural axis only. It does not seal the
purity of T → V: compute could still read wall-clock, getEnv, or a
mutable filesystem — those are opaque to the type system. There is no
PureFn in safe Rust and there cannot be, so the purity axis stays
only-mitigated (C1) forever (the module invariant + the CI byte gate are
the correct terminal enforcement). Do not read ContentKey<T> as a purity
proof — it is a decoupling proof.
The digest is a 32-byte BLAKE3 over T’s Hash serialization, so the key
is a stable, collision-resistant content address of the value’s structural
fields.
The trait impls below are hand-written (not #[derive]d) so they hold for
any T — the standard derive would demand T: Clone + Eq + Hash + …
even though the only real field is the 32-byte digest (T lives only in a
zero-size PhantomData).
Implementations§
Source§impl<T> ContentKey<T>where
T: Hash,
impl<T> ContentKey<T>where
T: Hash,
Sourcepub fn of(input: &T) -> ContentKey<T>
pub fn of(input: &T) -> ContentKey<T>
Derive the content key from input — the sole constructor.
Hashes input’s structural read-set (everything its Hash impl writes)
through BLAKE3, so the returned key is a pure, deterministic function of
input’s content. Two structurally-equal Ts produce the identical key;
there is no way to construct a ContentKey<T> that is not the content
address of some &T.
Trait Implementations§
Source§impl<T> Clone for ContentKey<T>
impl<T> Clone for ContentKey<T>
Source§fn clone(&self) -> ContentKey<T>
fn clone(&self) -> ContentKey<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<T> Copy for ContentKey<T>
Source§impl<T> Debug for ContentKey<T>
impl<T> Debug for ContentKey<T>
impl<T> Eq for ContentKey<T>
Source§impl<T> Hash for ContentKey<T>
impl<T> Hash for ContentKey<T>
Auto Trait Implementations§
impl<T> Freeze for ContentKey<T>
impl<T> RefUnwindSafe for ContentKey<T>
impl<T> Send for ContentKey<T>
impl<T> Sync for ContentKey<T>
impl<T> Unpin for ContentKey<T>
impl<T> UnsafeUnpin for ContentKey<T>
impl<T> UnwindSafe for ContentKey<T>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.