crates.io
crates.io 
The mockserver-client crate provides an idiomatic Rust client for MockServer's control-plane REST API. It uses a blocking reqwest client (no async runtime required) and includes an on-demand binary launcher that starts MockServer without Java or Docker.
Install
Add to Cargo.toml. For a test-only dependency, use [dev-dependencies]:
[dev-dependencies]
mockserver-client = "7.0"
For use in non-test code, use [dependencies]:
[dependencies]
mockserver-client = "7.0"
Quick start
use mockserver_client::{ClientBuilder, HttpRequest, HttpResponse, VerificationTimes};
fn main() -> mockserver_client::Result<()> {
let client = ClientBuilder::new("localhost", 1080).build()?;
// Create an expectation
client.when(HttpRequest::new().method("GET").path("/hello"))
.respond(HttpResponse::new().status_code(200).body("world"))?;
// Verify the request was received
client.verify(
HttpRequest::new().path("/hello"),
VerificationTimes::at_least(1),
)?;
// Reset
client.reset()?;
Ok(())
}
Launch MockServer from Rust
The crate includes a binary launcher — no Java installation or Docker required:
use mockserver_client::launcher;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut handle = launcher::start(1080)?;
println!("MockServer running on port {}", handle.port());
// ... use MockServer ...
handle.stop()?;
Ok(())
}
See Running MockServer — client library launcher for full launcher options (version pinning, cache directory, air-gapped networks).
For the full Rust client API, see MockServer clients.