pub struct Uuid { /* private fields */ }Expand description
This class defines an immutable universally unique identifier (UUID). It represents a 128-bit value.
The toString() method prints using base64 URL encoding without padding (matching Java’s implementation). Likewise, the from_string method expects a base64 URL encoded string.
Implementations§
Source§impl Uuid
impl Uuid
Sourcepub const ZERO_UUID: Uuid
pub const ZERO_UUID: Uuid
A UUID that represents a null or empty UUID. Will never be returned by random_uuid.
Sourcepub const METADATA_TOPIC_ID: Uuid = Self::ONE_UUID
pub const METADATA_TOPIC_ID: Uuid = Self::ONE_UUID
A UUID for the metadata topic in KRaft mode. Will never be returned by random_uuid.
Sourcepub const fn new(most_sig_bits: u64, least_sig_bits: u64) -> Self
pub const fn new(most_sig_bits: u64, least_sig_bits: u64) -> Self
Constructs a 128-bit UUID where the first u64 represents the most significant 64 bits and the second u64 represents the least significant 64 bits.
Sourcepub fn random_uuid() -> Self
pub fn random_uuid() -> Self
Static factory to retrieve a type 4 (pseudo randomly generated) UUID.
This will not generate a UUID equal to ZERO_UUID, ONE_UUID, or one whose
string representation starts with a dash (“-”).
Sourcepub const fn most_sig_bits(&self) -> u64
pub const fn most_sig_bits(&self) -> u64
Returns the most significant 64 bits of this UUID.
Sourcepub const fn least_sig_bits(&self) -> u64
pub const fn least_sig_bits(&self) -> u64
Returns the least significant 64 bits of this UUID.
Sourcepub fn with_bytes(bytes: [u8; 16]) -> Self
pub fn with_bytes(bytes: [u8; 16]) -> Self
Creates a UUID from a 16-byte array in big-endian order.
Sourcepub fn from_string(s: &str) -> Result<Self, String>
pub fn from_string(s: &str) -> Result<Self, String>
Creates a UUID based on a base64 URL encoded string (without padding). This matches the Java implementation’s fromString() method.
Sourcepub fn to_base64_string(self) -> String
pub fn to_base64_string(self) -> String
Returns a base64 URL encoded string (without padding) of the UUID. This matches the Java implementation’s toString() method.
Trait Implementations§
Source§impl Ord for Uuid
impl Ord for Uuid
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
Compares two UUIDs using signed 64-bit comparison to match Java’s
Uuid.compareTo() which compares long (signed) fields.
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Uuid
impl PartialOrd for Uuid
impl Copy for Uuid
impl Eq for Uuid
impl StructuralPartialEq for Uuid
Auto Trait Implementations§
impl Freeze for Uuid
impl RefUnwindSafe for Uuid
impl Send for Uuid
impl Sync for Uuid
impl Unpin for Uuid
impl UnsafeUnpin for Uuid
impl UnwindSafe for Uuid
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.