pub enum ServerData {
Java(JavaStatus),
Bedrock(BedrockStatus),
Legacy(LegacyData),
Query(QueryData),
}Expand description
Edition-specific server data, stored inside ServerStatus.
Match on this enum to access edition-specific fields:
use rust_mc_status::{McClient, ServerData};
let client = McClient::builder().build();
let status = client.java("mc.hypixel.net").await?;
match &status.raw().data {
ServerData::Java(j) => println!("Protocol: {}", j.version.protocol),
ServerData::Bedrock(b) => println!("Edition: {}", b.edition),
_ => {}
}§Future variants
Legacy and Query are placeholder variants with stub models.
They will be populated in a future release when those protocols are
implemented. Both are serialised with #[serde(skip)] until then.
Variants§
Java(JavaStatus)
Java Edition — modern handshake (protocol 1.7 / version 47+).
Bedrock(BedrockStatus)
Bedrock Edition — RakNet UDP Unconnected Ping/Pong.
Legacy(LegacyData)
Java Edition — legacy ping (0xFE 0x01, pre-1.7).
Not yet implemented. Skipped in serialisation.
Query(QueryData)
Java Edition — UDP Query API (GameSpy4 protocol).
Not yet implemented. Skipped in serialisation.
Implementations§
Source§impl ServerData
impl ServerData
Sourcepub fn players(&self) -> Option<(i64, i64)>
pub fn players(&self) -> Option<(i64, i64)>
Returns (online_players, max_players) for any implemented variant.
Sourcepub fn is_java(&self) -> bool
pub fn is_java(&self) -> bool
Returns true for any Java Edition variant (Modern, Legacy, Query).
Sourcepub fn is_bedrock(&self) -> bool
pub fn is_bedrock(&self) -> bool
Returns true for the Bedrock Edition variant.
Trait Implementations§
Source§impl Clone for ServerData
impl Clone for ServerData
Source§fn clone(&self) -> ServerData
fn clone(&self) -> ServerData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ServerData
impl Debug for ServerData
Source§impl<'de> Deserialize<'de> for ServerData
impl<'de> Deserialize<'de> for ServerData
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ServerData
impl RefUnwindSafe for ServerData
impl Send for ServerData
impl Sync for ServerData
impl Unpin for ServerData
impl UnsafeUnpin for ServerData
impl UnwindSafe for ServerData
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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