pub struct Round<'a, R> { /* private fields */ }
Expand description
A structure for receiving a round of messages.
This struct manages the reception of a fixed number of messages with a specific tag in a single round of communication.
§Type Parameters
'a
- The lifetime of the parentFilteredMsgRelay
R
- The type of the underlying relay
Implementations§
Source§impl<'a, R: Relay> Round<'a, R>
impl<'a, R: Relay> Round<'a, R>
Sourcepub fn new(
count: usize,
tag: MessageTag,
relay: &'a mut FilteredMsgRelay<R>,
) -> Self
pub fn new( count: usize, tag: MessageTag, relay: &'a mut FilteredMsgRelay<R>, ) -> Self
Sourcepub async fn recv(&mut self) -> Result<Option<(Vec<u8>, usize, bool)>, Error>
pub async fn recv(&mut self) -> Result<Option<(Vec<u8>, usize, bool)>, Error>
Receives the next message in the round.
§Returns
Ok(Some(message, party_index, is_abort_flag))
on successful receptionOk(None)
when the round is completeErr(Error)
if an error occurs
Sourcepub fn put_back(&mut self, msg: &[u8], tag: MessageTag, party_id: usize)
pub fn put_back(&mut self, msg: &[u8], tag: MessageTag, party_id: usize)
Returns a message back to the expected messages queue.
This is used when a message is received but found to be invalid.
§Arguments
msg
- The message to put backtag
- The message tagparty_id
- The ID of the party that sent the message
Sourcepub async fn of_signed_messages<T, F, S, E>(
self,
setup: &S,
abort_err: impl Fn(usize) -> E,
handler: F,
) -> Result<(), E>
pub async fn of_signed_messages<T, F, S, E>( self, setup: &S, abort_err: impl Fn(usize) -> E, handler: F, ) -> Result<(), E>
Receives all messages in the round, verifies them, decodes them, and passes them to a handler.
§Type Parameters
T
- The type of the message payloadF
- The handler function typeS
- The protocol participant typeE
- The error type
§Arguments
setup
- The protocol participant setupabort_err
- Function to create an error from an abort messagehandler
- Function to handle each received message
§Returns
Ok(())
if all messages are successfully processed, or an error if any message fails
Sourcepub async fn of_encrypted_messages<T, F, P, E>(
self,
setup: &P,
scheme: &mut dyn EncryptionScheme,
trailer: usize,
err: impl Fn(usize) -> E,
handler: F,
) -> Result<(), E>
pub async fn of_encrypted_messages<T, F, P, E>( self, setup: &P, scheme: &mut dyn EncryptionScheme, trailer: usize, err: impl Fn(usize) -> E, handler: F, ) -> Result<(), E>
Receives all encrypted messages in the round, decrypts them, and passes them to a handler.
§Type Parameters
T
- The type of the message payloadF
- The handler function typeP
- The protocol participant typeE
- The error type
§Arguments
setup
- The protocol participant setupscheme
- The encryption scheme to usetrailer
- Size of the trailer dataerr
- Function to create an error from an abort messagehandler
- Function to handle each received message
§Returns
Ok(())
if all messages are successfully processed, or an error if any message fails
Sourcepub async fn broadcast_4<P, T1, T2, T3, T4>(
self,
setup: &P,
msg: (T1, T2, T3, T4),
) -> Result<(Pairs<T1, usize>, Pairs<T2, usize>, Pairs<T3, usize>, Pairs<T4, usize>), Error>
pub async fn broadcast_4<P, T1, T2, T3, T4>( self, setup: &P, msg: (T1, T2, T3, T4), ) -> Result<(Pairs<T1, usize>, Pairs<T2, usize>, Pairs<T3, usize>, Pairs<T4, usize>), Error>
Broadcasts four different types of messages to all participants.
§Type Parameters
P
- The protocol participant typeT1
- The type of the first messageT2
- The type of the second messageT3
- The type of the third messageT4
- The type of the fourth message
§Arguments
setup
- The protocol participant setupmsg
- Tuple of four messages to broadcast
§Returns
A tuple of four Pairs
containing the broadcast messages and their senders
Sourcepub async fn recv_broadcast_4<P, T1, T2, T3, T4>(
self,
setup: &P,
sizes: &[usize; 4],
) -> Result<(Pairs<T1, usize>, Pairs<T2, usize>, Pairs<T3, usize>, Pairs<T4, usize>), Error>
pub async fn recv_broadcast_4<P, T1, T2, T3, T4>( self, setup: &P, sizes: &[usize; 4], ) -> Result<(Pairs<T1, usize>, Pairs<T2, usize>, Pairs<T3, usize>, Pairs<T4, usize>), Error>
Receives four different types of broadcast messages from all participants.
§Type Parameters
P
- The protocol participant typeT1
- The type of the first messageT2
- The type of the second messageT3
- The type of the third messageT4
- The type of the fourth message
§Arguments
setup
- The protocol participant setupsizes
- Array of sizes for each message type
§Returns
A tuple of four Pairs
containing the received messages and their senders