Struct uuid_mc::OnlineUuid
source · pub struct OnlineUuid(_);
Expand description
A struct that represents a UUID with an online format (UUID v4).
Implementations§
source§impl OnlineUuid
impl OnlineUuid
sourcepub fn get_username(&self) -> Result<String, Error>
pub fn get_username(&self) -> Result<String, Error>
Uses the Mojang API to fetch the username belonging to this UUID.
Errors
If there is no user that corresponds to the provided UUID, an Error::InvalidUuid
is returned.
Otherwise, an Error::Transport
can be returned in case of network failure.
Examples
To fetch the user belonging to an arbitrary UUID, you can do:
use uuid::Uuid;
use uuid_mc::{PlayerUuid, OnlineUuid};
let uuid = Uuid::try_parse("069a79f4-44e9-4726-a5be-fca90e38aaf5")?;
let player_uuid = PlayerUuid::new_with_uuid(uuid)?;
let name = player_uuid.unwrap_online().get_username()?;
assert_eq!(name, "Notch");
Trait Implementations§
source§impl Clone for OnlineUuid
impl Clone for OnlineUuid
source§fn clone(&self) -> OnlineUuid
fn clone(&self) -> OnlineUuid
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for OnlineUuid
impl Debug for OnlineUuid
source§impl<'de> Deserialize<'de> for OnlineUuid
impl<'de> Deserialize<'de> for OnlineUuid
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<OnlineUuid> for Uuid
impl From<OnlineUuid> for Uuid
source§fn from(other: OnlineUuid) -> Self
fn from(other: OnlineUuid) -> Self
Converts to this type from the input type.
source§impl Hash for OnlineUuid
impl Hash for OnlineUuid
source§impl Ord for OnlineUuid
impl Ord for OnlineUuid
source§fn cmp(&self, other: &OnlineUuid) -> Ordering
fn cmp(&self, other: &OnlineUuid) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<OnlineUuid> for OnlineUuid
impl PartialEq<OnlineUuid> for OnlineUuid
source§fn eq(&self, other: &OnlineUuid) -> bool
fn eq(&self, other: &OnlineUuid) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<OnlineUuid> for OnlineUuid
impl PartialOrd<OnlineUuid> for OnlineUuid
source§fn partial_cmp(&self, other: &OnlineUuid) -> Option<Ordering>
fn partial_cmp(&self, other: &OnlineUuid) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more