Skip to main content

StatusExt

Trait StatusExt 

Source
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§

Source

fn latency_ms(&self) -> f64

Round-trip latency in milliseconds.

0.0 for responses served from the response cache (check JavaServerStatus::is_cached).

Source

fn ip(&self) -> &str

Resolved IP address of the server, e.g. "172.65.197.160".

Source

fn hostname(&self) -> &str

Original hostname as provided to the ping call, e.g. "mc.hypixel.net".

Source

fn port(&self) -> u16

Port that was connected to, e.g. 25565.

Source

fn is_online(&self) -> bool

true if the server responded successfully within the timeout.

Source

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".

Implementors§