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

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();

Creates a new ServerMockerInstructionsList without instruction

Creates a new ServerMockerInstructionsList with the given instructions

Takes a slice of ServerMockerInstruction and clone it into the new ServerMockerInstructionsList

Add instruction for sending a message to the client

Takes self as a mutable reference

Message is given as a BinaryMessage

Add instruction for sending a message to the client

Takes ownership of self and returns a new ServerMockerInstructionsList

Message is given as a BinaryMessage

Add instruction for sending a message to the client depending on the last received message

Takes self as a mutable reference

If the given function returns None, no message is sent

Add instruction for sending a message to the client depending on the last received message

Takes ownership of self and returns a new ServerMockerInstructionsList

If the given function returns None, no message is sent

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()

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()

Add instruction for waiting for a message to be received from the client with a maximum size

Takes self as a mutable reference

If the message is bigger than the given size, the message is truncated.

Add instruction for waiting for a message to be received from the client with a maximum size

Takes ownership of self and returns a new ServerMockerInstructionsList

If the message is bigger than the given size, the message is truncated.

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

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.