rust_mc_status/
lib.rs

1//! # Rust Minecraft Server Status Library
2//!
3//! A high-performance, asynchronous Rust library for querying the status of both
4//! Minecraft Java Edition and Bedrock Edition servers.
5//!
6//! ## Features
7//!
8//! - **Dual Protocol Support**: Ping both Minecraft Java Edition (`25565`) and Bedrock Edition (`19132`) servers
9//! - **Async/Await**: Built on Tokio for non-blocking operations and high concurrency
10//! - **Batch Queries**: Ping multiple servers in parallel with configurable concurrency limits
11//! - **DNS Caching**: Automatically caches DNS lookups and SRV records to reduce latency
12//! - **SRV Record Support**: Automatically resolves SRV records for Java servers (mimics Minecraft client behavior)
13//! - **Structured Data**: Returns richly structured, serializable data (using `serde`)
14//! - **Favicon Handling**: Easily retrieve and save server favicons (Java Edition only)
15//! - **Robust Error Handling**: Comprehensive error types using `thiserror`
16//! - **Extended Information**: Detailed data about plugins, mods, DNS, and more
17//!
18//! ## Quick Start
19//!
20//! ```no_run
21//! use rust_mc_status::{McClient, ServerEdition};
22//! use std::time::Duration;
23//!
24//! #[tokio::main]
25//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
26//!     let client = McClient::new()
27//!         .with_timeout(Duration::from_secs(5))
28//!         .with_max_parallel(10);
29//!
30//!     // Ping a Java server (automatically uses SRV lookup if port not specified)
31//!     let status = client.ping("mc.hypixel.net", ServerEdition::Java).await?;
32//!     println!("Server is online: {}", status.online);
33//!     if let Some((online, max)) = status.players() {
34//!         println!("Players: {}/{}", online, max);
35//!     }
36//!
37//!     Ok(())
38//! }
39//! ```
40//!
41//! ## SRV Record Lookup
42//!
43//! When pinging Java servers without an explicit port, the library automatically performs
44//! an SRV DNS lookup for `_minecraft._tcp.{hostname}`. This mimics the behavior of the
45//! official Minecraft client.
46//!
47//! - If an SRV record is found, the target host and port from the record are used
48//! - If no SRV record exists, the default port (25565) is used
49//! - Explicitly specifying a port (e.g., `"server.com:25565"`) skips SRV lookup
50//! - SRV lookup results are cached for 5 minutes to improve performance
51//!
52//! ## Examples
53//!
54//! See the `examples/` directory for more detailed usage examples.
55//!
56//! - `basic_usage.rs` - Basic server status queries
57//! - `advanced_usage.rs` - Advanced features and batch queries
58//! - `srv_lookup_example.rs` - SRV record lookup demonstration
59//! - `performance_test.rs` - Performance benchmarking and speed tests
60//! - `cache_management.rs` - Cache management and statistics
61
62pub mod client;
63pub mod error;
64pub mod models;
65
66pub use client::McClient;
67pub use error::McError;
68pub use models::*;
69
70// Re-export CacheStats for convenience
71pub use models::CacheStats;