Struct round_based::simulation::SimulationSync

source ·
pub struct SimulationSync<'a, O, M> { /* private fields */ }
Available on crate features state-machine and dev only.
Expand description

Simulates MPC protocol with parties defined as state machines

Implementations§

source§

impl<'a, O, M> SimulationSync<'a, O, M>
where M: Clone + 'static,

source

pub fn empty() -> Self

Creates empty simulation containing no parties

New parties can be added via .add_party()

source

pub fn with_capacity(n: u16) -> Self

Constructs empty simulation containing no parties, with allocated memory that can fit up to n parties without re-allocations

source

pub fn from_async_fn<F>(n: u16, init: impl FnMut(u16, MpcParty<M>) -> F) -> Self
where F: Future<Output = O> + 'a,

Constructs a simulation with n parties from async function that defines the protocol

Each party has index 0 <= i < n and instantiated via provided init function

source

pub fn from_fn<S>(n: u16, init: impl FnMut(u16) -> S) -> Self
where S: StateMachine<Output = O, Msg = M> + 'a,

Construct a simulation with n parties from init function that constructs state machine for each party

Each party has index 0 <= i < n and instantiated via provided init function

source

pub fn add_party(&mut self, party: impl StateMachine<Output = O, Msg = M> + 'a)

Adds new party into the protocol

New party will be assigned index i = n - 1 where n is amount of parties in the simulation after this party was added.

source

pub fn parties_amount(&self) -> usize

Returns amount of parties in the simulation

source

pub fn run(self) -> Result<Vec<O>, SimulationSyncError>

Carries out the simulation

Auto Trait Implementations§

§

impl<'a, O, M> Freeze for SimulationSync<'a, O, M>

§

impl<'a, O, M> !RefUnwindSafe for SimulationSync<'a, O, M>

§

impl<'a, O, M> !Send for SimulationSync<'a, O, M>

§

impl<'a, O, M> !Sync for SimulationSync<'a, O, M>

§

impl<'a, O, M> Unpin for SimulationSync<'a, O, M>
where O: Unpin,

§

impl<'a, O, M> !UnwindSafe for SimulationSync<'a, O, M>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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