Struct twitch_api2::types::TimestampRef
source · [−]#[repr(transparent)]pub struct TimestampRef(_);
Expand description
A reference to a borrowed Timestamp
Implementations
sourceimpl TimestampRef
impl TimestampRef
sourcepub fn from_str(raw: &str) -> Result<&Self, <Timestamp as Validator>::Error>
pub fn from_str(raw: &str) -> Result<&Self, <Timestamp as Validator>::Error>
Transparently reinterprets the string slice as a strongly-typed TimestampRef if it conforms to Timestamp
sourcepub unsafe fn from_str_unchecked(raw: &str) -> &Self
pub unsafe fn from_str_unchecked(raw: &str) -> &Self
Transparently reinterprets the string slice as a strongly-typed TimestampRef without validating
sourcepub fn into_owned(self: Box<TimestampRef>) -> Timestamp
pub fn into_owned(self: Box<TimestampRef>) -> Timestamp
Converts a Box<TimestampRef>
into a Timestamp
without copying or allocating
sourceimpl TimestampRef
impl TimestampRef
sourcepub fn normalize(&self) -> Result<Cow<'_, TimestampRef>, TimestampParseError>
pub fn normalize(&self) -> Result<Cow<'_, TimestampRef>, TimestampParseError>
Normalize the timestamp into UTC time.
Examples
use twitch_api2::types::Timestamp;
let time = Timestamp::new("2021-07-01T13:37:00Z").unwrap();
assert_eq!(time.normalize()?.as_ref(), &time);
let time2 = Timestamp::new("2021-07-01T13:37:00-01:00").unwrap();
assert_ne!(time2.normalize()?.as_ref(), &time2);
sourcepub fn is_before<T>(&self, other: &T) -> bool where
Self: PartialOrd<T>,
pub fn is_before<T>(&self, other: &T) -> bool where
Self: PartialOrd<T>,
Compare another time and return self < other
.
Examples
use twitch_api2::types::Timestamp;
let time2021 = Timestamp::new("2021-07-01T13:37:00Z").unwrap();
let time2020 = Timestamp::new("2020-07-01T13:37:00Z").unwrap();
assert!(time2020.is_before(&time2021));
sourceimpl TimestampRef
impl TimestampRef
sourcepub fn to_utc(&self) -> OffsetDateTime
Available on crate feature time
only.
pub fn to_utc(&self) -> OffsetDateTime
time
only.Construct into a OffsetDateTime
time with a guaranteed UTC offset.
Panics
This method assumes the timestamp is a valid rfc3339 timestamp, and panics if not.
sourcepub fn to_fixed_offset(&self) -> OffsetDateTime
Available on crate feature time
only.
pub fn to_fixed_offset(&self) -> OffsetDateTime
time
only.Construct into a OffsetDateTime
time.
Panics
This method assumes the timestamp is a valid rfc3339 timestamp, and panics if not.
Trait Implementations
sourceimpl AsRef<TimestampRef> for Timestamp
impl AsRef<TimestampRef> for Timestamp
sourcefn as_ref(&self) -> &TimestampRef
fn as_ref(&self) -> &TimestampRef
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl AsRef<str> for TimestampRef
impl AsRef<str> for TimestampRef
sourceimpl Borrow<TimestampRef> for Timestamp
impl Borrow<TimestampRef> for Timestamp
sourcefn borrow(&self) -> &TimestampRef
fn borrow(&self) -> &TimestampRef
Immutably borrows from an owned value. Read more
sourceimpl Borrow<str> for TimestampRef
impl Borrow<str> for TimestampRef
sourceimpl Debug for TimestampRef
impl Debug for TimestampRef
sourceimpl<'de: 'a, 'a> Deserialize<'de> for &'a TimestampRef
impl<'de: 'a, 'a> Deserialize<'de> for &'a TimestampRef
sourcefn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for TimestampRef
impl Display for TimestampRef
sourceimpl From<&'_ TimestampRef> for Timestamp
impl From<&'_ TimestampRef> for Timestamp
sourcefn from(s: &TimestampRef) -> Self
fn from(s: &TimestampRef) -> Self
Converts to this type from the input type.
sourceimpl<'a, 'b: 'a> From<&'a Cow<'b, TimestampRef>> for &'a TimestampRef
impl<'a, 'b: 'a> From<&'a Cow<'b, TimestampRef>> for &'a TimestampRef
sourcefn from(r: &'a Cow<'b, TimestampRef>) -> &'a TimestampRef
fn from(r: &'a Cow<'b, TimestampRef>) -> &'a TimestampRef
Converts to this type from the input type.
sourceimpl<'a> From<&'a TimestampRef> for Cow<'a, TimestampRef>
impl<'a> From<&'a TimestampRef> for Cow<'a, TimestampRef>
sourcefn from(r: &'a TimestampRef) -> Self
fn from(r: &'a TimestampRef) -> Self
Converts to this type from the input type.
sourceimpl Hash for TimestampRef
impl Hash for TimestampRef
sourceimpl PartialEq<&'_ TimestampRef> for Timestamp
impl PartialEq<&'_ TimestampRef> for Timestamp
sourceimpl PartialEq<&'_ TimestampRef> for TimestampRef
impl PartialEq<&'_ TimestampRef> for TimestampRef
sourceimpl PartialEq<&'_ TimestampRef> for Box<TimestampRef>
impl PartialEq<&'_ TimestampRef> for Box<TimestampRef>
sourceimpl PartialEq<Box<TimestampRef, Global>> for &TimestampRef
impl PartialEq<Box<TimestampRef, Global>> for &TimestampRef
sourceimpl PartialEq<Box<TimestampRef, Global>> for TimestampRef
impl PartialEq<Box<TimestampRef, Global>> for TimestampRef
sourceimpl PartialEq<OffsetDateTime> for TimestampRef
Available on crate feature time
only.
impl PartialEq<OffsetDateTime> for TimestampRef
time
only.sourceimpl PartialEq<Timestamp> for TimestampRef
impl PartialEq<Timestamp> for TimestampRef
sourceimpl PartialEq<Timestamp> for &TimestampRef
impl PartialEq<Timestamp> for &TimestampRef
sourceimpl PartialEq<TimestampRef> for TimestampRef
impl PartialEq<TimestampRef> for TimestampRef
sourceimpl PartialEq<TimestampRef> for Timestamp
impl PartialEq<TimestampRef> for Timestamp
sourceimpl PartialEq<TimestampRef> for &TimestampRef
impl PartialEq<TimestampRef> for &TimestampRef
sourceimpl PartialOrd<OffsetDateTime> for TimestampRef
Available on crate feature time
only.
impl PartialOrd<OffsetDateTime> for TimestampRef
time
only.sourcefn partial_cmp(&self, other: &OffsetDateTime) -> Option<Ordering>
fn partial_cmp(&self, other: &OffsetDateTime) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
sourceimpl PartialOrd<Timestamp> for TimestampRef
impl PartialOrd<Timestamp> for TimestampRef
sourcefn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>
fn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
sourceimpl PartialOrd<TimestampRef> for TimestampRef
impl PartialOrd<TimestampRef> for TimestampRef
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
sourceimpl Serialize for TimestampRef
impl Serialize for TimestampRef
sourceimpl ToOwned for TimestampRef
impl ToOwned for TimestampRef
sourceimpl<'a> TryFrom<&'a str> for &'a TimestampRef
impl<'a> TryFrom<&'a str> for &'a TimestampRef
impl Eq for TimestampRef
Auto Trait Implementations
impl RefUnwindSafe for TimestampRef
impl Send for TimestampRef
impl !Sized for TimestampRef
impl Sync for TimestampRef
impl Unpin for TimestampRef
impl UnwindSafe for TimestampRef
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.