Skip to content

Commit cf466c7

Browse files
committed
Update docs
Signed-off-by: Denis Varlakov <denis@dfns.co>
1 parent 5213b10 commit cf466c7

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ the documentation of the protocol you're using), but usually they are:
3535

3636
## Features
3737

38-
* `dev` enables development tools such as protocol simulation
38+
* `sim` enables protocol execution simulation, see `sim` module
39+
* `sim-async` enables protocol execution simulation with tokio runtime, see `sim::async_env`
40+
module
41+
* `state-machine` provides ability to carry out the protocol, defined as async function, via Sync
42+
API, see `state_machine` module
43+
* `derive` is needed to use `ProtocolMessage` proc macro
3944
* `runtime-tokio` enables tokio-specific implementation of async runtime
4045

4146
## Join us in Discord!

round-based/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ rand_dev = "0.1"
4141
default = ["std"]
4242
state-machine = []
4343
sim = ["std", "state-machine"]
44-
sim-async = ["std", "tokio/sync", "tokio-stream", "futures-util/alloc"]
44+
sim-async = ["sim", "tokio/sync", "tokio-stream", "futures-util/alloc"]
4545
derive = ["round-based-derive"]
4646
runtime-tokio = ["tokio"]
4747
std = ["thiserror"]

round-based/src/lib.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@
3535
//!
3636
//! ## Features
3737
//!
38-
//! * `dev` enables development tools such as [protocol simulation](sim)
38+
//! * `sim` enables protocol execution simulation, see [`sim`] module
39+
//! * `sim-async` enables protocol execution simulation with tokio runtime, see [`sim::async_env`]
40+
//! module
41+
//! * `state-machine` provides ability to carry out the protocol, defined as async function, via Sync
42+
//! API, see [`state_machine`] module
43+
//! * `derive` is needed to use [`ProtocolMessage`](macro@ProtocolMessage) proc macro
3944
//! * `runtime-tokio` enables [tokio]-specific implementation of [async runtime](runtime)
4045
//!
4146
//! ## Join us in Discord!

round-based/src/state_machine/mod.rs

+27
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,33 @@
44
//! may not be possible/desirable to have async runtime which drives the futures until completion.
55
//! For such use-cases, we provide [`wrap_protocol`] function that wraps an MPC protocol defined as
66
//! async function and returns the [`StateMachine`] that exposes sync API to carry out the protocol.
7+
//!
8+
//! ## Example
9+
//! ```rust,no_run
10+
//! use round_based::{Mpc, PartyIndex};
11+
//!
12+
//! # type Result<T, E = ()> = std::result::Result<T, E>;
13+
//! # type Randomness = [u8; 32];
14+
//! # type Msg = ();
15+
//! // Any MPC protocol
16+
//! pub async fn protocol_of_random_generation<M>(
17+
//! party: M,
18+
//! i: PartyIndex,
19+
//! n: u16
20+
//! ) -> Result<Randomness>
21+
//! where
22+
//! M: Mpc<ProtocolMessage = Msg>
23+
//! {
24+
//! // ...
25+
//! # todo!()
26+
//! }
27+
//!
28+
//! let state_machine = round_based::state_machine::wrap_protocol(
29+
//! |party| protocol_of_random_generation(party, 0, 3)
30+
//! );
31+
//! // `state_machine` implements `round_based::state_machine::StateMachine` trait.
32+
//! // Its methods can be used to advance protocol until completion.
33+
//! ```
734
835
mod delivery;
936
mod noop_waker;

0 commit comments

Comments
 (0)