Struct rustube::Id[][src]

pub struct Id<'a>(_);
Expand description

A wrapper around a Cow<’a, str> that makes sure the video id, which is contained, always has the correct format.

Guaranties:

Since YouTube does not guarantee a consistent video-id format, these guarantees can change in major version updates. If your application depends on them, make sure to check this section on regular bases!

  • The id will always match following regex (defined in ID_PATTERN): ^[a-zA-Z0-9_-]{11}$
  • The id can always be used as a valid url segment
  • The id can always be used as a valid url parameter

Ownership

All available constructors except for Id::deserialize and Id::from_string will create the borrowed version with the lifetime of the input. Therefore no allocation is required.

If you don’t need ’static deserialization, you can use Id::deserialize_borrowed, which will create an Id<'de>.

If you require Id to be owned (Id<'static>), you can use Id::as_owned or Id::into_owned, which both can easily be chained. You can also use IdBuf, which is an alias for Id<'static>, to make functions and types less verbose.

Implementations

Trait Implementations

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

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

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

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

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

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

Performs the conversion.

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

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

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.