Struct uuid_b64::UuidB64
[−]
[src]
pub struct UuidB64(_);
It's a Uuid that displays as Base 64
Methods
impl UuidB64
[src]
pub fn new() -> UuidB64
[src]
Generate a new v4 Uuid
pub fn uuid(&self) -> Uuid
[src]
Copy the raw UUID out
pub fn to_istring(&self) -> InlineString
[src]
Convert this to a new InlineString
InlineString
s are stack-allocated and therefore faster than
heap-allocated Strings. How much faster? Somewhat faster:
test uuidb64_to_inline_string ... bench: 49 ns/iter (+/- 20)
test uuidb64_to_inline_string_new_id_per_loop ... bench: 146 ns/iter (+/- 23)
test uuidb64_to_string ... bench: 151 ns/iter (+/- 28)
test uuidb64_to_string_new_id_per_loop ... bench: 268 ns/iter (+/- 144)
Honestly this is unlikely to matter for your use case, but since B64 UUIDs have a serialization that does fit within the InlineString limit (where the regular UUID representation does not) it felt like a waste to not do this. Also this is what is used for Serde, so we're zero-allocation for that.
pub fn to_buf(&self, buffer: &mut String)
[src]
Write the Base64-encoded UUID into the provided buffer
let known_id = Uuid::parse_str("b0c1ee86-6f46-4f1b-8d8b-7849e75dbcee").unwrap(); let as_b64 = UuidB64::from(known_id); let mut buf = String::new(); as_b64.to_buf(&mut buf); assert_eq!(&buf, "sMHuhm9GTxuNi3hJ51287g");
Trait Implementations
impl Copy for UuidB64
[src]
impl Clone for UuidB64
[src]
fn clone(&self) -> UuidB64
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq for UuidB64
[src]
fn eq(&self, __arg_0: &UuidB64) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &UuidB64) -> bool
[src]
This method tests for !=
.
impl Eq for UuidB64
[src]
impl Hash for UuidB64
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialOrd for UuidB64
[src]
fn partial_cmp(&self, __arg_0: &UuidB64) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &UuidB64) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &UuidB64) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &UuidB64) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &UuidB64) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for UuidB64
[src]
fn cmp(&self, __arg_0: &UuidB64) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl FromStr for UuidB64
[src]
Parse a B64 encoded string into a UuidB64
let parsed_b64: UuidB64 = "sMHuhm9GTxuNi3hJ51287g".parse().unwrap(); assert_eq!(format!("{:?}", parsed_b64), "UuidB64(sMHuhm9GTxuNi3hJ51287g)");
type Err = ErrorKind
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
Parses a string s
to return a value of this type. Read more
impl<T> From<T> for UuidB64 where
T: Into<Uuid>,
[src]
T: Into<Uuid>,
Right now this is just Uuid
, but anything Uuid is comfortable with, we are
impl Debug for UuidB64
[src]
fn fmt(&self, f: &mut Formatter) -> FmtResult
[src]
Same as the display formatter, but includes UuidB64()
around it
let known_id = Uuid::parse_str("b0c1ee86-6f46-4f1b-8d8b-7849e75dbcee").unwrap(); let as_b64 = UuidB64::from(known_id); assert_eq!(format!("{:?}", as_b64), "UuidB64(sMHuhm9GTxuNi3hJ51287g)");