pub struct TestCommunicationBackend {
outgoing_tx: Sender<OutgoingMessage>,
outgoing_rx: Receiver<OutgoingMessage>,
outgoing: Arc<RwLock<Vec<OutgoingMessage>>>,
incoming_tx: Sender<IncomingMessage>,
incoming_rx: Receiver<IncomingMessage>,
resolution: Arc<RwLock<Option<BroadcastResolution>>>,
}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>§resolution: Arc<RwLock<Option<BroadcastResolution>>>Implementations§
Source§impl TestCommunicationBackend
impl TestCommunicationBackend
Sourcepub async fn set_resolution(&self, resolution: BroadcastResolution)
pub async fn set_resolution(&self, resolution: BroadcastResolution)
Make resolve return resolution for every group.
Until this is called, every group resolves to BroadcastResolution::Unsupported,
like the trait’s default.
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§type Receiver = TestCommunicationBackendReceiver
type Receiver = TestCommunicationBackendReceiver
Receiver type returned by
subscribe.Source§async fn send(&self, message: OutgoingMessage) -> Result<(), Self::SendError>
async fn send(&self, message: OutgoingMessage) -> Result<(), Self::SendError>
Send a message to the destination specified in the message. This function may be called
from any thread at any time. Read more
Source§async fn resolve(&self, _group: &BroadcastGroup) -> BroadcastResolution
async fn resolve(&self, _group: &BroadcastGroup) -> BroadcastResolution
Resolve a
BroadcastGroup into the endpoints that are currently its members. Called by
IpcClient::broadcast, which rejects any resolved endpoint
that falls outside the group. Read moreSource§impl Debug for TestCommunicationBackend
impl Debug for TestCommunicationBackend
Auto Trait Implementations§
impl !RefUnwindSafe for TestCommunicationBackend
impl !UnwindSafe for TestCommunicationBackend
impl Freeze for TestCommunicationBackend
impl Send for TestCommunicationBackend
impl Sync for TestCommunicationBackend
impl Unpin for TestCommunicationBackend
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
Create a new handle for an Arc value Read more
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
Clone a handle Read more
§unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
Consume a handle, getting back the initial
Arc<> Read more