[][src]Struct brawl_api::time::TimeLike

pub struct TimeLike(_);

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).

Methods

impl TimeLike[src]

pub fn parse(&self) -> Result<DateTime<Utc>>[src]

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.

impl TimeLike[src]

pub fn inner(&self) -> &String[src]

Returns an immutable reference to the inner string.

pub fn inner_mut(&mut self) -> &mut String[src]

Returns a mutable reference to the inner string.

Trait Implementations

impl Clone for TimeLike[src]

impl Debug for TimeLike[src]

impl Default for TimeLike[src]

fn default() -> TimeLike[src]

Returns an initial TimeLike instance containing an empty string.

Examples

use brawl_api::TimeLike;

assert_eq!(
    TimeLike::default().to_string(),
    "",
)

impl<'de> Deserialize<'de> for TimeLike[src]

impl Display for TimeLike[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Displays the inner string of the TimeLike instance.

impl Eq for TimeLike[src]

impl Hash for TimeLike[src]

impl PartialEq<TimeLike> for TimeLike[src]

impl Serialize for TimeLike[src]

impl StructuralEq for TimeLike[src]

impl StructuralPartialEq for TimeLike[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> FetchFrom<T> for T where
    T: Clone + Send + Sync
[src]

fn fetch_from(&Client, &T) -> Result<T, Error>[src]

(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.

fn a_fetch_from<'life0, 'life1, 'async_trait>(
    &'life0 Client,
    &'life1 T
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + 'async_trait + Send>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    T: 'async_trait, 
[src]

(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.

impl<T, U> FetchInto<U> for T where
    T: Sync + Send,
    U: FetchFrom<T> + Sync + Send
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.