From cf466c770bad992bf288b3564f254de726a60a94 Mon Sep 17 00:00:00 2001 From: Denis Varlakov Date: Fri, 29 Nov 2024 10:26:16 +0100 Subject: [PATCH] Update docs Signed-off-by: Denis Varlakov --- README.md | 7 ++++++- round-based/Cargo.toml | 2 +- round-based/src/lib.rs | 7 ++++++- round-based/src/state_machine/mod.rs | 27 +++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8de592a..5308be4 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,12 @@ the documentation of the protocol you're using), but usually they are: ## Features -* `dev` enables development tools such as protocol simulation +* `sim` enables protocol execution simulation, see `sim` module + * `sim-async` enables protocol execution simulation with tokio runtime, see `sim::async_env` + module +* `state-machine` provides ability to carry out the protocol, defined as async function, via Sync + API, see `state_machine` module +* `derive` is needed to use `ProtocolMessage` proc macro * `runtime-tokio` enables tokio-specific implementation of async runtime ## Join us in Discord! diff --git a/round-based/Cargo.toml b/round-based/Cargo.toml index ac9af58..5abf394 100644 --- a/round-based/Cargo.toml +++ b/round-based/Cargo.toml @@ -41,7 +41,7 @@ rand_dev = "0.1" default = ["std"] state-machine = [] sim = ["std", "state-machine"] -sim-async = ["std", "tokio/sync", "tokio-stream", "futures-util/alloc"] +sim-async = ["sim", "tokio/sync", "tokio-stream", "futures-util/alloc"] derive = ["round-based-derive"] runtime-tokio = ["tokio"] std = ["thiserror"] diff --git a/round-based/src/lib.rs b/round-based/src/lib.rs index d765bb1..a035069 100644 --- a/round-based/src/lib.rs +++ b/round-based/src/lib.rs @@ -35,7 +35,12 @@ //! //! ## Features //! -//! * `dev` enables development tools such as [protocol simulation](sim) +//! * `sim` enables protocol execution simulation, see [`sim`] module +//! * `sim-async` enables protocol execution simulation with tokio runtime, see [`sim::async_env`] +//! module +//! * `state-machine` provides ability to carry out the protocol, defined as async function, via Sync +//! API, see [`state_machine`] module +//! * `derive` is needed to use [`ProtocolMessage`](macro@ProtocolMessage) proc macro //! * `runtime-tokio` enables [tokio]-specific implementation of [async runtime](runtime) //! //! ## Join us in Discord! diff --git a/round-based/src/state_machine/mod.rs b/round-based/src/state_machine/mod.rs index 2d6e683..7b12c84 100644 --- a/round-based/src/state_machine/mod.rs +++ b/round-based/src/state_machine/mod.rs @@ -4,6 +4,33 @@ //! may not be possible/desirable to have async runtime which drives the futures until completion. //! For such use-cases, we provide [`wrap_protocol`] function that wraps an MPC protocol defined as //! async function and returns the [`StateMachine`] that exposes sync API to carry out the protocol. +//! +//! ## Example +//! ```rust,no_run +//! use round_based::{Mpc, PartyIndex}; +//! +//! # type Result = std::result::Result; +//! # type Randomness = [u8; 32]; +//! # type Msg = (); +//! // Any MPC protocol +//! pub async fn protocol_of_random_generation( +//! party: M, +//! i: PartyIndex, +//! n: u16 +//! ) -> Result +//! where +//! M: Mpc +//! { +//! // ... +//! # todo!() +//! } +//! +//! let state_machine = round_based::state_machine::wrap_protocol( +//! |party| protocol_of_random_generation(party, 0, 3) +//! ); +//! // `state_machine` implements `round_based::state_machine::StateMachine` trait. +//! // Its methods can be used to advance protocol until completion. +//! ``` mod delivery; mod noop_waker;