pub enum ServerMockerInstruction {
SendMessage(BinaryMessage),
SendMessageDependingOnLastReceivedMessage(fn(_: Option<BinaryMessage>) -> Option<BinaryMessage>),
ReceiveMessage,
ReceiveMessageWithMaxSize(usize),
StopExchange,
}
Expand description
Type of network instruction executed by the server mocker.
Variants
SendMessage(BinaryMessage)
Send given message to the client
SendMessageDependingOnLastReceivedMessage(fn(_: Option<BinaryMessage>) -> Option<BinaryMessage>)
Send a message to the client depending on the last received message
If the given function returns None, no message is sent
Example
use socket_server_mocker::server_mocker_instruction::{BinaryMessage, ServerMockerInstruction};
use socket_server_mocker::server_mocker_instruction::ServerMockerInstruction::SendMessageDependingOnLastReceivedMessage;
SendMessageDependingOnLastReceivedMessage(|last_received_message: Option<BinaryMessage>| {
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
sourceimpl Clone for ServerMockerInstruction
impl Clone for ServerMockerInstruction
sourcefn clone(&self) -> ServerMockerInstruction
fn clone(&self) -> ServerMockerInstruction
Returns a copy of the value. Read more
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for ServerMockerInstruction
impl Debug for ServerMockerInstruction
sourceimpl PartialEq<ServerMockerInstruction> for ServerMockerInstruction
impl PartialEq<ServerMockerInstruction> for ServerMockerInstruction
sourcefn eq(&self, other: &ServerMockerInstruction) -> bool
fn eq(&self, other: &ServerMockerInstruction) -> bool
impl StructuralPartialEq for ServerMockerInstruction
Auto Trait Implementations
impl RefUnwindSafe for ServerMockerInstruction
impl Send for ServerMockerInstruction
impl Sync for ServerMockerInstruction
impl Unpin for ServerMockerInstruction
impl UnwindSafe for ServerMockerInstruction
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more