pub struct ServerMockerInstructionsList { /* private fields */ }
Expand description
Represents a list of network instructions to be executed by the server mocker
The list is executed in order, one instruction at a time.
The list is executed in a loop, until the StopExchange instruction is received.
Implementations
sourceimpl ServerMockerInstructionsList
impl ServerMockerInstructionsList
Creates a new ServerMockerInstructionsList with the given instructions
Example
use socket_server_mocker::server_mocker_instruction::{ServerMockerInstruction, ServerMockerInstructionsList};
let mut instructions_list = ServerMockerInstructionsList::new_with_instructions([
ServerMockerInstruction::ReceiveMessage,
ServerMockerInstruction::SendMessage("hello from server".as_bytes().to_vec()),
].as_slice()).with_added_receive_message();
instructions_list.add_stop_exchange();
sourcepub fn new() -> ServerMockerInstructionsList
pub fn new() -> ServerMockerInstructionsList
Creates a new ServerMockerInstructionsList without instruction
sourcepub fn new_with_instructions(
instructions: &[ServerMockerInstruction]
) -> ServerMockerInstructionsList
pub fn new_with_instructions(
instructions: &[ServerMockerInstruction]
) -> ServerMockerInstructionsList
Creates a new ServerMockerInstructionsList with the given instructions
Takes a slice of ServerMockerInstruction and clone it into the new ServerMockerInstructionsList
sourcepub fn add_send_message(&mut self, message: BinaryMessage)
pub fn add_send_message(&mut self, message: BinaryMessage)
Add instruction for sending a message to the client
Takes self as a mutable reference
Message is given as a BinaryMessage
sourcepub fn with_added_send_message(self, message: BinaryMessage) -> Self
pub fn with_added_send_message(self, message: BinaryMessage) -> Self
Add instruction for sending a message to the client
Takes ownership of self and returns a new ServerMockerInstructionsList
Message is given as a BinaryMessage
sourcepub fn add_receive_message(&mut self)
pub fn add_receive_message(&mut self)
Add instruction for waiting for a message to be received from the client
Takes self as a mutable reference
The message could be recovered with TcpServerMocker::pop_received_message()
sourcepub fn with_added_receive_message(self) -> Self
pub fn with_added_receive_message(self) -> Self
Add instruction for waiting for a message to be received from the client
Takes ownership of self and returns a new ServerMockerInstructionsList
The message could be recovered with TcpServerMocker::pop_received_message()
sourcepub fn add_stop_exchange(&mut self)
pub fn add_stop_exchange(&mut self)
Add instruction for stopping the exchange with the client, closing the connection.
Once the connection is closed, the client will receive an error when trying to send a message.
Takes self as a mutable reference
sourcepub fn with_added_stop_exchange(self) -> Self
pub fn with_added_stop_exchange(self) -> Self
Add instruction for stopping the exchange with the client, closing the connection.
Once the connection is closed, the client will receive an error when trying to send a message.
Takes ownership of self and returns a new ServerMockerInstructionsList
Trait Implementations
sourceimpl Clone for ServerMockerInstructionsList
impl Clone for ServerMockerInstructionsList
sourcefn clone(&self) -> ServerMockerInstructionsList
fn clone(&self) -> ServerMockerInstructionsList
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more