ServerStatus

Struct ServerStatus 

Source
pub struct ServerStatus {
    pub online: bool,
    pub ip: String,
    pub port: u16,
    pub hostname: String,
    pub latency: f64,
    pub dns: Option<DnsInfo>,
    pub data: ServerData,
}
Expand description

Server status information.

This structure contains all information about a Minecraft server’s status. Even if the server is offline, some fields may still be populated (e.g., DNS info).

§Example

use rust_mc_status::{McClient, ServerEdition};

let client = McClient::new();
let status = client.ping("mc.hypixel.net", ServerEdition::Java).await?;

println!("Hostname: {}", status.hostname);
println!("IP: {}", status.ip);
println!("Port: {}", status.port);
println!("Online: {}", status.online);
println!("Latency: {:.2}ms", status.latency);

Fields§

§online: bool

Whether the server is online and responding.

This field is always true for successful pings. If the server is offline or unreachable, the ping() method returns an error instead.

§ip: String

Resolved IP address of the server.

This is the actual IP address that was connected to, which may differ from the hostname if SRV records were used or if the hostname resolves to multiple IP addresses.

Example: "172.65.197.160"

§port: u16

Port number of the server.

This is the actual port that was connected to. For Java servers, this may differ from the default port (25565) if an SRV record was found.

Example: 25565 (Java) or 19132 (Bedrock)

§hostname: String

Original hostname used for the query.

This is the hostname that was provided to the ping() method, before any DNS resolution or SRV lookup.

Example: "mc.hypixel.net"

§latency: f64

Latency in milliseconds.

This is the round-trip time (RTT) from sending the ping request to receiving the response. Lower values indicate better network connectivity.

Example: 45.23 (45.23 milliseconds)

§dns: Option<DnsInfo>

Optional DNS information (A records, CNAME, TTL).

This field contains DNS resolution details if available. It may be None if DNS information could not be retrieved or if an IP address was used directly instead of a hostname.

§data: ServerData

Server data (Java or Bedrock specific information).

This field contains edition-specific server information including version, players, plugins, mods, and more. Use pattern matching to access the data:

match data {
    ServerData::Java(java) => println!("Java server: {}", java.version.name),
    ServerData::Bedrock(bedrock) => println!("Bedrock server: {}", bedrock.version),
}

Implementations§

Source§

impl ServerStatus

Source

pub fn players(&self) -> Option<(i64, i64)>

Get player count information.

Returns a tuple of (online, max) players, or None if not available.

§Example
if let Some((online, max)) = status.players() {
    println!("Players: {}/{}", online, max);
}

Trait Implementations§

Source§

impl Clone for ServerStatus

Source§

fn clone(&self) -> ServerStatus

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ServerStatus

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ServerStatus

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ServerStatus

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,