pub struct TimeLike(/* private fields */);Expand description
Represents a timestamp provided by the Brawl API. If the chrono feature is enabled (it is
by default), then it is possible to use helper methods to convert it to chrono data
structures - see TimeLike.parse (this is recommended, as it is aware of the correct
format).
Implementations§
Source§impl TimeLike
impl TimeLike
Sourcepub fn parse(&self) -> Result<DateTime<Utc>>
pub fn parse(&self) -> Result<DateTime<Utc>>
Parses this timestamp into a chrono::DateTime<chrono::Utc>, using the API’s
format (see constants::TIMELIKE_FORMAT).
§Errors
If the string is invalid, an Error::ParseTimeLike is returned.
Generally, when requesting from the API, this shouldn’t ever happen.
§Examples
use brawl_api::prelude::*;
use brawl_api::{TimeLike, Battle};
use chrono::{DateTime, Utc};
// after obtaining a fetched battlelog's battle
let battle: Battle;
let mut the_time: TimeLike = battle.battle_time;
let parsed_time: DateTime<Utc> = the_time.parse()?;
// the parsed time of the battle is now available for use.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TimeLike
impl<'de> Deserialize<'de> for TimeLike
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for TimeLike
impl StructuralPartialEq for TimeLike
Auto Trait Implementations§
impl Freeze for TimeLike
impl RefUnwindSafe for TimeLike
impl Send for TimeLike
impl Sync for TimeLike
impl Unpin for TimeLike
impl UnwindSafe for TimeLike
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FetchFrom<T> for T
impl<T> FetchFrom<T> for T
Source§fn fetch_from(_: &Client, t: &T) -> Result<T, Error>
fn fetch_from(_: &Client, t: &T) -> Result<T, Error>
(Sync) Returns a copy of the current instance when attempting to fetch from itself.
In order to re-fetch, see Refetchable.
§Errors
Never errors; is only a Result in order to match the trait signature.
Source§fn a_fetch_from<'life0, 'life1, 'async_trait>(
_: &'life0 Client,
t: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
T: 'async_trait,
fn a_fetch_from<'life0, 'life1, 'async_trait>(
_: &'life0 Client,
t: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
T: 'async_trait,
(Async) Returns a copy of the current instance when attempting to fetch from itself.
In order to re-fetch, see Refetchable.
§Errors
Never errors; is only a Result in order to match the trait signature.