Skip to main content

TrustStore

Struct TrustStore 

Source
pub struct TrustStore {
    pub schema: String,
    pub pins: Vec<TrustPin>,
}
Expand description

The persisted trust store: a schema tag plus the ordered list of pins.

Fields§

§schema: String

Schema identifier. Always TRUST_STORE_SCHEMA for files this version writes; parsing tolerates a missing tag (legacy/empty).

§pins: Vec<TrustPin>

Pinned identities, in insertion order.

Implementations§

Source§

impl TrustStore

Source

pub fn default_path() -> PathBuf

Default store path: <config-root>/trust-store.json.

Honors TSAFE_VAULT_DIR via crate::profile::config_path’s sibling logic so tests and sandboxes can redirect it.

Source

pub fn load(path: &Path) -> Result<TrustStore, TrustStoreError>

Load the store from path, returning an empty store if the file does not exist (first-run is not an error).

Source

pub fn load_default() -> Result<TrustStore, TrustStoreError>

Load from the default path.

Source

pub fn save(&self, path: &Path) -> Result<(), TrustStoreError>

Persist the store to path atomically (write-tmp + rename).

Source

pub fn add( &mut self, name: &str, algo: &str, pubkey: &str, ) -> Result<(), TrustStoreError>

Add a pin. Validates that pubkey decodes to a real Ed25519 key and algo is supported BEFORE persisting, so a corrupt pin can never enter the store. Rejects a duplicate name (use TrustStore::remove first to rotate a key under an existing name).

Source

pub fn remove(&mut self, name: &str) -> Result<TrustPin, TrustStoreError>

Remove the pin named name. Errors if no such pin exists.

Source

pub fn identity_for_pubkey(&self, pubkey_b64url: &str) -> Option<&TrustPin>

Look up the pinned identity that owns pubkey, if any.

Comparison is on the decoded key bytes, not the string, so two base64url encodings of the same key (or differing-by-padding representations) still match.

Source

pub fn identity_for_signature( &self, sig: &SignaturePayload, ) -> Option<&TrustPin>

Resolve which pinned identity (if any) a signature payload’s embedded pubkey corresponds to. This is the fail-closed gate’s core question: “is the signer a key we have pinned?”

Source

pub fn is_empty(&self) -> bool

True when at least one pin is present.

Source

pub fn len(&self) -> usize

Number of pinned identities.

Trait Implementations§

Source§

impl Clone for TrustStore

Source§

fn clone(&self) -> TrustStore

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 TrustStore

Source§

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

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

impl Default for TrustStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for TrustStore

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 Eq for TrustStore

Source§

impl PartialEq for TrustStore

Source§

fn eq(&self, other: &TrustStore) -> 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 TrustStore

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 StructuralPartialEq for TrustStore

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> AnyEq for T
where T: Any + PartialEq,

Source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

Source§

fn as_any(&self) -> &(dyn Any + 'static)

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more