pub trait Relay: Send + Sync {
// Required methods
fn broadcast<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
session_id: &'life1 SessionId,
round: u32,
message: &'life2 T,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where T: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn send_direct<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
session_id: &'life1 SessionId,
round: u32,
to: PartyId,
message: &'life2 T,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where T: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn collect_broadcasts<'life0, 'life1, 'async_trait, T>(
&'life0 self,
session_id: &'life1 SessionId,
round: u32,
count: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned + Send,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn collect_direct<'life0, 'life1, 'async_trait, T>(
&'life0 self,
session_id: &'life1 SessionId,
round: u32,
my_id: PartyId,
count: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned + Send,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Message relay trait for MPC communication
Implementations of this trait handle the transport of messages between MPC protocol participants. The relay is responsible for:
- Broadcasting messages to all parties
- Sending direct (point-to-point) messages
- Collecting and delivering messages by round
Required Methods§
Sourcefn broadcast<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
session_id: &'life1 SessionId,
round: u32,
message: &'life2 T,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
fn broadcast<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, session_id: &'life1 SessionId, round: u32, message: &'life2 T, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
Broadcast a message to all parties in the session
§Arguments
session_id- Unique session identifierround- Protocol round numbermessage- Message to broadcast (will be serialized)
Sourcefn send_direct<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
session_id: &'life1 SessionId,
round: u32,
to: PartyId,
message: &'life2 T,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
fn send_direct<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, session_id: &'life1 SessionId, round: u32, to: PartyId, message: &'life2 T, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
Send a direct message to a specific party
§Arguments
session_id- Unique session identifierround- Protocol round numberto- Target party IDmessage- Message to send (will be serialized)
Sourcefn collect_broadcasts<'life0, 'life1, 'async_trait, T>(
&'life0 self,
session_id: &'life1 SessionId,
round: u32,
count: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Send,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn collect_broadcasts<'life0, 'life1, 'async_trait, T>(
&'life0 self,
session_id: &'life1 SessionId,
round: u32,
count: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Send,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Collect broadcast messages from all parties for a round
This method blocks until count messages have been received.
§Arguments
session_id- Unique session identifierround- Protocol round numbercount- Number of messages to collect
Sourcefn collect_direct<'life0, 'life1, 'async_trait, T>(
&'life0 self,
session_id: &'life1 SessionId,
round: u32,
my_id: PartyId,
count: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Send,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn collect_direct<'life0, 'life1, 'async_trait, T>(
&'life0 self,
session_id: &'life1 SessionId,
round: u32,
my_id: PartyId,
count: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Send,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Collect direct messages sent to this party
This method blocks until count messages have been received.
§Arguments
session_id- Unique session identifierround- Protocol round numbermy_id- This party’s IDcount- Number of messages to collect
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.