Struct Framework

Source
pub struct Framework<M, R, T = Instant>
where T: Instant,
{ /* private fields */ }
Expand description

An instance of the Maybenot framework.

An instance of the Framework repeatedly takes as input one or more TriggerEvent describing the encrypted traffic going over an encrypted channel, and produces as output zero or more TriggerAction, such as to send padding traffic or block outgoing traffic. One or more Machine determine what TriggerAction to take based on TriggerEvent.

Implementations§

Source§

impl<M, R, T> Framework<M, R, T>
where M: AsRef<[Machine]>, R: RngCore, T: Instant,

Source

pub fn new( machines: M, max_padding_frac: f64, max_blocking_frac: f64, current_time: T, rng: R, ) -> Result<Self, Error>

Create a new framework instance with zero or more Machine.

The max padding/blocking fractions are enforced as a total across all machines. The only way those limits can be violated are through Machine::allowed_padding_packets and Machine::allowed_blocked_microsec, respectively.

The current time is handed to the framework here (and later in Self::trigger_events()) to make some types of use cases of the framework easier (weird machines and for simulation). The generic time type also allows for using custom time sources. This can for example improve performance.

Returns an error on any invalid Machine or limits not being fractions [0.0, 1.0].

Source

pub fn num_machines(&self) -> usize

Returns the number of machines in the framework.

Source

pub fn trigger_events( &mut self, events: &[TriggerEvent], current_time: T, ) -> impl Iterator<Item = &TriggerAction<T>>

Trigger zero or more TriggerEvent for all machines running in the framework.

The current_time SHOULD be the current time at the time of calling the method (e.g., Instant::now()).

In more detail, the current_time SHOULD be a monotonically nondecreasing clock. This means that the time passed SHOULD never be earlier than what was given to Framework::new() or a previous call to trigger_events for the same framework instance. If this requirement is not followed, blocking durations MAY be inaccurately accounted for, leading to less or more TriggerAction::BlockOutgoing than intended by set framework and machine limits. The consequences of this depend on the running machines (e.g., a machine may also pad as a consequence of blocking) and the use-case for the user of the framework.

Returns an iterator of zero or more TriggerAction that MUST be taken by the caller.

Trait Implementations§

Source§

impl<M: Clone, R: Clone, T> Clone for Framework<M, R, T>
where T: Instant + Clone, T::Duration: Clone,

Source§

fn clone(&self) -> Framework<M, R, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<M: Debug, R: Debug, T> Debug for Framework<M, R, T>
where T: Instant + Debug, T::Duration: Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<M, R, T> Freeze for Framework<M, R, T>
where T: Freeze, R: Freeze, M: Freeze, <T as Instant>::Duration: Freeze,

§

impl<M, R, T> RefUnwindSafe for Framework<M, R, T>

§

impl<M, R, T> Send for Framework<M, R, T>
where T: Send, R: Send, M: Send, <T as Instant>::Duration: Send,

§

impl<M, R, T> Sync for Framework<M, R, T>
where T: Sync, R: Sync, M: Sync, <T as Instant>::Duration: Sync,

§

impl<M, R, T> Unpin for Framework<M, R, T>
where T: Unpin, R: Unpin, M: Unpin, <T as Instant>::Duration: Unpin,

§

impl<M, R, T> UnwindSafe for Framework<M, R, T>

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