Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 4fcce82

Browse files
authored
Merge pull request #41 from CryZe/deps-for-0-3
Release `v0.3.0`
2 parents 967753f + 5156b34 commit 4fcce82

File tree

7 files changed

+62
-46
lines changed

7 files changed

+62
-46
lines changed

.github/workflows/rust.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- i686-unknown-linux-gnu
2121
- x86_64-unknown-linux-gnu
2222
- i686-pc-windows-msvc
23-
- i686-pc-windows-gnu
23+
# - i686-pc-windows-gnu
2424
- x86_64-pc-windows-msvc
2525
- x86_64-pc-windows-gnu
2626
- x86_64-apple-darwin
@@ -42,10 +42,11 @@ jobs:
4242
os: windows-latest
4343
cargo_dir: ''
4444
toolchain: stable
45-
- target: i686-pc-windows-gnu
46-
os: windows-latest
47-
cargo_dir: ''
48-
toolchain: stable-i686-pc-windows-gnu
45+
# The windows crate doesn't work with this target atm.
46+
# - target: i686-pc-windows-gnu
47+
# os: windows-latest
48+
# cargo_dir: ''
49+
# toolchain: stable-i686-pc-windows-gnu
4950
- target: x86_64-pc-windows-msvc
5051
os: windows-latest
5152
cargo_dir: ''
@@ -60,7 +61,7 @@ jobs:
6061
toolchain: stable
6162

6263
steps:
63-
- uses: actions/checkout@v1
64+
- uses: actions/checkout@v3
6465
- name: Install gcc-multilib
6566
if: matrix.target == 'i686-unknown-linux-gnu'
6667
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends g++-multilib

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
name = "splits-io-api"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
authors = ["Christopher Serr <christopher.serr@gmail.com>"]
55
edition = "2021"
66
documentation = "https://docs.rs/splits-io-api/"
77
repository = "https://github.com/LiveSplit/splits-io-api"
88
license = "Apache-2.0/MIT"
9-
description = "Bindings to the Splits.io API for Rust."
9+
description = "Bindings to the splits.io API for Rust."
1010
readme = "README.md"
1111
keywords = ["splits-io", "speedrun", "livesplit", "web", "async"]
1212
categories = ["network-programming", "api-bindings"]
@@ -23,9 +23,9 @@ include = [
2323
http = "0.2.0"
2424
serde = { version = "1.0.99", features = ["derive"] }
2525
serde_json = "1.0.40"
26-
snafu = { version = "0.6.0", default-features = false, features = ["std"] }
26+
snafu = { version = "0.7.1", default-features = false, features = ["std"] }
2727
url = "2.1.0"
28-
uuid = { version = "0.8.1", default-features = false, features = ["serde"] }
28+
uuid = { version = "1.1.2", default-features = false, features = ["serde"] }
2929

3030
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
3131
hyper = { version = "0.14.1", default-features = false, features = ["tcp", "client", "http2"] }

src/game.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
get_json,
88
platform::Body,
99
wrapper::{ContainsCategories, ContainsGame, ContainsGames, ContainsRunners, ContainsRuns},
10-
Category, Client, Error, Game, Run, Runner, UnidentifiableResource,
10+
Category, Client, Error, Game, Run, Runner, UnidentifiableResourceSnafu,
1111
};
1212
use http::Request;
1313
use snafu::OptionExt;
@@ -28,7 +28,9 @@ impl Game {
2828
pub async fn categories(&self, client: &Client) -> Result<Vec<Category>, Error> {
2929
get_categories(
3030
client,
31-
self.shortname.as_ref().context(UnidentifiableResource)?,
31+
self.shortname
32+
.as_ref()
33+
.context(UnidentifiableResourceSnafu)?,
3234
)
3335
.await
3436
}
@@ -37,7 +39,9 @@ impl Game {
3739
pub async fn runs(&self, client: &Client) -> Result<Vec<Run>, Error> {
3840
get_runs(
3941
client,
40-
self.shortname.as_ref().context(UnidentifiableResource)?,
42+
self.shortname
43+
.as_ref()
44+
.context(UnidentifiableResourceSnafu)?,
4145
)
4246
.await
4347
}
@@ -46,7 +50,9 @@ impl Game {
4650
pub async fn runners(&self, client: &Client) -> Result<Vec<Runner>, Error> {
4751
get_runners(
4852
client,
49-
self.shortname.as_ref().context(UnidentifiableResource)?,
53+
self.shortname
54+
.as_ref()
55+
.context(UnidentifiableResourceSnafu)?,
5056
)
5157
.await
5258
}

src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ async fn get_response_unchecked(
147147
}
148148
}
149149

150-
let response = client.client.request(request).await.context(Download)?;
151-
Ok(response)
150+
client.client.request(request).await.context(DownloadSnafu)
152151
}
153152

154153
async fn get_response(client: &Client, request: Request<Body>) -> Result<Response<Body>, Error> {
@@ -173,8 +172,10 @@ async fn get_json<T: serde::de::DeserializeOwned>(
173172
request: Request<Body>,
174173
) -> Result<T, Error> {
175174
let response = get_response(client, request).await?;
176-
let reader = recv_reader(response.into_body()).await.context(Download)?;
177-
serde_json::from_reader(reader).context(Json)
175+
let reader = recv_reader(response.into_body())
176+
.await
177+
.context(DownloadSnafu)?;
178+
serde_json::from_reader(reader).context(JsonSnafu)
178179
}
179180

180181
#[derive(serde::Deserialize)]

src/platform/wasm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Client {
5757
}
5858

5959
pub async fn request(&self, request: Request<Body>) -> Result<Response<Body>, Error> {
60-
let window = window().context(NoWindow)?;
60+
let window = window().context(NoWindowSnafu)?;
6161

6262
let (
6363
Parts {

src/race.rs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
ContainsChatMessage, ContainsChatMessages, ContainsEntries, ContainsEntry, ContainsRace,
1010
ContainsRaces,
1111
},
12-
Attachment, ChatMessage, Client, Download, Entry, Error, Race, Visibility,
12+
Attachment, ChatMessage, Client, DownloadSnafu, Entry, Error, Race, Visibility,
1313
};
1414
use http::{header::CONTENT_TYPE, Request};
1515
use snafu::ResultExt;
@@ -121,7 +121,9 @@ impl Attachment {
121121
)
122122
.await?;
123123

124-
recv_bytes(response.into_body()).await.context(Download)
124+
recv_bytes(response.into_body())
125+
.await
126+
.context(DownloadSnafu)
125127
}
126128
}
127129

@@ -145,7 +147,7 @@ pub async fn get(client: &Client, id: Uuid) -> Result<Race, Error> {
145147
let mut url = Url::parse("https://splits.io/api/v4/races").unwrap();
146148
url.path_segments_mut()
147149
.unwrap()
148-
.push(id.to_hyphenated().encode_lower(&mut Uuid::encode_buffer()));
150+
.push(id.hyphenated().encode_lower(&mut Uuid::encode_buffer()));
149151

150152
let ContainsRace { race } = get_json(
151153
client,
@@ -247,7 +249,7 @@ pub async fn update(
247249
let mut url = Url::parse("https://splits.io/api/v4/races").unwrap();
248250
url.path_segments_mut()
249251
.unwrap()
250-
.push(id.to_hyphenated().encode_lower(&mut Uuid::encode_buffer()));
252+
.push(id.hyphenated().encode_lower(&mut Uuid::encode_buffer()));
251253

252254
let ContainsRace { race } = get_json(
253255
client,
@@ -265,7 +267,7 @@ pub async fn update(
265267
pub async fn get_entries(client: &Client, id: Uuid) -> Result<Vec<Entry>, Error> {
266268
let mut url = Url::parse("https://splits.io/api/v4/races").unwrap();
267269
url.path_segments_mut().unwrap().extend(&[
268-
id.to_hyphenated().encode_lower(&mut Uuid::encode_buffer()),
270+
id.hyphenated().encode_lower(&mut Uuid::encode_buffer()),
269271
"entries",
270272
]);
271273

@@ -282,7 +284,7 @@ pub async fn get_entries(client: &Client, id: Uuid) -> Result<Vec<Entry>, Error>
282284
pub async fn get_entry(client: &Client, id: Uuid) -> Result<Entry, Error> {
283285
let mut url = Url::parse("https://splits.io/api/v4/races").unwrap();
284286
url.path_segments_mut().unwrap().extend(&[
285-
id.to_hyphenated().encode_lower(&mut Uuid::encode_buffer()),
287+
id.hyphenated().encode_lower(&mut Uuid::encode_buffer()),
286288
"entry",
287289
]);
288290

@@ -326,7 +328,7 @@ pub async fn join(
326328
let mut url = Url::parse("https://splits.io/api/v4/races").unwrap();
327329
url.path_segments_mut().unwrap().extend(&[
328330
race_id
329-
.to_hyphenated()
331+
.hyphenated()
330332
.encode_lower(&mut Uuid::encode_buffer()),
331333
"entries",
332334
]);
@@ -357,11 +359,11 @@ pub async fn leave(client: &Client, race_id: Uuid, entry_id: Uuid) -> Result<(),
357359
let mut url = Url::parse("https://splits.io/api/v4/races").unwrap();
358360
url.path_segments_mut().unwrap().extend(&[
359361
race_id
360-
.to_hyphenated()
362+
.hyphenated()
361363
.encode_lower(&mut Uuid::encode_buffer()),
362364
"entries",
363365
entry_id
364-
.to_hyphenated()
366+
.hyphenated()
365367
.encode_lower(&mut Uuid::encode_buffer()),
366368
]);
367369

@@ -399,11 +401,11 @@ pub async fn ready_up(client: &Client, race_id: Uuid, entry_id: Uuid) -> Result<
399401
let mut url = Url::parse("https://splits.io/api/v4/races").unwrap();
400402
url.path_segments_mut().unwrap().extend(&[
401403
race_id
402-
.to_hyphenated()
404+
.hyphenated()
403405
.encode_lower(&mut Uuid::encode_buffer()),
404406
"entries",
405407
entry_id
406-
.to_hyphenated()
408+
.hyphenated()
407409
.encode_lower(&mut Uuid::encode_buffer()),
408410
]);
409411

@@ -431,11 +433,11 @@ pub async fn unready(client: &Client, race_id: Uuid, entry_id: Uuid) -> Result<E
431433
let mut url = Url::parse("https://splits.io/api/v4/races").unwrap();
432434
url.path_segments_mut().unwrap().extend(&[
433435
race_id
434-
.to_hyphenated()
436+
.hyphenated()
435437
.encode_lower(&mut Uuid::encode_buffer()),
436438
"entries",
437439
entry_id
438-
.to_hyphenated()
440+
.hyphenated()
439441
.encode_lower(&mut Uuid::encode_buffer()),
440442
]);
441443

@@ -461,11 +463,11 @@ pub async fn finish(client: &Client, race_id: Uuid, entry_id: Uuid) -> Result<En
461463
let mut url = Url::parse("https://splits.io/api/v4/races").unwrap();
462464
url.path_segments_mut().unwrap().extend(&[
463465
race_id
464-
.to_hyphenated()
466+
.hyphenated()
465467
.encode_lower(&mut Uuid::encode_buffer()),
466468
"entries",
467469
entry_id
468-
.to_hyphenated()
470+
.hyphenated()
469471
.encode_lower(&mut Uuid::encode_buffer()),
470472
]);
471473

@@ -493,11 +495,11 @@ pub async fn undo_finish(client: &Client, race_id: Uuid, entry_id: Uuid) -> Resu
493495
let mut url = Url::parse("https://splits.io/api/v4/races").unwrap();
494496
url.path_segments_mut().unwrap().extend(&[
495497
race_id
496-
.to_hyphenated()
498+
.hyphenated()
497499
.encode_lower(&mut Uuid::encode_buffer()),
498500
"entries",
499501
entry_id
500-
.to_hyphenated()
502+
.hyphenated()
501503
.encode_lower(&mut Uuid::encode_buffer()),
502504
]);
503505

@@ -523,11 +525,11 @@ pub async fn forfeit(client: &Client, race_id: Uuid, entry_id: Uuid) -> Result<E
523525
let mut url = Url::parse("https://splits.io/api/v4/races").unwrap();
524526
url.path_segments_mut().unwrap().extend(&[
525527
race_id
526-
.to_hyphenated()
528+
.hyphenated()
527529
.encode_lower(&mut Uuid::encode_buffer()),
528530
"entries",
529531
entry_id
530-
.to_hyphenated()
532+
.hyphenated()
531533
.encode_lower(&mut Uuid::encode_buffer()),
532534
]);
533535

@@ -555,11 +557,11 @@ pub async fn undo_forfeit(client: &Client, race_id: Uuid, entry_id: Uuid) -> Res
555557
let mut url = Url::parse("https://splits.io/api/v4/races").unwrap();
556558
url.path_segments_mut().unwrap().extend(&[
557559
race_id
558-
.to_hyphenated()
560+
.hyphenated()
559561
.encode_lower(&mut Uuid::encode_buffer()),
560562
"entries",
561563
entry_id
562-
.to_hyphenated()
564+
.hyphenated()
563565
.encode_lower(&mut Uuid::encode_buffer()),
564566
]);
565567

@@ -584,7 +586,7 @@ pub async fn undo_forfeit(client: &Client, race_id: Uuid, entry_id: Uuid) -> Res
584586
pub async fn get_chat(client: &Client, id: Uuid) -> Result<Vec<ChatMessage>, Error> {
585587
let mut url = Url::parse("https://splits.io/api/v4/races").unwrap();
586588
url.path_segments_mut().unwrap().extend(&[
587-
id.to_hyphenated().encode_lower(&mut Uuid::encode_buffer()),
589+
id.hyphenated().encode_lower(&mut Uuid::encode_buffer()),
588590
"chat",
589591
]);
590592

@@ -615,7 +617,7 @@ pub async fn send_chat_message(
615617
) -> Result<ChatMessage, Error> {
616618
let mut url = Url::parse("https://splits.io/api/v4/races").unwrap();
617619
url.path_segments_mut().unwrap().extend(&[
618-
id.to_hyphenated().encode_lower(&mut Uuid::encode_buffer()),
620+
id.hyphenated().encode_lower(&mut Uuid::encode_buffer()),
619621
"chat",
620622
]);
621623

src/run.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
platform::{recv_bytes, Body},
88
schema::Run,
99
wrapper::ContainsRun,
10-
Client, Download, Error, UnidentifiableResource,
10+
Client, DownloadSnafu, Error, UnidentifiableResourceSnafu,
1111
};
1212
use http::{header::CONTENT_TYPE, Request};
1313
use snafu::{OptionExt, ResultExt};
@@ -20,7 +20,11 @@ use url::Url;
2020
impl Run {
2121
/// Downloads the splits for the Run.
2222
pub async fn download(&self, client: &Client) -> Result<impl Deref<Target = [u8]>, Error> {
23-
self::download(client, self.id.as_ref().context(UnidentifiableResource)?).await
23+
self::download(
24+
client,
25+
self.id.as_ref().context(UnidentifiableResourceSnafu)?,
26+
)
27+
.await
2428
}
2529

2630
/// Gets a Run.
@@ -46,7 +50,7 @@ impl Run {
4650
let mut url = Url::parse("https://splits.io").unwrap();
4751
url.path_segments_mut()
4852
.unwrap()
49-
.push(self.id.as_ref().context(UnidentifiableResource)?);
53+
.push(self.id.as_ref().context(UnidentifiableResourceSnafu)?);
5054
Ok(url)
5155
}
5256
}
@@ -65,7 +69,9 @@ pub async fn download(client: &Client, id: &str) -> Result<impl Deref<Target = [
6569
)
6670
.await?;
6771

68-
recv_bytes(response.into_body()).await.context(Download)
72+
recv_bytes(response.into_body())
73+
.await
74+
.context(DownloadSnafu)
6975
}
7076

7177
/// Gets a Run.

0 commit comments

Comments
 (0)