rosu_v2/request/
matches.rs1use crate::{
2 model::matches::{MatchList, OsuMatch},
3 request::{Query, Request},
4 routing::Route,
5 Osu,
6};
7
8use serde::Serialize;
9
10#[must_use = "requests must be configured and executed"]
12#[derive(Serialize)]
13pub struct GetMatch<'a> {
14 #[serde(skip)]
15 osu: &'a Osu,
16 #[serde(skip)]
17 match_id: u32,
18 after: Option<u64>,
19 before: Option<u64>,
20 limit: Option<usize>,
21}
22
23impl<'a> GetMatch<'a> {
24 pub(crate) const fn new(osu: &'a Osu, match_id: u32) -> Self {
25 Self {
26 osu,
27 match_id,
28 after: None,
29 before: None,
30 limit: None,
31 }
32 }
33
34 #[inline]
38 pub const fn after(mut self, after: u64) -> Self {
39 self.after = Some(after);
40
41 self
42 }
43
44 #[inline]
48 pub const fn before(mut self, before: u64) -> Self {
49 self.before = Some(before);
50
51 self
52 }
53
54 #[inline]
56 pub const fn limit(mut self, limit: usize) -> Self {
57 self.limit = Some(limit);
58
59 self
60 }
61}
62
63into_future! {
64 |self: GetMatch<'_>| -> OsuMatch {
65 let route = Route::GetMatch {
66 match_id: Some(self.match_id),
67 };
68
69 Request::with_query(route, Query::encode(&self))
70 }
71}
72
73#[must_use = "requests must be configured and executed"]
75#[derive(Serialize)]
76pub struct GetMatches<'a> {
77 #[serde(skip)]
78 osu: &'a Osu,
79 #[serde(rename = "cursor_string")]
80 cursor: Option<&'a str>,
81}
82
83impl<'a> GetMatches<'a> {
84 pub(crate) const fn new(osu: &'a Osu) -> Self {
85 Self { osu, cursor: None }
86 }
87
88 #[inline]
89 pub(crate) const fn cursor(mut self, cursor: &'a str) -> Self {
90 self.cursor = Some(cursor);
91
92 self
93 }
94}
95
96into_future! {
97 |self: GetMatches<'_>| -> MatchList {
98 Request::with_query(
99 Route::GetMatch { match_id: None },
100 Query::encode(&self),
101 )
102 }
103}