Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

A client configured for one recipient key and one explicit PSK identity.

Implementations§

Source§

impl Client

Source

pub fn new( recipient_public_key: &[u8], recipient_key_id: Vec<u8>, psk: Vec<u8>, psk_id: Vec<u8>, limits: Limits, ) -> Result<Self, Error>

Validate and create a client. The public PSK ID cannot equal the PSK.

§Errors

Returns Error::InvalidConfiguration for invalid keys, identifiers, credentials, or limits.

Source

pub fn protect(&self, request: &Request) -> Result<ProtectedRequest, Error>

Protect one complete request with the platform entropy source.

§Errors

Returns a validation, clock, entropy, or cryptographic error before exposing a partially protected envelope.

Source

pub fn protect_at( &self, request: &Request, now_unix_s: u64, ) -> Result<ProtectedRequest, Error>

Protect one complete request at an injected Unix time.

This entry point exists for hosts with their own trusted clock and for deterministic conformance tests. Normal native callers use Self::protect.

§Errors

Returns a validation, entropy, or cryptographic error.

Source

pub fn protect_with_entropy( &self, request: &Request, entropy: &mut impl EntropySource, ) -> Result<ProtectedRequest, Error>

Protect one complete request with an injected fallible entropy source.

§Errors

Returns a validation, clock, entropy, or cryptographic error before exposing a partially protected envelope.

Source

pub fn protect_at_with_entropy( &self, request: &Request, now_unix_s: u64, entropy: &mut impl EntropySource, ) -> Result<ProtectedRequest, Error>

Protect a request with injected time and entropy.

§Errors

Returns a validation, entropy, or cryptographic error before exposing a partial envelope.

Source§

impl Client

Source

pub fn begin_stream( &self, head: &RequestHead, ) -> Result<(StreamRequestSealer, Vec<u8>), Error>

Start a protected request and return its bounded prefix and checked START.

§Errors

Returns a validation, entropy, or cryptographic error before source bytes are read.

Source

pub fn begin_stream_at_with_entropy( &self, head: &RequestHead, now_unix_s: u64, entropy: &mut impl EntropySource, ) -> Result<(StreamRequestSealer, Vec<u8>), Error>

Start a stream with caller-supplied time and entropy for wire tests.

§Errors

Returns a validation, entropy, or cryptographic error.

Trait Implementations§

Source§

impl Debug for Client

Source§

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

Formats the value using the given formatter. Read more

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<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 = !

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

fn try_from(value: U) -> Result<T, !>

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