pub struct ServerListLegacyPingResponse { /* private fields */ }
Expand description
Response data of the legacy server list ping.
§Example
let mut response =
ServerListLegacyPingResponse::new(127, 0, 10).version("Valence 1.20.1".to_owned());
// This will make the description just repeat "hello" until the length limit
// (which depends on the other fields that we set above: protocol, version,
// online players, max players).
let max_description = response.max_description();
response = response.description(
std::iter::repeat("hello ")
.flat_map(|s| s.chars())
.take(max_description)
.collect(),
);
Implementations§
source§impl ServerListLegacyPingResponse
impl ServerListLegacyPingResponse
sourcepub fn new(protocol: i32, online_players: i32, max_players: i32) -> Self
pub fn new(protocol: i32, online_players: i32, max_players: i32) -> Self
Constructs a new basic ServerListLegacyPingResponse
.
See description
and version
.
sourcepub fn description(self, description: String) -> Self
pub fn description(self, description: String) -> Self
Sets the description of the server.
If the resulting response packet is too long to be valid, the description will be truncated.
Use max_description
method to get the max
valid length for this specific packet with the already set fields
(version, protocol, online players, max players).
Also any null bytes will be removed.
sourcepub fn version(self, version: String) -> Self
pub fn version(self, version: String) -> Self
Sets the version of the server.
If the resulting response packet is too long to be valid, the version will be truncated.
Use max_version
method to get the max valid
length for this specific packet with the already set fields
(description, protocol, online players, max players).
Also any null bytes will be removed.
sourcepub fn max_description(&self) -> usize
pub fn max_description(&self) -> usize
Returns the maximum number of characters (not bytes) that this packet’s description can have with all other fields set as they are.
sourcepub fn max_version(&self) -> usize
pub fn max_version(&self) -> usize
Returns the maximum number of characters (not bytes) that this packet’s version can have with all other fields set as they are.
Trait Implementations§
source§impl Clone for ServerListLegacyPingResponse
impl Clone for ServerListLegacyPingResponse
source§fn clone(&self) -> ServerListLegacyPingResponse
fn clone(&self) -> ServerListLegacyPingResponse
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ServerListLegacyPingResponse
impl Debug for ServerListLegacyPingResponse
source§impl Default for ServerListLegacyPingResponse
impl Default for ServerListLegacyPingResponse
source§fn default() -> ServerListLegacyPingResponse
fn default() -> ServerListLegacyPingResponse
source§impl PartialEq for ServerListLegacyPingResponse
impl PartialEq for ServerListLegacyPingResponse
source§fn eq(&self, other: &ServerListLegacyPingResponse) -> bool
fn eq(&self, other: &ServerListLegacyPingResponse) -> bool
self
and other
values to be equal, and is used by ==
.impl StructuralPartialEq for ServerListLegacyPingResponse
Auto Trait Implementations§
impl Freeze for ServerListLegacyPingResponse
impl RefUnwindSafe for ServerListLegacyPingResponse
impl Send for ServerListLegacyPingResponse
impl Sync for ServerListLegacyPingResponse
impl Unpin for ServerListLegacyPingResponse
impl UnwindSafe for ServerListLegacyPingResponse
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given [World
].