Skip to main content

Headers

Struct Headers 

Source
pub struct Headers<'a> {
    pub substrate: &'a str,
    pub receipt: &'a str,
    pub algorithms: &'a str,
    pub timestamp_ms: u64,
}
Expand description

Zero-allocation view of the four substrate headers.

Construct with Self::from_strs when you have already extracted the raw string values, or enable the reqwest-support feature to use [Self::from_reqwest] for one-line extraction from a reqwest::Response.

Fields§

§substrate: &'a str

Value of X-H33-Substrate — 64 lowercase hex chars.

§receipt: &'a str

Value of X-H33-Receipt — 84 lowercase hex chars.

§algorithms: &'a str

Value of X-H33-Algorithms — comma-separated algorithm identifiers.

§timestamp_ms: u64

Value of X-H33-Substrate-Ts — already parsed from string to u64.

Implementations§

Source§

impl<'a> Headers<'a>

Source

pub const fn from_strs( substrate: &'a str, receipt: &'a str, algorithms: &'a str, timestamp_ms: u64, ) -> Self

Construct from already-extracted string slices. This is the no_std-friendly constructor that every other constructor ultimately calls into.

§Examples
use h33_substrate_verifier::Headers;

let headers = Headers::from_strs(
    "f3a8b2c1deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
    "012e891fa4cafebabedeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef\
     0000000012345678\
     07",
    "ML-DSA-65,FALCON-512,SPHINCS+-SHA2-128f",
    1_733_942_731_234,
);
assert_eq!(headers.substrate.len(), 64);
Source

pub fn decode_substrate(&self) -> Result<[u8; 32], VerifierError>

Parse the hex-encoded X-H33-Substrate value into the raw 32-byte SHA3-256 digest it represents. Runs length and hex-character validation before decoding.

Source

pub fn algorithm_identifiers(&self) -> impl Iterator<Item = &'a str>

Split X-H33-Algorithms into its comma-separated parts, trimming whitespace. Returns an iterator that is lazy and zero-copy.

Trait Implementations§

Source§

impl<'a> Clone for Headers<'a>

Source§

fn clone(&self) -> Headers<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Headers<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for Headers<'a>

Source§

fn eq(&self, other: &Headers<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Copy for Headers<'a>

Source§

impl<'a> Eq for Headers<'a>

Source§

impl<'a> StructuralPartialEq for Headers<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Headers<'a>

§

impl<'a> RefUnwindSafe for Headers<'a>

§

impl<'a> Send for Headers<'a>

§

impl<'a> Sync for Headers<'a>

§

impl<'a> Unpin for Headers<'a>

§

impl<'a> UnsafeUnpin for Headers<'a>

§

impl<'a> UnwindSafe for Headers<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.