pub trait StatusExt {
// Required methods
fn latency_ms(&self) -> f64;
fn ip(&self) -> &str;
fn hostname(&self) -> &str;
fn port(&self) -> u16;
fn is_online(&self) -> bool;
fn display_players(&self) -> String;
}Expand description
Common interface shared by JavaServerStatus
and BedrockServerStatus.
Provides access to the fields that exist on every successful ping result regardless of edition. Import this trait to call its methods:
use rust_mc_status::{McClient, StatusExt};
let client = McClient::builder().build();
let s = client.java("mc.hypixel.net").await?;
// These methods come from StatusExt:
println!("{} ms", s.latency_ms() as u32);
println!("{}", s.display_players()); // "21000/200000"
println!("{}", s.ip());
println!("{}", s.hostname());Required Methods§
Sourcefn latency_ms(&self) -> f64
fn latency_ms(&self) -> f64
Round-trip latency in milliseconds.
0.0 for responses served from the response cache
(check JavaServerStatus::is_cached).
Sourcefn hostname(&self) -> &str
fn hostname(&self) -> &str
Original hostname as provided to the ping call, e.g. "mc.hypixel.net".
Sourcefn display_players(&self) -> String
fn display_players(&self) -> String
Formatted "online/max" player string, e.g. "21000/200000".
For edition-specific types use
JavaServerStatus::players_online /
players_max directly.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".