Network Delay
This section describes functions designed to simulate network issues, such as latency (delay).
delay
Sets a delay for the mock server response.
This method configures the server to wait for a specified duration before sending a response, which can be useful for testing timeout scenarios or asynchronous operations.
Parameters
duration
: The length of the delay as astd::time::Duration
.
Returns
Returns self
to allow chaining of method calls on the Mock
object.
Panics
Panics if the specified duration results in a delay that cannot be represented as a 64-bit unsigned integer of milliseconds (more than approximately 584 million years).
Example
Demonstrates setting a 3-second delay for a request to the path /delay
.