pub struct JavaServerStatus(/* private fields */);Expand description
Typed wrapper around a Java Edition ServerStatus.
Implements StatusExt for common fields and serde::Serialize via
#[serde(transparent)] — serialises identically to the inner
ServerStatus.
§Accessing raw fields
Use .raw() to get the underlying ServerStatus directly, or match on
ServerData::Java for the raw JavaStatus.
§Example
use rust_mc_status::{McClient, StatusExt};
let client = McClient::builder().build();
let s = client.java("mc.hypixel.net").await?;
println!("Version : {}", s.version());
println!("Players : {}", s.display_players());
println!("Latency : {:.0} ms", s.latency_ms());
println!("MOTD : {}", s.motd_clean());
println!("Cached : {}", s.is_cached());Implementations§
Source§impl JavaServerStatus
impl JavaServerStatus
Sourcepub fn motd(&self) -> &str
pub fn motd(&self) -> &str
Primary MOTD / description as returned by the server.
May contain §-color codes. Use motd_clean to
strip them. Returns "" when the inner data is not Java (shouldn’t
happen in normal usage).
Sourcepub fn motd_clean(&self) -> String
pub fn motd_clean(&self) -> String
Primary MOTD with all Minecraft §-formatting codes removed and
whitespace normalised.
Equivalent to strip_formatting applied to
motd.
Sourcepub fn players_online(&self) -> i64
pub fn players_online(&self) -> i64
Number of players currently online as reported by the server.
Large networks often report custom inflated numbers here.
Sourcepub fn players_max(&self) -> i64
pub fn players_max(&self) -> i64
Maximum player capacity as reported by the server.
Sourcepub fn favicon(&self) -> Option<&str>
pub fn favicon(&self) -> Option<&str>
Base64-encoded 64×64 PNG favicon, if the server provides one.
The string may include a data:image/png;base64, prefix.
Use save_favicon to decode and write to disk.
Sourcepub fn save_favicon(&self, filename: &str) -> Result<(), McError>
pub fn save_favicon(&self, filename: &str) -> Result<(), McError>
Decode the favicon and write it to filename as a PNG file.
§Errors
- [
McError::Protocol] — no favicon available. - [
McError::Protocol] — base64 decoding failed. - [
McError::Io] — file could not be created or written.
Sourcepub fn is_cached(&self) -> bool
pub fn is_cached(&self) -> bool
true if this result was served from the response cache.
Cached responses have latency_ms() == 0.0 and reflect the server
state at the time of the original ping, not the current moment.
The maximum age is determined by the TTL passed to
McClientBuilder::response_cache.
Sourcepub fn raw(&self) -> &ServerStatus
pub fn raw(&self) -> &ServerStatus
Access the underlying ServerStatus directly.
Use this to access fields not surfaced by the typed accessors, such as
dns, meta, or to match on ServerData for
the full JavaStatus.
Trait Implementations§
Source§impl Debug for JavaServerStatus
impl Debug for JavaServerStatus
Source§impl Display for JavaServerStatus
impl Display for JavaServerStatus
Source§impl Serialize for JavaServerStatus
impl Serialize for JavaServerStatus
Auto Trait Implementations§
impl Freeze for JavaServerStatus
impl RefUnwindSafe for JavaServerStatus
impl Send for JavaServerStatus
impl Sync for JavaServerStatus
impl Unpin for JavaServerStatus
impl UnsafeUnpin for JavaServerStatus
impl UnwindSafe for JavaServerStatus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more