Skip to main content

PinHeader

Struct PinHeader 

Source
pub struct PinHeader {
    pub v: u32,
    pub model: String,
    pub model_hash: Option<String>,
    pub source_hash: String,
    pub vec_hash: String,
    pub vec_dtype: String,
    pub vec_dim: u32,
    pub ts: String,
    pub extra: BTreeMap<String, String>,
}
Expand description

The signed portion of a Pin.

Two pins are considered equivalent iff their headers canonicalize to identical bytes. Optional fields (model_hash, extra) are omitted from the canonical form when unset, never written as null — this matters because adding a null would change the byte sequence the signature commits to.

You normally do not construct PinHeader directly; obtain one from Signer::pin or Signer::pin_with_options.

Fields§

§v: u32

Protocol version. Must equal PROTOCOL_VERSION.

§model: String

Embedding model identifier.

§model_hash: Option<String>

Optional content hash of the model weights.

§source_hash: String

SHA-256 of the source text (UTF-8 NFC).

§vec_hash: String

SHA-256 of the embedding vector under the declared dtype.

§vec_dtype: String

"f32" or "f64".

§vec_dim: u32

Embedding dimensionality.

§ts: String

RFC 3339 / ISO 8601 timestamp in UTC, e.g. "2026-05-05T12:00:00Z".

§extra: BTreeMap<String, String>

Producer-defined string-to-string metadata, signed alongside the rest of the header. Omitted from the canonical form when empty.

Implementations§

Source§

impl PinHeader

Source

pub fn canonicalize(&self) -> Vec<u8>

Stable byte representation for signing/verifying.

JSON with sorted keys and no whitespace. BTreeMap gives us sorted extra for free; field order is fixed by hand below to match the Python reference.

Trait Implementations§

Source§

impl Clone for PinHeader

Source§

fn clone(&self) -> PinHeader

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PinHeader

Source§

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

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

impl<'de> Deserialize<'de> for PinHeader

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for PinHeader

Source§

fn eq(&self, other: &PinHeader) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Serialize for PinHeader

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for PinHeader

Source§

impl StructuralPartialEq for PinHeader

Auto Trait Implementations§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,