pub enum Instruction {
SendMessage(Vec<u8>),
SendMessageDependingOnLastReceivedMessage(fn(Option<Vec<u8>>) -> Option<Vec<u8>>),
ReceiveMessage,
ReceiveMessageWithMaxSize(usize),
StopExchange,
}
Expand description
Type of network instruction executed by the server mocker.
Variants§
SendMessage(Vec<u8>)
Send given message to the client
SendMessageDependingOnLastReceivedMessage(fn(Option<Vec<u8>>) -> Option<Vec<u8>>)
Send a message to the client depending on the last received message
If the given function returns None, no message is sent
§Example
SendMessageDependingOnLastReceivedMessage(|last_received_message: Option<Vec<u8>>| {
if let Some(last_received_message) = last_received_message {
if last_received_message == vec![0x01, 0x02, 0x03] {
Some(vec![0x04, 0x05, 0x06])
} else {
None
}
} else {
None
}
});
ReceiveMessage
Wait for a message to be received.
The message could be recovered with ServerMocker::pop_received_message
ReceiveMessageWithMaxSize(usize)
Wait for a message to be received with a maximum size (useful in UDP).
If the message is bigger than the given size, the message is truncated.
The message could be recovered with ServerMocker::pop_received_message
StopExchange
Stop the exchange with the client, close the connection in case of TCP
Trait Implementations§
Source§impl Clone for Instruction
impl Clone for Instruction
Source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Instruction
impl Debug for Instruction
Source§impl PartialEq for Instruction
impl PartialEq for Instruction
impl StructuralPartialEq for Instruction
Auto Trait Implementations§
impl Freeze for Instruction
impl RefUnwindSafe for Instruction
impl Send for Instruction
impl Sync for Instruction
impl Unpin for Instruction
impl UnwindSafe for Instruction
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