pub struct TestCommunicationBackend {
outgoing_tx: Sender<OutgoingMessage>,
outgoing_rx: Receiver<OutgoingMessage>,
outgoing: Arc<RwLock<Vec<OutgoingMessage>>>,
incoming_tx: Sender<IncomingMessage>,
incoming_rx: Receiver<IncomingMessage>,
}Expand description
A test implementation of the CommunicationBackend trait. Provides methods to inject
incoming messages and inspect outgoing messages.
Fields§
§outgoing_tx: Sender<OutgoingMessage>§outgoing_rx: Receiver<OutgoingMessage>§outgoing: Arc<RwLock<Vec<OutgoingMessage>>>§incoming_tx: Sender<IncomingMessage>§incoming_rx: Receiver<IncomingMessage>Implementations§
Source§impl TestCommunicationBackend
impl TestCommunicationBackend
Sourcepub fn push_incoming(&self, message: IncomingMessage)
pub fn push_incoming(&self, message: IncomingMessage)
Inject a message as if it were received from a remote endpoint.
Sourcepub async fn outgoing(&self) -> Vec<OutgoingMessage>
pub async fn outgoing(&self) -> Vec<OutgoingMessage>
Get a copy of all the outgoing messages that have been sent.
Sourcepub async fn drain_outgoing(&self) -> Vec<OutgoingMessage>
pub async fn drain_outgoing(&self) -> Vec<OutgoingMessage>
Drain all outgoing messages, returning them and clearing the internal buffer.
Trait Implementations§
Source§impl Clone for TestCommunicationBackend
impl Clone for TestCommunicationBackend
Source§impl CommunicationBackend for TestCommunicationBackend
impl CommunicationBackend for TestCommunicationBackend
Source§impl Debug for TestCommunicationBackend
impl Debug for TestCommunicationBackend
Auto Trait Implementations§
impl Freeze for TestCommunicationBackend
impl !RefUnwindSafe for TestCommunicationBackend
impl Send for TestCommunicationBackend
impl Sync for TestCommunicationBackend
impl Unpin for TestCommunicationBackend
impl UnsafeUnpin for TestCommunicationBackend
impl !UnwindSafe for TestCommunicationBackend
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