Struct twitch_api2::types::Timestamp
source · [−]#[repr(transparent)]pub struct Timestamp(_);
Expand description
RFC3339 timestamp
Implementations
sourceimpl Timestamp
impl Timestamp
sourcepub fn new<S: Into<String> + AsRef<str>>(
s: S
) -> Result<Self, <Timestamp as Validator>::Error>
pub fn new<S: Into<String> + AsRef<str>>(
s: S
) -> Result<Self, <Timestamp as Validator>::Error>
Constructs a new Timestamp if it conforms to Timestamp
sourcepub unsafe fn new_unchecked<S: Into<String>>(s: S) -> Self
pub unsafe fn new_unchecked<S: Into<String>>(s: S) -> Self
sourcepub fn into_boxed_ref(self) -> Box<TimestampRef>
pub fn into_boxed_ref(self) -> Box<TimestampRef>
Converts this Timestamp
into a Box
<
TimestampRef
>
This will drop any excess capacity.
sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Unwraps the underlying String
value
Methods from Deref<Target = 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));
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 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 Deref for Timestamp
impl Deref for Timestamp
type Target = TimestampRef
type Target = TimestampRef
The resulting type after dereferencing.
sourceimpl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
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 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 From<Box<TimestampRef, Global>> for Timestamp
impl From<Box<TimestampRef, Global>> for Timestamp
sourcefn from(r: Box<TimestampRef>) -> Self
fn from(r: Box<TimestampRef>) -> Self
Converts to this type from the input type.
sourceimpl<'a> From<Cow<'a, TimestampRef>> for Timestamp
impl<'a> From<Cow<'a, TimestampRef>> for Timestamp
sourcefn from(r: Cow<'a, TimestampRef>) -> Self
fn from(r: Cow<'a, TimestampRef>) -> Self
Converts to this type from the input type.
sourceimpl From<Timestamp> for Box<TimestampRef>
impl From<Timestamp> for Box<TimestampRef>
sourceimpl<'a> From<Timestamp> for Cow<'a, TimestampRef>
impl<'a> From<Timestamp> for Cow<'a, TimestampRef>
sourceimpl PartialEq<&'_ TimestampRef> for Timestamp
impl PartialEq<&'_ TimestampRef> for Timestamp
sourceimpl PartialEq<OffsetDateTime> for Timestamp
Available on crate feature time
only.
impl PartialEq<OffsetDateTime> for Timestamp
time
only.sourceimpl PartialEq<Timestamp> for TimestampRef
impl PartialEq<Timestamp> for TimestampRef
sourceimpl PartialEq<Timestamp> for &TimestampRef
impl PartialEq<Timestamp> for &TimestampRef
sourceimpl PartialEq<Timestamp> for Box<TimestampRef>
impl PartialEq<Timestamp> for Box<TimestampRef>
sourceimpl PartialEq<TimestampRef> for Timestamp
impl PartialEq<TimestampRef> for Timestamp
sourceimpl PartialOrd<OffsetDateTime> for Timestamp
Available on crate feature time
only.
impl PartialOrd<OffsetDateTime> for Timestamp
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 Timestamp
impl PartialOrd<Timestamp> for Timestamp
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 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 TryFrom<OffsetDateTime> for Timestamp
Available on crate feature time
only.
impl TryFrom<OffsetDateTime> for Timestamp
time
only.impl Eq for Timestamp
Auto Trait Implementations
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
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.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more