pub struct EntityUuid(/* private fields */);
Expand description
The Minecraft UUID of the entity. For players, this is their actual player UUID, and for other entities it’s just random.
Implementations§
Methods from Deref<Target = Uuid>§
Sourcepub fn as_hyphenated(&self) -> &Hyphenated
pub fn as_hyphenated(&self) -> &Hyphenated
Get a borrowed Hyphenated
formatter.
pub const NAMESPACE_DNS: Uuid = _
pub const NAMESPACE_OID: Uuid = _
pub const NAMESPACE_URL: Uuid = _
pub const NAMESPACE_X500: Uuid = _
Sourcepub fn get_variant(&self) -> Variant
pub fn get_variant(&self) -> Variant
Returns the variant of the UUID structure.
This determines the interpretation of the structure of the UUID. This method simply reads the value of the variant byte. It doesn’t validate the rest of the UUID as conforming to that variant.
§Examples
Basic usage:
let my_uuid = Uuid::parse_str("02f09a3f-1624-3b1d-8409-44eff7708208")?;
assert_eq!(Variant::RFC4122, my_uuid.get_variant());
§References
Sourcepub fn get_version_num(&self) -> usize
pub fn get_version_num(&self) -> usize
Returns the version number of the UUID.
This represents the algorithm used to generate the value.
This method is the future-proof alternative to Uuid::get_version
.
§Examples
Basic usage:
let my_uuid = Uuid::parse_str("02f09a3f-1624-3b1d-8409-44eff7708208")?;
assert_eq!(3, my_uuid.get_version_num());
§References
Sourcepub fn get_version(&self) -> Option<Version>
pub fn get_version(&self) -> Option<Version>
Returns the version of the UUID.
This represents the algorithm used to generate the value.
If the version field doesn’t contain a recognized version then None
is returned. If you’re trying to read the version for a future extension
you can also use Uuid::get_version_num
to unconditionally return a
number. Future extensions may start to return Some
once they’re
standardized and supported.
§Examples
Basic usage:
let my_uuid = Uuid::parse_str("02f09a3f-1624-3b1d-8409-44eff7708208")?;
assert_eq!(Some(Version::Md5), my_uuid.get_version());
§References
Sourcepub fn as_fields(&self) -> (u32, u16, u16, &[u8; 8])
pub fn as_fields(&self) -> (u32, u16, u16, &[u8; 8])
Returns the four field values of the UUID.
These values can be passed to the Uuid::from_fields
method to get
the original Uuid
back.
- The first field value represents the first group of (eight) hex
digits, taken as a big-endian
u32
value. For V1 UUIDs, this field represents the low 32 bits of the timestamp. - The second field value represents the second group of (four) hex
digits, taken as a big-endian
u16
value. For V1 UUIDs, this field represents the middle 16 bits of the timestamp. - The third field value represents the third group of (four) hex digits,
taken as a big-endian
u16
value. The 4 most significant bits give the UUID version, and for V1 UUIDs, the last 12 bits represent the high 12 bits of the timestamp. - The last field value represents the last two groups of four and twelve hex digits, taken in order. The first 1-3 bits of this indicate the UUID variant, and for V1 UUIDs, the next 13-15 bits indicate the clock sequence and the last 48 bits indicate the node ID.
§Examples
let uuid = Uuid::nil();
assert_eq!(uuid.as_fields(), (0, 0, 0, &[0u8; 8]));
let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
assert_eq!(
uuid.as_fields(),
(
0xa1a2a3a4,
0xb1b2,
0xc1c2,
&[0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8],
)
);
Sourcepub fn to_fields_le(&self) -> (u32, u16, u16, &[u8; 8])
pub fn to_fields_le(&self) -> (u32, u16, u16, &[u8; 8])
Returns the four field values of the UUID in little-endian order.
The bytes in the returned integer fields will be converted from big-endian order. This is based on the endianness of the UUID, rather than the target environment so bytes will be flipped on both big and little endian machines.
§Examples
use uuid::Uuid;
let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
assert_eq!(
uuid.to_fields_le(),
(
0xa4a3a2a1,
0xb2b1,
0xc2c1,
&[0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8],
)
);
Sourcepub fn as_u128(&self) -> u128
pub fn as_u128(&self) -> u128
Returns a 128bit value containing the value.
The bytes in the UUID will be packed directly into a u128
.
§Examples
let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
assert_eq!(
uuid.as_u128(),
0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8,
);
Sourcepub fn to_u128_le(&self) -> u128
pub fn to_u128_le(&self) -> u128
Returns a 128bit little-endian value containing the value.
The bytes in the u128
will be flipped to convert into big-endian
order. This is based on the endianness of the UUID, rather than the
target environment so bytes will be flipped on both big and little
endian machines.
Note that this will produce a different result than
Uuid::to_fields_le
, because the entire UUID is reversed, rather
than reversing the individual fields in-place.
§Examples
let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
assert_eq!(
uuid.to_u128_le(),
0xd8d7d6d5d4d3d2d1c2c1b2b1a4a3a2a1,
);
Sourcepub fn as_u64_pair(&self) -> (u64, u64)
pub fn as_u64_pair(&self) -> (u64, u64)
Returns two 64bit values containing the value.
The bytes in the UUID will be split into two u64
.
The first u64 represents the 64 most significant bits,
the second one represents the 64 least significant.
§Examples
let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
assert_eq!(
uuid.as_u64_pair(),
(0xa1a2a3a4b1b2c1c2, 0xd1d2d3d4d5d6d7d8),
);
Sourcepub fn as_bytes(&self) -> &[u8; 16]
pub fn as_bytes(&self) -> &[u8; 16]
Returns a slice of 16 octets containing the value.
This method borrows the underlying byte value of the UUID.
§Examples
let bytes1 = [
0xa1, 0xa2, 0xa3, 0xa4,
0xb1, 0xb2,
0xc1, 0xc2,
0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
];
let uuid1 = Uuid::from_bytes_ref(&bytes1);
let bytes2 = uuid1.as_bytes();
let uuid2 = Uuid::from_bytes_ref(bytes2);
assert_eq!(uuid1, uuid2);
assert!(std::ptr::eq(
uuid2 as *const Uuid as *const u8,
&bytes1 as *const [u8; 16] as *const u8,
));
Sourcepub fn to_bytes_le(&self) -> [u8; 16]
pub fn to_bytes_le(&self) -> [u8; 16]
Returns the bytes of the UUID in little-endian order.
The bytes will be flipped to convert into little-endian order. This is based on the endianness of the UUID, rather than the target environment so bytes will be flipped on both big and little endian machines.
§Examples
use uuid::Uuid;
let uuid = Uuid::parse_str("a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8")?;
assert_eq!(
uuid.to_bytes_le(),
([
0xa4, 0xa3, 0xa2, 0xa1, 0xb2, 0xb1, 0xc2, 0xc1, 0xd1, 0xd2,
0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8
])
);
Sourcepub fn get_timestamp(&self) -> Option<Timestamp>
pub fn get_timestamp(&self) -> Option<Timestamp>
If the UUID is the correct version (v1, v6, or v7) this will return
the timestamp in a version-agnostic Timestamp
. For other versions
this will return None
.
§Roundtripping
This method is unlikely to roundtrip a timestamp in a UUID due to the way UUIDs encode timestamps. The timestamp returned from this method will be truncated to 100ns precision for version 1 and 6 UUIDs, and to millisecond precision for version 7 UUIDs.
Sourcepub fn get_node_id(&self) -> Option<[u8; 6]>
pub fn get_node_id(&self) -> Option<[u8; 6]>
If the UUID is the correct version (v1, or v6) this will return the
node value as a 6-byte array. For other versions this will return None
.
Trait Implementations§
Source§impl Clone for EntityUuid
impl Clone for EntityUuid
Source§fn clone(&self) -> EntityUuid
fn clone(&self) -> EntityUuid
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Component for EntityUuid
impl Component for EntityUuid
Source§impl Debug for EntityUuid
impl Debug for EntityUuid
Source§impl Default for EntityUuid
impl Default for EntityUuid
Source§fn default() -> EntityUuid
fn default() -> EntityUuid
Source§impl Deref for EntityUuid
impl Deref for EntityUuid
Source§impl DerefMut for EntityUuid
impl DerefMut for EntityUuid
impl Copy for EntityUuid
Auto Trait Implementations§
impl Freeze for EntityUuid
impl RefUnwindSafe for EntityUuid
impl Send for EntityUuid
impl Sync for EntityUuid
impl Unpin for EntityUuid
impl UnwindSafe for EntityUuid
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
§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId), )
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
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<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
fn get_components(self, func: &mut impl FnMut(StorageType, OwningPtr<'_>))
§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
].