pub struct ServerQueryResponse {
pub len: VarInt,
pub packet_id: VarInt,
pub json_len: VarInt,
pub json: String,
}Expand description
Represents the server’s response to a status query.
Contains the raw JSON string with server information.
Fields§
§len: VarIntLength of the entire response packet.
packet_id: VarIntPacket ID (should be 0x00).
json_len: VarIntLength of the JSON string.
json: StringJSON string with server status information.
Implementations§
Source§impl ServerQueryResponse
impl ServerQueryResponse
Sourcepub async fn from(bytes: &[u8]) -> ServerQueryResponse
pub async fn from(bytes: &[u8]) -> ServerQueryResponse
Parses a ServerQueryResponse from raw bytes.
Reads VarInts for lengths and packet IDs, then extracts the JSON string.
§Panics
If the byte slice is too short or malformed, this may panic.
Sourcepub fn parse_status(&self) -> Result<ServerStatus>
pub fn parse_status(&self) -> Result<ServerStatus>
Parses the JSON string into a strongly-typed ServerStatus struct.
Returns an error if JSON deserialization fails.
§Example
let response = ServerQueryResponse::from(&bytes);
let status = response.parse_status()?;Trait Implementations§
Auto Trait Implementations§
impl Freeze for ServerQueryResponse
impl RefUnwindSafe for ServerQueryResponse
impl Send for ServerQueryResponse
impl Sync for ServerQueryResponse
impl Unpin for ServerQueryResponse
impl UnsafeUnpin for ServerQueryResponse
impl UnwindSafe for ServerQueryResponse
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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