Struct Round

Source
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 parent FilteredMsgRelay
  • R - The type of the underlying relay

Implementations§

Source§

impl<'a, R: Relay> Round<'a, R>

Source

pub fn new( count: usize, tag: MessageTag, relay: &'a mut FilteredMsgRelay<R>, ) -> Self

Creates a new round with a given number of messages to receive.

§Arguments
  • count - Number of messages to receive in this round
  • tag - The expected message tag
  • relay - The parent message relay
§Returns

A new Round instance

Source

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 reception
  • Ok(None) when the round is complete
  • Err(Error) if an error occurs
Source

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 back
  • tag - The message tag
  • party_id - The ID of the party that sent the message
Source

pub async fn of_signed_messages<T, F, S, E>( self, setup: &S, abort_err: impl Fn(usize) -> E, handler: F, ) -> Result<(), E>
where T: AnyBitPattern + NoUninit, S: ProtocolParticipant, F: FnMut(&T, usize) -> Result<(), E>, E: From<Error>,

Receives all messages in the round, verifies them, decodes them, and passes them to a handler.

§Type Parameters
  • T - The type of the message payload
  • F - The handler function type
  • S - The protocol participant type
  • E - The error type
§Arguments
  • setup - The protocol participant setup
  • abort_err - Function to create an error from an abort message
  • handler - Function to handle each received message
§Returns

Ok(()) if all messages are successfully processed, or an error if any message fails

Source

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>
where T: AnyBitPattern + NoUninit, P: ProtocolParticipant, F: FnMut(&T, usize, &[u8], &mut dyn EncryptionScheme) -> Result<Option<Vec<u8>>, E>, E: From<Error>,

Receives all encrypted messages in the round, decrypts them, and passes them to a handler.

§Type Parameters
  • T - The type of the message payload
  • F - The handler function type
  • P - The protocol participant type
  • E - The error type
§Arguments
  • setup - The protocol participant setup
  • scheme - The encryption scheme to use
  • trailer - Size of the trailer data
  • err - Function to create an error from an abort message
  • handler - Function to handle each received message
§Returns

Ok(()) if all messages are successfully processed, or an error if any message fails

Source

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>
where P: ProtocolParticipant, T1: Wrap, T2: Wrap, T3: Wrap, T4: Wrap,

Broadcasts four different types of messages to all participants.

§Type Parameters
  • P - The protocol participant type
  • T1 - The type of the first message
  • T2 - The type of the second message
  • T3 - The type of the third message
  • T4 - The type of the fourth message
§Arguments
  • setup - The protocol participant setup
  • msg - Tuple of four messages to broadcast
§Returns

A tuple of four Pairs containing the broadcast messages and their senders

Source

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>
where P: ProtocolParticipant, T1: Wrap, T2: Wrap, T3: Wrap, T4: Wrap,

Receives four different types of broadcast messages from all participants.

§Type Parameters
  • P - The protocol participant type
  • T1 - The type of the first message
  • T2 - The type of the second message
  • T3 - The type of the third message
  • T4 - The type of the fourth message
§Arguments
  • setup - The protocol participant setup
  • sizes - Array of sizes for each message type
§Returns

A tuple of four Pairs containing the received messages and their senders

Auto Trait Implementations§

§

impl<'a, R> Freeze for Round<'a, R>

§

impl<'a, R> RefUnwindSafe for Round<'a, R>
where R: RefUnwindSafe,

§

impl<'a, R> Send for Round<'a, R>
where R: Send,

§

impl<'a, R> Sync for Round<'a, R>
where R: Sync,

§

impl<'a, R> Unpin for Round<'a, R>

§

impl<'a, R> !UnwindSafe for Round<'a, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more