pub struct MemoryTransport { /* private fields */ }Expand description
In-memory transport for testing and simulation.
Implementations§
Source§impl MemoryTransport
impl MemoryTransport
Sourcepub fn new(local_id: PeerId) -> Self
pub fn new(local_id: PeerId) -> Self
Create a new in-memory transport instance for a local peer.
Sourcepub fn connect_to(&self, other: &MemoryTransport)
pub fn connect_to(&self, other: &MemoryTransport)
Connect two memory transports together (for testing).
Trait Implementations§
Source§impl NetworkTransport for MemoryTransport
impl NetworkTransport for MemoryTransport
Source§fn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
peer_id: &'life1 PeerId,
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
peer_id: &'life1 PeerId,
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Connect to a peer.
Source§fn disconnect<'life0, 'life1, 'async_trait>(
&'life0 self,
peer_id: &'life1 PeerId,
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn disconnect<'life0, 'life1, 'async_trait>(
&'life0 self,
peer_id: &'life1 PeerId,
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Disconnect from a peer.
Source§fn send<'life0, 'life1, 'async_trait>(
&'life0 self,
peer_id: &'life1 PeerId,
message: Message,
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send<'life0, 'life1, 'async_trait>(
&'life0 self,
peer_id: &'life1 PeerId,
message: Message,
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send a message to a specific peer.
Source§fn broadcast<'life0, 'async_trait>(
&'life0 self,
message: Message,
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn broadcast<'life0, 'async_trait>(
&'life0 self,
message: Message,
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Broadcast a message to all connected peers.
Auto Trait Implementations§
impl Freeze for MemoryTransport
impl !RefUnwindSafe for MemoryTransport
impl Send for MemoryTransport
impl Sync for MemoryTransport
impl Unpin for MemoryTransport
impl UnsafeUnpin for MemoryTransport
impl !UnwindSafe for MemoryTransport
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