Struct rosu_v2::model::matches::OsuMatch

source ·
pub struct OsuMatch {
    pub current_game_id: Option<u64>,
    pub end_time: Option<OffsetDateTime>,
    pub events: Vec<MatchEvent>,
    pub first_event_id: u64,
    pub latest_event_id: u64,
    pub match_id: u32,
    pub name: String,
    pub start_time: OffsetDateTime,
    pub users: HashMap<u32, UserCompact>,
}

Fields§

§current_game_id: Option<u64>§end_time: Option<OffsetDateTime>§events: Vec<MatchEvent>§first_event_id: u64§latest_event_id: u64§match_id: u32§name: String§start_time: OffsetDateTime§users: HashMap<u32, UserCompact>

Maps user ids to users

Implementations§

source§

impl OsuMatch

source

pub fn games(&self) -> MatchGameIter<'_>

Iterate over references of the match’s MatchGames.

source

pub fn drain_games(&mut self) -> MatchGameDrain<'_>

Return an iterator over all MatchGames of the match.

Note: The games are drained from the match’s events meaning the events field will be empty after this method is called.

Example
use rosu_v2::model::matches::{OsuMatch, MatchEvent, MatchGame};

let mut osu_match = OsuMatch {
    events: vec![
        MatchEvent::Create { ... },
        MatchEvent::Game {
            game: Box::new(MatchGame { game_id: 14, ... }),
            ...
        },
        MatchEvent::Joined { ... },
        MatchEvent::Game {
            game: Box::new(MatchGame { game_id: 52, ... }),
            ...
        },
    ],
    ...
};

assert_eq!(osu_match.events.len(), 4);

{
    // Borrows osu_match mutably, this smaller scope lifts that borrow
    let mut iter = osu_match.drain_games();

    assert!(matches!(iter.next(), Some(MatchGame { game_id: 14, .. })));
    assert!(matches!(iter.next(), Some(MatchGame { game_id: 52, .. })));
    assert!(matches!(iter.next(), None));
}

// Events were drained, hence empty
assert!(osu_match.events.is_empty());
source

pub async fn get_next(&self, osu: &Osu) -> OsuResult<OsuMatch>

Get the OsuMatch containing only data from some event id onwards.

If the latest game event is an in-progress game, the result will contain all events starting from this game event, inclusively. Otherwise it will contain all events after the currently last event.

Convenient to display a “live” update of the match, e.g. the way an mp link pulls the next result every 10 seconds.

source

pub fn has_previous(&self) -> bool

The API sends only up to 100 events per request. This method checks whether there are events before the currently first event.

source

pub async fn get_previous(&self, osu: &Osu) -> Option<OsuResult<OsuMatch>>

Get the OsuMatch containing only data before some event id.

This method returns None either if the events field is empty or if the first event is already contained.

Trait Implementations§

source§

impl Clone for OsuMatch

source§

fn clone(&self) -> OsuMatch

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for OsuMatch

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for OsuMatch

source§

fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq<OsuMatch> for OsuMatch

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for OsuMatch

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,