pub struct MockServerBuilder { /* private fields */ }Expand description
Builder for creating and configuring mock servers
Implementations§
Source§impl MockServerBuilder
impl MockServerBuilder
Sourcepub const fn auto_port(self) -> Self
pub const fn auto_port(self) -> Self
Automatically discover an available port
By default, uses port 0 which lets the OS assign any available ephemeral port. This is atomic and avoids race conditions in parallel tests.
Use port_range() if you need ports within a specific range.
Sourcepub const fn port_range(self, start: u16, end: u16) -> Self
pub const fn port_range(self, start: u16, end: u16) -> Self
Set the port range for automatic port discovery
When set, auto_port() will scan this range for an available port
instead of using OS-assigned ports.
Note: Scanning a range has a small TOCTOU race condition. For parallel
tests, prefer using auto_port() without a range.
Sourcepub fn config_file(self, path: impl Into<PathBuf>) -> Self
pub fn config_file(self, path: impl Into<PathBuf>) -> Self
Load configuration from a YAML file
Sourcepub fn openapi_spec(self, path: impl Into<PathBuf>) -> Self
pub fn openapi_spec(self, path: impl Into<PathBuf>) -> Self
Load routes from an OpenAPI specification
Sourcepub fn latency(self, profile: LatencyProfile) -> Self
pub fn latency(self, profile: LatencyProfile) -> Self
Set the latency profile for simulating network delays
Sourcepub fn failures(self, config: FailureConfig) -> Self
pub fn failures(self, config: FailureConfig) -> Self
Enable failure injection with configuration
Sourcepub fn proxy(self, config: ProxyConfig) -> Self
pub fn proxy(self, config: ProxyConfig) -> Self
Enable proxy mode with configuration
Sourcepub const fn admin_port(self, port: u16) -> Self
pub const fn admin_port(self, port: u16) -> Self
Set admin API port
Sourcepub async fn start(self) -> Result<MockServer>
pub async fn start(self) -> Result<MockServer>
Start the mock server