pub struct Verified<'a> { /* private fields */ }Expand description
A decoder module that hashes to what the container says it should.
The point of this type is that it has no public constructor. Policy::decoder is the only
thing that makes one, and hashing the bytes is the only thing it does, so a caller holding a
Verified is holding proof that the comparison happened. That is a stronger promise than a
function that checks and then returns a slice, because the slice is the same slice whether or
not anybody called the checker.
The module is borrowed from the container when it is embedded and owned when a resolver went and found it, which is the only difference the two cases make once the hash has matched.
Implementations§
Source§impl<'a> Verified<'a>
impl<'a> Verified<'a>
Sourcepub const fn digest(&self) -> Digest
pub const fn digest(&self) -> Digest
The digest of the module.
This is the decoder’s identity: the container names it, this crate recomputed it, and the two agreed. A host with a native implementation of this exact module looks it up by this value and runs that instead, which is what makes substitution safe rather than a matter of trusting a name.
Sourcepub const fn record(&self) -> &DecoderRef<'a>
pub const fn record(&self) -> &DecoderRef<'a>
What the container says about the decoder: its name, its ABI version and what it needs.