pub struct MockUdpSocket<Link> {
pub only_peer: char,
pub link: Link,
/* private fields */
}
Expand description
A mock socket that can be used to simulate a perfect link.
Fields§
§only_peer: char
Peers identified by a letter
link: Link
Defines whether the link is up. If not up, link will SILENTLY drop all sent packets.
Trait Implementations§
Source§impl<Link: LinkDecider + Sync + Send> AsyncUdpSocket<char> for MockUdpSocket<Link>
impl<Link: LinkDecider + Sync + Send> AsyncUdpSocket<char> for MockUdpSocket<Link>
Source§fn send_to<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
buf: &'life1 [u8],
peer: &'life2 Peer<char>,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn send_to<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
buf: &'life1 [u8],
peer: &'life2 Peer<char>,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
§Panics
Panics if target
is not equal to self.only_peer
. This socket is built to support
exactly two peers communicating with each other, so it will panic if used with more.
Source§fn recv_from<'life0, 'life1, 'async_trait>(
&'life0 mut self,
buf: &'life1 mut [u8],
) -> Pin<Box<dyn Future<Output = Result<(usize, Peer<char>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn recv_from<'life0, 'life1, 'async_trait>(
&'life0 mut self,
buf: &'life1 mut [u8],
) -> Pin<Box<dyn Future<Output = Result<(usize, Peer<char>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
§Panics
Panics if buf
is smaller than the packet size.
Auto Trait Implementations§
impl<Link> Freeze for MockUdpSocket<Link>where
Link: Freeze,
impl<Link> RefUnwindSafe for MockUdpSocket<Link>where
Link: RefUnwindSafe,
impl<Link> Send for MockUdpSocket<Link>where
Link: Send,
impl<Link> Sync for MockUdpSocket<Link>where
Link: Sync,
impl<Link> Unpin for MockUdpSocket<Link>where
Link: Unpin,
impl<Link> UnwindSafe for MockUdpSocket<Link>where
Link: UnwindSafe,
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