Documentation: https://docs.rs/rust-mc-status
Source Code: https://github.com/NameOfShadow/rust-mc-status
๐ v3.0.0 โ Released 2026-07-01
A major rewrite focused on ergonomics, performance, and extensibility. Breaking changes from 2.x โ see the Migration Guide.
Headline changes:
- Builder API โ
McClient::builder().timeout(...).response_cache(...).build()replaces ad-hocwith_*chaining. - Per-request fluent pings โ
client.java("addr").timeout(3s).await?with optional.is_online(). - Response cache with in-flight deduplication โ repeated pings to the same server collapse into one network request; cache hits return in ~0 ms.
- Two-level error hierarchy โ
McError::Network(NetworkError::Timeout)etc. for fine-grained matching and retry policy. - Proxy support (feature = "proxy") โ SOCKS5 (with optional UDP for Bedrock) and HTTP CONNECT, with auth.
- Tower integration (feature = "tower") โ
McService+McRetryPolicyplug into the Tower middleware ecosystem. - Layer-based source tree โ
client/,core/,models/,protocol/,proxy/,status/for cleaner navigation. - Zero-cost defaults โ without optional features, no extra tower / pin-project / tokio-socks dependencies are pulled in.
- 149 tests across 8 integration test files โ DNS parsing, Bedrock/Java decoders, error hierarchy, response cache, proxy config, MOTD formatting.
Full release notes and the migration guide are in CHANGELOG.md.
Features
- Dual Protocol Support โ ping both Java Edition (port
25565) and Bedrock Edition (port19132) - Ergonomic Builder API โ
client.java("addr").timeout(3s).await?with per-request timeout override - Typed Status Wrappers โ
JavaServerStatusandBedrockServerStatuswith edition-specific methods - Facade Functions โ
ping_java("addr").await?without creating a client - Tower Middleware (optional feature) โ rate limiting, retries, buffering, tracing via the Tower ecosystem
- Async/Await โ built on Tokio for non-blocking, high-concurrency operation
- Batch Queries โ ping multiple servers in parallel with configurable concurrency
- LRU DNS Cache โ DNS and SRV lookups cached with automatic eviction (default 1024 entries)
- SRV Record Support โ automatic SRV lookup for Java servers, mimicking the official client
- JSON Serialisation โ all status types implement
serde::Serialize; favicon and raw data excluded automatically - MOTD Formatting โ
motd_clean()strips Minecraftยง-color codes;truncate_str()safely slices Unicode - Zero-Panic Design โ all server-supplied data validated before use; no silent index panics
- SmallVec Optimisation โ player sample, plugins, and mods use stack allocation for small lists
- Zero-cost without Tower โ the default build pulls in no tower, async-trait, or pin-project dependency
Installation
[]
= "3.0.0"
= { = "*", = ["full"] }
To enable Tower middleware (rate limiting, retries, buffering, tracing):
= { = "3.0.0", = ["tower"] }
Quick Start
One-liner (no client needed)
use ;
async
Client with custom settings
use ;
use Duration;
async
Batch queries
use ;
async
JSON serialisation
let status = client.java.await?;
let json = to_string?; // compact
let json = to_string_pretty?; // pretty-printed
// favicon and raw_data are excluded automatically
Runtime edition selection
let edition: ServerEdition = "java".parse?;
// Full status
let status = client.server.await?;
// Lightweight reachability check only
let online = client.server
.timeout
.is_online
.await;
Custom address types
;
let status = client.java.await?;
Tower Middleware
Enable with features = ["tower"]. Converts McClient into a standard tower::Service that works with the entire Tower ecosystem โ rate limiting, retries, buffering, tower-http tracing, and any custom tower::Layer.
use ;
use ;
use Duration;
async
Custom Tower Layer
Implement tower::Layer for logging, metrics, or any middleware:
use Future;
use Pin;
use ;
use ;
use ;
;
// Usage
let mut svc = new
.layer
.service;
SRV Record Lookup
When pinging a Java server without an explicit port, the library queries _minecraft._tcp.{hostname} for SRV records โ exactly as the official Minecraft client does. Results are cached for 5 minutes.
// SRV lookup performed automatically
let status = client.java.await?;
// Explicit port โ SRV lookup skipped
let status = client.java.await?;
MOTD Formatting
use strip_formatting;
let raw = "ยงaHypixel ยงc[1.8/1.21]";
println!; // "Hypixel [1.8/1.21]"
// Or via the wrapper method
let status = client.java.await?;
println!; // same result
Examples
| Example | Description |
|---|---|
basic_usage |
Core API: facade, typed status, per-request timeout, serialisation |
advanced_usage |
Batch queries, plugins, mods, favicon saving |
cache_management |
LRU cache stats, warm/cold timing, clear_caches() |
tower_usage |
Tower middleware: rate limiting, retries, buffer, custom Layer |
srv_lookup_example |
SRV record behaviour |
performance_test |
Benchmarking (run with --release) |
API Reference
McClient builder methods
| Method | Description |
|---|---|
new() |
Default settings (10 s timeout, 10 parallel, 1024 cache) |
with_timeout(Duration) |
Global request timeout |
with_max_parallel(usize) |
Max concurrent pings in ping_many |
with_cache_size(usize) |
LRU cache capacity for DNS and SRV |
into_service() (tower) |
Convert to McService for Tower middleware |
Ping methods
| Method | Returns | Notes |
|---|---|---|
client.java(addr) |
JavaPingBuilder |
Supports .timeout(d).await |
client.bedrock(addr) |
BedrockPingBuilder |
Supports .timeout(d).await |
client.server(addr, edition) |
ServerPingBuilder |
Runtime edition; .is_online().await |
client.ping_many(&[ServerInfo]) |
Vec<(ServerInfo, Result<ServerStatus>)> |
Parallel batch |
ping_java(addr) |
Result<JavaServerStatus> |
Global client, no setup needed |
ping_bedrock(addr) |
Result<BedrockServerStatus> |
Global client, no setup needed |
Tower types (feature = "tower")
| Type | Description |
|---|---|
McService |
tower::Service<PingRequestTower> โ wraps McClient |
McRetryPolicy |
Retries on Timeout / ConnectionError; configurable attempt count |
PingRequestTower |
Request type with .java(addr) / .bedrock(addr) constructors |
PingResponseTower |
Response containing status: ServerStatus |
JavaServerStatus methods
motd(), motd_clean(), version(), players_online(), players_max(), display_players(), favicon(), save_favicon(path), ip(), port(), hostname(), latency_ms(), is_online(), raw()
BedrockServerStatus methods
motd(), motd_clean(), motd2(), motd2_clean(), edition(), version(), players_online(), players_max(), display_players(), game_mode(), ip(), port(), hostname(), latency_ms(), is_online(), raw()
Utility functions
| Function | Description |
|---|---|
strip_formatting(s) |
Remove Minecraft ยงX codes, collapse whitespace |
truncate_str(s, n) |
Truncate to n Unicode characters (panic-safe) |
Cache methods (all async)
cache_stats().await, clear_caches().await
Error Handling
use McError;
match client.java.await
Performance Notes
- DNS and SRV results cached for 5 minutes with LRU eviction โ no memory leaks
tokio::sync::RwLockallows concurrent readers with minimal contentionSmallVecfor player sample (โค 12), plugins (โค 8), and mods (โค 8) โ stack-allocated for common case- Per-request
.timeout()reduces tail latency in batch scenarios without touching the client ping_bedrockuses UDP;ping_javauses TCP withTCP_NODELAY- Default build has zero tower/async-trait dependency โ only pulled in with
features = ["tower"]
License
MIT โ see LICENSE.
Changelog
See CHANGELOG.md.
Version
Current version: 3.0.0 (released 2026-07-01) โ see CHANGELOG.md for full history and migration guide.