pub struct InMemoryTransport { /* private fields */ }Expand description
In-memory transport for testing.
Messages are delivered in FIFO order per sender-receiver pair.
Implementations§
Source§impl InMemoryTransport
impl InMemoryTransport
Create a new transport with shared queues.
Multiple transports sharing queues can communicate with each other.
Sourcepub fn all_messages(&self) -> Vec<ProtocolEnvelope>
pub fn all_messages(&self) -> Vec<ProtocolEnvelope>
Get all messages in transit (for debugging).
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Get the number of pending messages.
Trait Implementations§
Source§impl AsyncSimulatedTransport for InMemoryTransport
impl AsyncSimulatedTransport for InMemoryTransport
Source§fn send<'life0, 'life1, 'async_trait>(
&'life0 mut self,
to: &'life1 RoleName,
envelope: ProtocolEnvelope,
) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send<'life0, 'life1, 'async_trait>(
&'life0 mut self,
to: &'life1 RoleName,
envelope: ProtocolEnvelope,
) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send a message to a destination.
Source§fn recv<'life0, 'life1, 'async_trait>(
&'life0 mut self,
from: &'life1 RoleName,
) -> Pin<Box<dyn Future<Output = TransportResult<ProtocolEnvelope>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn recv<'life0, 'life1, 'async_trait>(
&'life0 mut self,
from: &'life1 RoleName,
) -> Pin<Box<dyn Future<Output = TransportResult<ProtocolEnvelope>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Receive a message from a source, waiting if necessary.
Source§fn try_recv(
&mut self,
from: &RoleName,
) -> TransportResult<Option<ProtocolEnvelope>>
fn try_recv( &mut self, from: &RoleName, ) -> TransportResult<Option<ProtocolEnvelope>>
Try to receive a message without blocking.
Source§fn has_message(&self, from: &RoleName) -> bool
fn has_message(&self, from: &RoleName) -> bool
Check if a message is available from a source.
Source§impl Clone for InMemoryTransport
impl Clone for InMemoryTransport
Source§impl Debug for InMemoryTransport
impl Debug for InMemoryTransport
Source§impl Default for InMemoryTransport
impl Default for InMemoryTransport
Source§fn default() -> InMemoryTransport
fn default() -> InMemoryTransport
Returns the “default value” for a type. Read more
Source§impl SimulatedTransport for InMemoryTransport
impl SimulatedTransport for InMemoryTransport
Source§fn send(
&mut self,
to: &RoleName,
envelope: ProtocolEnvelope,
) -> TransportResult<()>
fn send( &mut self, to: &RoleName, envelope: ProtocolEnvelope, ) -> TransportResult<()>
Send a message to a destination.
Source§fn recv(&mut self, from: &RoleName) -> TransportResult<ProtocolEnvelope>
fn recv(&mut self, from: &RoleName) -> TransportResult<ProtocolEnvelope>
Receive a message from a source. Read more
Source§fn peek(&self, from: &RoleName) -> bool
fn peek(&self, from: &RoleName) -> bool
Check if a message is available from a source without consuming it.
Source§fn pending_messages(&self) -> Vec<&ProtocolEnvelope>
fn pending_messages(&self) -> Vec<&ProtocolEnvelope>
Get all pending messages (for debugging/inspection).
Auto Trait Implementations§
impl Freeze for InMemoryTransport
impl !RefUnwindSafe for InMemoryTransport
impl Send for InMemoryTransport
impl Sync for InMemoryTransport
impl Unpin for InMemoryTransport
impl UnsafeUnpin for InMemoryTransport
impl !UnwindSafe for InMemoryTransport
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
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<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> StrictAs for T
impl<T> StrictAs for T
Source§fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
Casts the value.
Source§impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
Source§fn strict_cast_from(src: Src) -> Dst
fn strict_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.