[−][src]Struct round_based::dev::AsyncSimulation
Emulates running protocol between local parties using AsyncProtocol
Takes parties (every party is instance of StateMachine) and executes protocol between them.
Compared to Simulation, AsyncSimulation requires tokio runtime and introduces parallelism, so it's heavier and more suitable for writing tests as it backed by protocol executor that will likely be used in production.
Limitations
- Doesn't log process of protocol execution (except for occurring non critical errors). Limited by ProtocolWatcher API (to be expanded).
Example
let results: Vec<Result<Party::Output, _>> = AsyncSimulation::new() .add_party(Party::new(1, 3)) .add_party(Party::new(2, 3)) .add_party(Party::new(3, 3)) .run() .await;
Implementations
impl<SM> AsyncSimulation<SM> where
SM: StateMachine + Send + 'static,
SM::MessageBody: Send + Clone + Unpin + 'static,
SM::Err: Send + Debug,
SM::Output: Send,
[src]
SM: StateMachine + Send + 'static,
SM::MessageBody: Send + Clone + Unpin + 'static,
SM::Err: Send + Debug,
SM::Output: Send,
pub fn new() -> Self
[src]
Creates new simulation
pub fn add_party(&mut self, party: SM) -> &mut Self
[src]
Adds protocol participant
pub async fn run(&mut self) -> Vec<Result<SM::Output, AsyncSimulationError<SM>>>
[src]
Runs a simulation
Returns
Returns Vec of execution results. Every party is executed independently, simulation will continue until each party finish protocol (either with success or error).
It's an error to call this method twice. In this case,
vec![Err(AsyncSimulationError::Exhausted); n]
is returned
Auto Trait Implementations
impl<SM> !RefUnwindSafe for AsyncSimulation<SM>
[src]
impl<SM> Send for AsyncSimulation<SM> where
SM: Send,
<SM as StateMachine>::MessageBody: Send,
[src]
SM: Send,
<SM as StateMachine>::MessageBody: Send,
impl<SM> !Sync for AsyncSimulation<SM>
[src]
impl<SM> Unpin for AsyncSimulation<SM> where
SM: Unpin,
[src]
SM: Unpin,
impl<SM> !UnwindSafe for AsyncSimulation<SM>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,