Struct sqlx::types::uuid::fmt::Hyphenated

source ยท
pub struct Hyphenated(/* private fields */);
Expand description

Format a Uuid as a hyphenated string, like 67e55044-10b1-426f-9247-bb680e5fe0c8.

Implementationsยง

sourceยง

impl Hyphenated

source

pub const LENGTH: usize = 36usize

The length of a hyphenated Uuid string.

source

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

Creates a Hyphenated from a Uuid.

source

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

Writes the Uuid as a lower-case hyphenated 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.hyphenated()
            .encode_lower(&mut Uuid::encode_buffer()),
        "936da01f-9abd-4d9d-80c7-02af85c822a8"
    );

    // the buffer is mutated directly, and trailing contents remains
    let mut buf = [b'!'; 40];
    uuid.hyphenated().encode_lower(&mut buf);
    assert_eq!(
        &buf as &[_],
        b"936da01f-9abd-4d9d-80c7-02af85c822a8!!!!" as &[_]
    );

    Ok(())
}

*/

source

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

Writes the Uuid as an upper-case hyphenated 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.hyphenated()
            .encode_upper(&mut Uuid::encode_buffer()),
        "936DA01F-9ABD-4D9D-80C7-02AF85C822A8"
    );

    // the buffer is mutated directly, and trailing contents remains
    let mut buf = [b'!'; 40];
    uuid.hyphenated().encode_upper(&mut buf);
    assert_eq!(
        &buf as &[_],
        b"936DA01F-9ABD-4D9D-80C7-02AF85C822A8!!!!" as &[_]
    );

    Ok(())
}

*/

source

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

Get a reference to the underlying Uuid.

ยงExamples
use uuid::Uuid;

let hyphenated = Uuid::nil().hyphenated();
assert_eq!(*hyphenated.as_uuid(), Uuid::nil());
source

pub const fn into_uuid(self) -> Uuid

Consumes the Hyphenated, returning the underlying Uuid.

ยงExamples
use uuid::Uuid;

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

Trait Implementationsยง

sourceยง

impl AsRef<Uuid> for Hyphenated

sourceยง

fn as_ref(&self) -> &Uuid

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

impl Borrow<Uuid> for Hyphenated

sourceยง

fn borrow(&self) -> &Uuid

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

impl Clone for Hyphenated

sourceยง

fn clone(&self) -> Hyphenated

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 Hyphenated

sourceยง

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

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

impl Decode<'_, MySql> for Hyphenated

sourceยง

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

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

impl Decode<'_, Sqlite> for Hyphenated

sourceยง

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

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

impl Default for Hyphenated

sourceยง

fn default() -> Hyphenated

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

impl Display for Hyphenated

sourceยง

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

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

impl Encode<'_, MySql> for Hyphenated

sourceยง

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

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

fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull
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 Hyphenated

sourceยง

fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull

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

fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull
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<Hyphenated> for Uuid

sourceยง

fn from(f: Hyphenated) -> Uuid

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

impl From<Uuid> for Hyphenated

sourceยง

fn from(f: Uuid) -> Hyphenated

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

impl Hash for Hyphenated

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 Hyphenated

sourceยง

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

Formats the value using the given formatter.
sourceยง

impl Ord for Hyphenated

sourceยง

fn cmp(&self, other: &Hyphenated) -> 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 + PartialOrd,

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

impl PartialEq for Hyphenated

sourceยง

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 ยท sourceยง

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
sourceยง

impl PartialOrd for Hyphenated

sourceยง

fn partial_cmp(&self, other: &Hyphenated) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
sourceยง

impl Type<MySql> for Hyphenated

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 Hyphenated

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 Hyphenated

sourceยง

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

Formats the value using the given formatter.
sourceยง

impl Copy for Hyphenated

sourceยง

impl Eq for Hyphenated

sourceยง

impl StructuralPartialEq for Hyphenated

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<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

Checks if this value is equivalent to the given key. Read more
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> Same for T

ยง

type Output = T

Should always be Self
sourceยง

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

ยง

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ยง

default 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>,

ยง

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>,

ยง

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