Skip to main content

Clauses

Struct Clauses 

Source
pub struct Clauses<T> { /* private fields */ }
Expand description

A verified mandate’s clauses. Constructible only by the verifier terminals, so its existence is proof the mandate authenticated and decoded as canonical CBOR (the mandate-must-be-authenticated rule of the Security Considerations, §16.2; the Reserved fields section, §8).

use obsigil::{Issuer, MandateKey, NoApp, Verifier};
let token = Issuer::new(MandateKey::from_bytes([42u8; 64])?)
    .clauses(&NoApp::default())
    .exp(4_000_000_000)
    .subject("user-1")
    .mint()?;
let key = MandateKey::from_bytes([42u8; 64])?;
let clauses = Verifier::new().key(&key).now(1_000_000_000)
    .clauses::<NoApp>(&token)?;
assert_eq!(clauses.exp(), 4_000_000_000);
assert_eq!(clauses.subject(), Some("user-1"));
assert_eq!(clauses.tid().get_version_num(), 7); // UUIDv7 (the `tid` field, §8.2)

Implementations§

Source§

impl<T> Clauses<T>

Source

pub fn exp(&self) -> NumericDate

Authoritative expiry (the exp field, §8.3).

Source

pub fn tid(&self) -> Uuid

The unique token id (UUIDv7, the tid field, §8.2).

Source

pub fn issued_at(&self) -> NumericDate

Issue time, derived from tid (the tid field, §8.2).

Source

pub fn issuer(&self) -> Option<&str>

Issuer, for audit (the iss field, §8.6).

Source

pub fn iss(&self) -> Option<&str>

Short alias for issuer.

Source

pub fn audience(&self) -> Option<&[String]>

Intended verifiers (the aud field, §8.4).

Source

pub fn aud(&self) -> Option<&[String]>

Short alias for audience.

Source

pub fn subject(&self) -> Option<&str>

Subject authorized (the sub field, §8.5).

Source

pub fn sub(&self) -> Option<&str>

Short alias for subject.

Source

pub fn app(&self) -> &T

The application clauses.

Source

pub fn into_app(self) -> T

Consume the clauses, yielding the application value.

Trait Implementations§

Source§

impl<T: Debug> Debug for Clauses<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Clauses<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Clauses<T>
where T: RefUnwindSafe,

§

impl<T> Send for Clauses<T>
where T: Send,

§

impl<T> Sync for Clauses<T>
where T: Sync,

§

impl<T> Unpin for Clauses<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Clauses<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Clauses<T>
where T: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.