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
impl OsuMatch
sourcepub fn games(&self) -> MatchGameIter<'_> ⓘ
pub fn games(&self) -> MatchGameIter<'_> ⓘ
Iterate over references of the match’s MatchGame
s.
sourcepub fn drain_games(&mut self) -> MatchGameDrain<'_> ⓘ
pub fn drain_games(&mut self) -> MatchGameDrain<'_> ⓘ
Return an iterator over all MatchGame
s 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());
sourcepub async fn get_next(&self, osu: &Osu) -> OsuResult<OsuMatch>
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.
sourcepub fn has_previous(&self) -> bool
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.
Trait Implementations§
source§impl<'de> Deserialize<'de> for OsuMatch
impl<'de> Deserialize<'de> for OsuMatch
source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
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
impl PartialEq<OsuMatch> for OsuMatch
impl Eq for OsuMatch
Auto Trait Implementations§
impl RefUnwindSafe for OsuMatch
impl Send for OsuMatch
impl Sync for OsuMatch
impl Unpin for OsuMatch
impl UnwindSafe for OsuMatch
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
Mutably borrows from an owned value. Read more
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.