Trait MessagesStore

Source
pub trait MessagesStore: Sized + 'static {
    type Msg;
    type Output;
    type Error: Error;

    // Required methods
    fn add_message(
        &mut self,
        msg: Incoming<Self::Msg>,
    ) -> Result<(), Self::Error>;
    fn wants_more(&self) -> bool;
    fn output(self) -> Result<Self::Output, Self>;
}
Expand description

Stores messages received at particular round

In MPC protocol, party at every round usually needs to receive up to n messages. MessagesStore is a container that stores messages, it knows how many messages are expected to be received, and should implement extra measures against malicious parties (e.g. prohibit message overwrite).

§Procedure

MessagesStore stores received messages. Once enough messages are received, it outputs MessagesStore::Output. In order to save received messages, .add_message(msg) is called. Then, .wants_more() tells whether more messages are needed to be received. If it returned false, then output can be retrieved by calling .output().

§Example

RoundInput is an simple messages store. Refer to its docs to see usage examples.

Required Associated Types§

Source

type Msg

Message type

Source

type Output

Store output (e.g. Vec<_> of received messages)

Source

type Error: Error

Store error

Required Methods§

Source

fn add_message(&mut self, msg: Incoming<Self::Msg>) -> Result<(), Self::Error>

Adds received message to the store

Returns error if message cannot be processed. Usually it means that sender behaves maliciously.

Source

fn wants_more(&self) -> bool

Indicates if store expects more messages to receive

Source

fn output(self) -> Result<Self::Output, Self>

Retrieves store output if enough messages are received

Returns Err(self) if more message are needed to be received.

If store indicated that it needs no more messages (ie store.wants_more() == false), then this function must return Ok(_).

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.

Implementors§