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
pub fn deserialize_borrowed<D>(
deserializer: D
) -> Result<Self, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Trait Implementations
fn deserialize<D>(
deserializer: D
) -> Result<Self, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<Self, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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
Auto Trait Implementations
impl<'a> RefUnwindSafe for Id<'a>
impl<'a> UnwindSafe for Id<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more