pub struct MemoryRelay { /* private fields */ }Expand description
In-memory message relay for local testing
This relay stores all messages in memory and uses channels for notification. It’s useful for:
- Unit and integration testing
- Local development
- Single-process multi-party simulation
Implementations§
Source§impl MemoryRelay
impl MemoryRelay
Sourcepub fn with_timeout(timeout_ms: u64) -> Self
pub fn with_timeout(timeout_ms: u64) -> Self
Create a new in-memory relay with custom timeout
Sourcepub fn broadcast_count(&self, session_id: &SessionId, round: u32) -> usize
pub fn broadcast_count(&self, session_id: &SessionId, round: u32) -> usize
Get the number of broadcast messages for a session/round
Trait Implementations§
Source§impl Clone for MemoryRelay
impl Clone for MemoryRelay
Source§impl Debug for MemoryRelay
impl Debug for MemoryRelay
Source§impl Default for MemoryRelay
impl Default for MemoryRelay
Source§impl Relay for MemoryRelay
impl Relay for MemoryRelay
Source§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>>
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 Read more
Source§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>>
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 Read more
Source§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_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 Read more
Source§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,
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 Read more
Auto Trait Implementations§
impl Freeze for MemoryRelay
impl !RefUnwindSafe for MemoryRelay
impl Send for MemoryRelay
impl Sync for MemoryRelay
impl Unpin for MemoryRelay
impl !UnwindSafe for MemoryRelay
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R> RelayExt for R
impl<R> RelayExt for R
Source§fn broadcast_with_timeout<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
session_id: &'life1 [u8; 32],
round: u32,
message: &'life2 T,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
fn broadcast_with_timeout<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, session_id: &'life1 [u8; 32], round: u32, message: &'life2 T, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
Broadcast with timeout
Source§fn collect_broadcasts_with_timeout<'life0, 'life1, 'async_trait, T>(
&'life0 self,
session_id: &'life1 [u8; 32],
round: u32,
count: usize,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
T: 'async_trait + DeserializeOwned + Send,
R: 'async_trait,
fn collect_broadcasts_with_timeout<'life0, 'life1, 'async_trait, T>(
&'life0 self,
session_id: &'life1 [u8; 32],
round: u32,
count: usize,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
T: 'async_trait + DeserializeOwned + Send,
R: 'async_trait,
Collect broadcasts with timeout