splits_io_api/schema.rs
1use uuid::Uuid;
2
3/// A Category is a ruleset for a Game (Any%, 100%, MST, etc.) and an optional container for Runs.
4///
5/// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#category)
6#[derive(Debug, serde_derive::Deserialize)]
7pub struct Category {
8 /// The time and date at which this category was created on splits.io. This field conforms to
9 /// ISO 8601.
10 pub created_at: Box<str>,
11 /// The unique ID of the category.
12 pub id: Box<str>,
13 /// The name of the category.
14 pub name: Box<str>,
15 /// The time and date at which this category was most recently modified on splits.io. This field
16 /// conforms to ISO 8601.
17 pub updated_at: Box<str>,
18}
19
20/// A Chat Message is a shortform message sent by a user to a Race
21///
22/// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#chat-message)
23#[derive(Debug, serde_derive::Deserialize)]
24pub struct ChatMessage {
25 /// The contents of the message.
26 pub body: Box<str>,
27 /// The time and date at which this message was created on splits.io. This field conforms to ISO
28 /// 8601.
29 pub created_at: Box<str>,
30 /// Boolean indicating whether the sender was in the race when the message was sent.
31 pub from_entrant: bool,
32 /// The time and date at which this message was most recently modified on splits.io. This field
33 /// conforms to ISO 8601.
34 pub updated_at: Box<str>,
35 /// The Runner that sent the message.
36 pub user: Runner,
37}
38
39/// An Entry represents a Runner's participation in a Race or a ghost of a past Run.
40///
41/// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#entry)
42#[derive(Debug, serde_derive::Deserialize)]
43pub struct Entry {
44 /// The time and date at which this Entry was created on splits.io. This field conforms to ISO
45 /// 8601.
46 pub created_at: Box<str>,
47 /// The user that created this Entry; can be different from runner if the Entry is a ghost.
48 pub creator: Runner,
49 /// The time and date at which the runner finished this Race, if at all. This field conforms to
50 /// ISO 8601.
51 #[serde(default)]
52 pub finished_at: Option<Box<str>>,
53 /// The time and date at which the runner forfeited from this Race, if at all. This field
54 /// conforms to ISO 8601.
55 #[serde(default)]
56 pub forfeited_at: Option<Box<str>>,
57 /// Whether the Entry represents a past recording of a run (true) or a real user that has
58 /// entered into the race explicitly (false).
59 pub ghost: bool,
60 /// The unchanging unique ID of this Entry.
61 pub id: Uuid,
62 /// The time and date at which the runner readied up in the Race, if at all. This field conforms
63 /// to ISO 8601.
64 #[serde(default)]
65 pub readied_at: Option<Box<str>>,
66 /// The Run linked to the current Entry. It has more detailed info about this runner's run, such
67 /// as splits and history.
68 pub run: Option<Run>,
69 /// The user participating in the race. If the entry is a ghost, this can differ from the
70 /// creator.
71 pub runner: Runner,
72 /// The time and date at which this Entry was most recently modified on splits.io. This field
73 /// conforms to ISO 8601.
74 pub updated_at: Box<str>,
75}
76
77/// A Game is a collection of information about a game, and a container for Categories.
78///
79/// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#game)
80#[derive(Debug, serde_derive::Deserialize)]
81pub struct Game {
82 /// The known speedrun categories for this game.
83 pub categories: Option<Vec<Category>>,
84 /// The time and date at which this game was created on splits.io. This field conforms to ISO
85 /// 8601.
86 pub created_at: Box<str>,
87 /// The unique ID of the game.
88 pub id: Box<str>,
89 /// The full title of the game, like "Super Mario Sunshine".
90 pub name: Box<str>,
91 /// A shortened title of the game, like "sms", if it is known. Where possible, this name tries
92 /// to match with those on SpeedRunsLive and/or Speedrun.com.
93 #[serde(default)]
94 pub shortname: Option<Box<str>>,
95 /// The time and date at which this game was most recently modified on splits.io. This field
96 /// conforms to ISO 8601.
97 pub updated_at: Box<str>,
98}
99
100/// Information about a past attempt associated with a Run.
101///
102/// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#history)
103#[derive(Debug, serde_derive::Deserialize)]
104pub struct RunItemHistories {
105 /// The corresponding attempt number this attempt was.
106 pub attempt_number: u32,
107 /// The gametime duration this attempt took in milliseconds.
108 pub gametime_duration_ms: f64,
109 /// The realtime duration this attempt took in milliseconds.
110 pub realtime_duration_ms: f64,
111}
112
113/// A Run maps 1:1 to an uploaded splits file.
114///
115/// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#run)
116#[derive(Debug, serde_derive::Deserialize)]
117pub struct Run {
118 /// The number of run attempts recorded by the timer that generated the run's source file, if
119 /// supported by the source timer.
120 #[serde(default)]
121 pub attempts: Option<u32>,
122 /// The category which was run, if it was supplied by the runner and determined from the source
123 /// file.
124 pub category: Option<Category>,
125 /// The time and date at which this run's source file was uploaded to splits.io. This field
126 /// conforms to ISO 8601.
127 pub created_at: Box<str>,
128 /// The timing method used for the run. Will be either real or game.
129 pub default_timing: Box<str>,
130 /// The game which was run, if it was supplied by the runner and determined from the source
131 /// file.
132 pub game: Option<Game>,
133 /// Gametime duration in milliseconds of the run.
134 #[serde(default)]
135 pub gametime_duration_ms: Option<f64>,
136 /// Gametime sum of best in milliseconds of the run.
137 #[serde(default)]
138 pub gametime_sum_of_best_ms: Option<f64>,
139 /// Ordered history objects of all previous attempts. The first item is the first run recorded
140 /// by the runner's timer into the source file. The last item is the most recent one. This field
141 /// is only nonempty if the source timer records history.
142 pub histories: Option<Vec<RunItemHistories>>,
143 /// Unique ID for identifying the run on splits.io. This can be used to construct a user-facing
144 /// URL or an API-facing one.
145 #[serde(default)]
146 pub id: Option<Box<str>>,
147 /// A screenshot of the timer after a finished run, if it was supplied by the runner. This is
148 /// typically supplied automatically by timers which support auto-uploading runs to splits.io.
149 #[serde(default)]
150 pub image_url: Option<Box<str>>,
151 /// The name of the timer with which the run was recorded. This is typically an all lowercase,
152 /// no-spaces version of the program name.
153 pub program: Box<str>,
154 /// Realtime duration in milliseconds of the run.
155 #[serde(default)]
156 pub realtime_duration_ms: Option<f64>,
157 /// Realtime sum of best in milliseconds of the run.
158 #[serde(default)]
159 pub realtime_sum_of_best_ms: Option<f64>,
160 /// The runner(s) who performed the run, if they claim credit.
161 pub runners: Vec<Runner>,
162 /// The associated segments for the run.
163 pub segments: Vec<Segment>,
164 /// Unique ID for identifying the run on Speedrun.com. This is typically supplied by the runner
165 /// manually.
166 #[serde(default)]
167 pub srdc_id: Option<Box<str>>,
168 /// The time and date at which this run was most recently modified on splits.io (modify events
169 /// include disowning, adding a video or Speedrun.com association, and changing the run's
170 /// game/category). This field conforms to ISO 8601.
171 pub updated_at: Box<str>,
172 /// A URL for a Twitch, YouTube, or Hitbox video which can be used as proof of the run. This is
173 /// supplied by the runner.
174 #[serde(default)]
175 pub video_url: Option<Box<str>>,
176}
177
178/// A Runner is a user who has at least one run tied to their account.
179///
180/// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#runner)
181#[derive(Debug, serde_derive::Deserialize)]
182pub struct Runner {
183 /// The avatar of the user.
184 #[serde(default)]
185 pub avatar: Option<Box<str>>,
186 /// The time and date at which this user first authenticated with splits.io. This field conforms
187 /// to ISO 8601.
188 pub created_at: Box<str>,
189 /// The display name of the user.
190 pub display_name: Option<Box<str>>,
191 /// The unique ID of the user.
192 pub id: Box<str>,
193 /// The splits.io username of the user.
194 pub name: Box<str>,
195 /// The Twitch ID of the user.
196 pub twitch_id: Option<Box<str>>,
197 /// The Twitch name of the user.
198 pub twitch_name: Option<Box<str>>,
199 /// The time and date at which this user was most recently modified on splits.io. This field
200 /// conforms to ISO 8601.
201 pub updated_at: Box<str>,
202}
203
204/// Information about a past attempt of a segment.
205///
206/// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#history)
207#[derive(Debug, serde_derive::Deserialize)]
208pub struct SegmentItemHistories {
209 /// The corresponding attempt number this attempt was.
210 pub attempt_number: u32,
211 /// The gametime duration this attempt took in milliseconds.
212 pub gametime_duration_ms: f64,
213 /// The realtime duration this attempt took in milliseconds.
214 pub realtime_duration_ms: f64,
215}
216
217/// A Segment maps to a single piece of a run, also called a split.
218///
219/// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#segment)
220#[derive(Debug, serde_derive::Deserialize)]
221pub struct Segment {
222 /// Gametime duration in milliseconds of the segment.
223 #[serde(default)]
224 pub gametime_duration_ms: Option<f64>,
225 /// The total elapsed time of the run at the moment when this segment was finished in gametime
226 /// (such that the run's duration is equal to the final split's finish time). Provided in
227 /// milliseconds.
228 #[serde(default)]
229 pub gametime_end_ms: Option<f64>,
230 /// Whether or not this split was the shortest duration the runner has ever gotten on this
231 /// segment in gametime. This field is shorthand for duration == best.
232 pub gametime_gold: bool,
233 /// Whether or not this segment was "reduced" in gametime; that is, had its duration affected by
234 /// previous splits being skipped.
235 pub gametime_reduced: bool,
236 /// The shortest duration the runner has ever gotten on this segment in gametime. Provided in
237 /// milliseconds.
238 #[serde(default)]
239 pub gametime_shortest_duration_ms: Option<f64>,
240 /// Whether or not this split was skipped in gametime -- some timers let the runner skip over a
241 /// split in case they forgot to hit their split button on time. Beware that a skipped split's
242 /// duration is considered 0, and instead is rolled into the following split.
243 pub gametime_skipped: bool,
244 /// The total elapsed time of the run at the moment when this segment was started in gametime.
245 /// Provided in milliseconds.
246 #[serde(default)]
247 pub gametime_start_ms: Option<f64>,
248 /// Ordered history objects of all previous attempts of the segment. The first item is the first
249 /// run recorded by the runner's timer into the source file. The last item is the most recent
250 /// one. This field is only nonempty if the source timer records history.
251 pub histories: Option<Vec<SegmentItemHistories>>,
252 /// Internal ID of the segment.
253 pub id: Uuid,
254 /// Name of the segment. This value is an exact copy of timers' fields.
255 pub name: Box<str>,
256 /// Realtime duration in milliseconds of the segment.
257 pub realtime_duration_ms: f64,
258 /// The total elapsed time of the run at the moment when this segment was finished in realtime
259 /// (such that the run's duration is equal to the final split's finish time). Provided in
260 /// milliseconds.
261 pub realtime_end_ms: f64,
262 /// Whether or not this split was the shortest duration the runner has ever gotten on this
263 /// segment in realtime. This field is shorthand for realtime_duration_ms ==
264 /// realtime_shortest_duration_ms.
265 pub realtime_gold: bool,
266 /// Whether or not this segment was "reduced" in realtime; that is, had its duration affected by
267 /// previous splits being skipped.
268 pub realtime_reduced: bool,
269 /// The shortest duration the runner has ever gotten on this segment in realtime. Provided in
270 /// milliseconds.
271 #[serde(default)]
272 pub realtime_shortest_duration_ms: Option<f64>,
273 /// Whether or not this split was skipped in realtime -- some timers let the runner skip over a
274 /// split in case they forgot to hit their split button on time. Beware that a skipped split's
275 /// duration is considered 0, and instead is rolled into the following split.
276 pub realtime_skipped: bool,
277 /// The total elapsed time of the run at the moment when this segment was started in realtime.
278 /// Provided in milliseconds.
279 pub realtime_start_ms: f64,
280 /// The index of the segment within the run. (This value starts at 0.)
281 pub segment_number: u32,
282}
283
284/// A Race is a live competition between multiple Runners who share a start time for their run.
285///
286/// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#race)
287#[derive(Debug, serde_derive::Deserialize)]
288pub struct Race {
289 /// Any attachments supplied by the race creator for the benefit of other entrants (e.g. for
290 /// randomizers).
291 pub attachments: Vec<Attachment>,
292 /// The category being raced.
293 pub category: Option<Category>,
294 /// Chat messages for the Race. Only present when fetching the Race individually.
295 pub chat_messages: Vec<ChatMessage>,
296 /// The time and date at which this Race was created on splits.io. This field conforms to ISO
297 /// 8601.
298 pub created_at: Box<str>,
299 /// All Entries currently in the Race.
300 pub entries: Vec<Entry>,
301 /// The game being raced.
302 pub game: Option<Game>,
303 /// The unique ID of the Race.
304 pub id: Uuid,
305 /// The token needed to join the race if it's invite-only or secret. Only provided to the owner
306 /// as a response to creation.
307 pub join_token: Option<Box<str>>,
308 /// Any notes associatied with the Race.
309 pub notes: Option<Box<str>>,
310 /// The Runner who created the Race.
311 pub owner: Runner,
312 /// The user-friendly URL to the Race, to be given to a user when necessary.
313 pub path: Box<str>,
314 /// The time and date at which this Race was started on splits.io. This field conforms to ISO
315 /// 8601.
316 pub started_at: Option<Box<str>>,
317 /// The time and date at which this Race was most recently modified on splits.io. This field
318 /// conforms to ISO 8601.
319 pub updated_at: Box<str>,
320 /// The permission set for the Race.
321 pub visibility: Visibility,
322}
323
324/// A file that is attached to a Race.
325///
326/// [API Documentation](https://github.com/glacials/splits-io/blob/master/docs/api.md#attachment)
327#[derive(Debug, serde_derive::Deserialize)]
328pub struct Attachment {
329 /// The unique ID of the attachment.
330 pub id: Uuid,
331 /// The time and date at which this attachment was created on splits.io. This field conforms to ISO 8601.
332 pub created_at: Box<str>,
333 /// The filename of the attachment.
334 pub filename: Box<str>,
335 /// The URL to use in order to download the attachment.
336 pub url: Box<str>,
337}
338
339/// The permission set for a Race.
340#[derive(Copy, Clone, Debug, serde_derive::Deserialize, serde_derive::Serialize)]
341#[serde(rename_all = "snake_case")]
342pub enum Visibility {
343 /// Anyone can join the race.
344 Public,
345 /// An invitation is required in order to join the race.
346 InviteOnly,
347 /// The race can only be viewed by certain users.
348 Secret,
349}