Skip to main content

SessionBuilder

Struct SessionBuilder 

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

Opt-in configuration for a fresh Session. Constructed via Session::builder; finalized via SessionBuilder::build.

Defaults reproduce Session::new: random source_id + epoch, DEFAULT_REKEY_GRACE grace, 64-slot replay window, and consent_required = false (→ crate::consent::ConsentState::LegacyBypass when the consent feature is on).

Implementations§

Source§

impl SessionBuilder

Source

pub fn new() -> Self

Create a builder with default values.

Source

pub fn with_source_id(self, source_id: [u8; 8], epoch: u8) -> Self

Pin the source_id + epoch for deterministic test fixtures. Normal callers SHOULD omit this and let the builder randomize.

Source

pub fn with_rekey_grace(self, grace: Duration) -> Self

Override the previous-key grace duration. See DEFAULT_REKEY_GRACE.

Available on crate feature consent only.

Require the consent ceremony to complete before application FRAME / INPUT / FRAME_LZ4 payloads are accepted.

  • require = false (default): initial state is LegacyBypass; consent is handled out-of-band by the application.
  • require = true: initial state is AwaitingRequest; application payloads are blocked until a ConsentRequest + approving ConsentResponse transition the session to Approved.

Only available with the consent feature.

Source

pub fn with_replay_window_bits(self, bits: u32) -> Self

Override the per-stream replay window size in bits. Must be a multiple of 64; valid values are 64 (default), 128, 256, 512, 1024.

Memory cost per (source_id, pld_type, key_epoch) stream is bits / 8 bytes of bitmap plus a small constant. 1024-slot windows cost 128 bytes per stream.

Panics at build() time if the value is out of range.

Source

pub fn build(self) -> Session

Finalize the builder and construct a Session.

Panics if replay_window_bits is invalid (not a multiple of 64, less than 64, or more than 1024).

Trait Implementations§

Source§

impl Default for SessionBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. 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<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, 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