pub struct MemoryChannel {
pub sender: Sender<Vec<CanonicalMessage>>,
pub receiver: Receiver<Vec<CanonicalMessage>>,
}Expand description
A shareable, thread-safe, in-memory channel for testing.
This struct holds the sender and receiver for an in-memory queue. It can be cloned and shared between your test code and the bridge’s endpoints. It transports batches of messages.
Fields§
§sender: Sender<Vec<CanonicalMessage>>§receiver: Receiver<Vec<CanonicalMessage>>Implementations§
Source§impl MemoryChannel
impl MemoryChannel
Sourcepub async fn send_message(&self, message: CanonicalMessage) -> Result<()>
pub async fn send_message(&self, message: CanonicalMessage) -> Result<()>
Helper function for tests to easily send a message to the channel.
Sourcepub async fn fill_messages(&self, messages: Vec<CanonicalMessage>) -> Result<()>
pub async fn fill_messages(&self, messages: Vec<CanonicalMessage>) -> Result<()>
Helper function for tests to easily fill in messages.
Sourcepub fn drain_messages(&self) -> Vec<CanonicalMessage>
pub fn drain_messages(&self) -> Vec<CanonicalMessage>
Helper function for tests to drain all messages from the channel.
Trait Implementations§
Source§impl Clone for MemoryChannel
impl Clone for MemoryChannel
Source§fn clone(&self) -> MemoryChannel
fn clone(&self) -> MemoryChannel
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MemoryChannel
impl RefUnwindSafe for MemoryChannel
impl Send for MemoryChannel
impl Sync for MemoryChannel
impl !Unpin for MemoryChannel
impl UnwindSafe for MemoryChannel
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