sqlx::types::uuid::fmt

Struct Simple

Source
pub struct Simple(/* private fields */);
Expand description

Format a Uuid as a simple string, like 67e5504410b1426f9247bb680e5fe0c8.

Implementationsยง

Sourceยง

impl Simple

Source

pub const LENGTH: usize = 32usize

The length of a simple Uuid string.

Source

pub const fn from_uuid(uuid: Uuid) -> Simple

Creates a Simple from a Uuid.

Source

pub fn encode_lower<'buf>(&self, buffer: &'buf mut [u8]) -> &'buf mut str

Writes the Uuid as a lower-case simple string to buffer, and returns the subslice of the buffer that contains the encoded UUID.

This is slightly more efficient than using the formatting infrastructure as it avoids virtual calls, and may avoid double buffering.

ยงPanics

Panics if the buffer is not large enough: it must have length at least LENGTH. Uuid::encode_buffer can be used to get a sufficiently-large temporary buffer.

ยงExamples
use uuid::Uuid;

fn main() -> Result<(), uuid::Error> {
    let uuid = Uuid::parse_str("936DA01f9abd4d9d80c702af85c822a8")?;

    // the encoded portion is returned
    assert_eq!(
        uuid.simple().encode_lower(&mut Uuid::encode_buffer()),
        "936da01f9abd4d9d80c702af85c822a8"
    );

    // the buffer is mutated directly, and trailing contents remains
    let mut buf = [b'!'; 36];
    assert_eq!(
        uuid.simple().encode_lower(&mut buf),
        "936da01f9abd4d9d80c702af85c822a8"
    );
    assert_eq!(
        &buf as &[_],
        b"936da01f9abd4d9d80c702af85c822a8!!!!" as &[_]
    );

    Ok(())
}

*/

Source

pub fn encode_upper<'buf>(&self, buffer: &'buf mut [u8]) -> &'buf mut str

Writes the Uuid as an upper-case simple string to buffer, and returns the subslice of the buffer that contains the encoded UUID.

ยงPanics

Panics if the buffer is not large enough: it must have length at least LENGTH. Uuid::encode_buffer can be used to get a sufficiently-large temporary buffer.

ยงExamples
use uuid::Uuid;

fn main() -> Result<(), uuid::Error> {
    let uuid = Uuid::parse_str("936da01f9abd4d9d80c702af85c822a8")?;

    // the encoded portion is returned
    assert_eq!(
        uuid.simple().encode_upper(&mut Uuid::encode_buffer()),
        "936DA01F9ABD4D9D80C702AF85C822A8"
    );

    // the buffer is mutated directly, and trailing contents remains
    let mut buf = [b'!'; 36];
    assert_eq!(
        uuid.simple().encode_upper(&mut buf),
        "936DA01F9ABD4D9D80C702AF85C822A8"
    );
    assert_eq!(
        &buf as &[_],
        b"936DA01F9ABD4D9D80C702AF85C822A8!!!!" as &[_]
    );

    Ok(())
}

*/

Source

pub const fn as_uuid(&self) -> &Uuid

Get a reference to the underlying Uuid.

ยงExamples
use uuid::Uuid;

let simple = Uuid::nil().simple();
assert_eq!(*simple.as_uuid(), Uuid::nil());
Source

pub const fn into_uuid(self) -> Uuid

Consumes the Simple, returning the underlying Uuid.

ยงExamples
use uuid::Uuid;

let simple = Uuid::nil().simple();
assert_eq!(simple.into_uuid(), Uuid::nil());

Trait Implementationsยง

Sourceยง

impl AsRef<Uuid> for Simple

Sourceยง

fn as_ref(&self) -> &Uuid

Converts this type into a shared reference of the (usually inferred) input type.
Sourceยง

impl Borrow<Uuid> for Simple

Sourceยง

fn borrow(&self) -> &Uuid

Immutably borrows from an owned value. Read more
Sourceยง

impl Clone for Simple

Sourceยง

fn clone(&self) -> Simple

Returns a copy of the value. Read more
1.0.0 ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Sourceยง

impl Debug for Simple

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Sourceยง

impl Decode<'_, MySql> for Simple

Sourceยง

fn decode( value: MySqlValueRef<'_>, ) -> Result<Simple, Box<dyn Error + Sync + Send>>

Decode a new value of this type using a raw value from the database.
Sourceยง

impl Decode<'_, Sqlite> for Simple

Sourceยง

fn decode( value: SqliteValueRef<'_>, ) -> Result<Simple, Box<dyn Error + Sync + Send>>

Decode a new value of this type using a raw value from the database.
Sourceยง

impl Default for Simple

Sourceยง

fn default() -> Simple

Returns the โ€œdefault valueโ€ for a type. Read more
Sourceยง

impl Display for Simple

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Sourceยง

impl Encode<'_, MySql> for Simple

Sourceยง

fn encode_by_ref( &self, buf: &mut Vec<u8>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

Writes the value of self into buf without moving self. Read more
Sourceยง

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
where Self: Sized,

Writes the value of self into buf in the expected format for the database.
Sourceยง

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

Sourceยง

fn size_hint(&self) -> usize

Sourceยง

impl<'q> Encode<'q, Sqlite> for Simple

Sourceยง

fn encode_by_ref( &self, args: &mut Vec<SqliteArgumentValue<'q>>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

Writes the value of self into buf without moving self. Read more
Sourceยง

fn encode( self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
where Self: Sized,

Writes the value of self into buf in the expected format for the database.
Sourceยง

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

Sourceยง

fn size_hint(&self) -> usize

Sourceยง

impl From<Simple> for Uuid

Sourceยง

fn from(f: Simple) -> Uuid

Converts to this type from the input type.
Sourceยง

impl From<Uuid> for Simple

Sourceยง

fn from(f: Uuid) -> Simple

Converts to this type from the input type.
Sourceยง

impl Hash for Simple

Sourceยง

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 ยท Sourceยง

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Sourceยง

impl LowerHex for Simple

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Sourceยง

impl Ord for Simple

Sourceยง

fn cmp(&self, other: &Simple) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 ยท Sourceยง

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 ยท Sourceยง

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 ยท Sourceยง

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Sourceยง

impl PartialEq for Simple

Sourceยง

fn eq(&self, other: &Simple) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท Sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Sourceยง

impl PartialOrd for Simple

Sourceยง

fn partial_cmp(&self, other: &Simple) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 ยท Sourceยง

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 ยท Sourceยง

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 ยท Sourceยง

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 ยท Sourceยง

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Sourceยง

impl Type<MySql> for Simple

Sourceยง

fn type_info() -> MySqlTypeInfo

Returns the canonical SQL type for this Rust type. Read more
Sourceยง

fn compatible(ty: &MySqlTypeInfo) -> bool

Determines if this Rust type is compatible with the given SQL type. Read more
Sourceยง

impl Type<Sqlite> for Simple

Sourceยง

fn type_info() -> SqliteTypeInfo

Returns the canonical SQL type for this Rust type. Read more
Sourceยง

fn compatible(ty: &<DB as Database>::TypeInfo) -> bool

Determines if this Rust type is compatible with the given SQL type. Read more
Sourceยง

impl UpperHex for Simple

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Sourceยง

impl Copy for Simple

Sourceยง

impl Eq for Simple

Sourceยง

impl StructuralPartialEq for Simple

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> CloneToUninit for T
where T: Clone,

Sourceยง

unsafe fn clone_to_uninit(&self, dst: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Sourceยง

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Sourceยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T> Instrument for T

Sourceยง

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Sourceยง

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Sourceยง

impl<T> IntoEither for T

Sourceยง

fn into_either(self, into_left: bool) -> Either<Self, Self> โ“˜

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ“˜
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

impl<T> Same for T

Sourceยง

type Output = T

Should always be Self
Sourceยง

impl<T> ToOwned for T
where T: Clone,

Sourceยง

type Owned = T

The resulting type after obtaining ownership.
Sourceยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Sourceยง

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Sourceยง

impl<T> ToString for T
where T: Display + ?Sized,

Sourceยง

fn to_string(&self) -> String

Converts the given value to a String. Read more
Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Sourceยง

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Sourceยง

fn vzip(self) -> V

Sourceยง

impl<T> WithSubscriber for T

Sourceยง

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Sourceยง

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Sourceยง

impl<T> ErasedDestructor for T
where T: 'static,

Sourceยง

impl<T> MaybeSendSync for T