From 5156b34f6193a1e5d939f09050f24d1b3c3d5f3a Mon Sep 17 00:00:00 2001 From: Christopher Serr Date: Wed, 28 Dec 2022 22:36:02 +0100 Subject: [PATCH] Release `v0.3.0` This updates all the dependencies for a `v0.3.0` release. --- .github/workflows/rust.yml | 13 ++++++----- Cargo.toml | 8 +++---- src/game.rs | 14 +++++++---- src/lib.rs | 9 +++---- src/platform/wasm.rs | 2 +- src/race.rs | 48 ++++++++++++++++++++------------------ src/run.rs | 14 +++++++---- 7 files changed, 62 insertions(+), 46 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 1d991e3..0926f2e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -20,7 +20,7 @@ jobs: - i686-unknown-linux-gnu - x86_64-unknown-linux-gnu - i686-pc-windows-msvc - - i686-pc-windows-gnu + # - i686-pc-windows-gnu - x86_64-pc-windows-msvc - x86_64-pc-windows-gnu - x86_64-apple-darwin @@ -42,10 +42,11 @@ jobs: os: windows-latest cargo_dir: '' toolchain: stable - - target: i686-pc-windows-gnu - os: windows-latest - cargo_dir: '' - toolchain: stable-i686-pc-windows-gnu + # The windows crate doesn't work with this target atm. + # - target: i686-pc-windows-gnu + # os: windows-latest + # cargo_dir: '' + # toolchain: stable-i686-pc-windows-gnu - target: x86_64-pc-windows-msvc os: windows-latest cargo_dir: '' @@ -60,7 +61,7 @@ jobs: toolchain: stable steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 - name: Install gcc-multilib if: matrix.target == 'i686-unknown-linux-gnu' run: sudo apt-get update && sudo apt-get install -y --no-install-recommends g++-multilib diff --git a/Cargo.toml b/Cargo.toml index f09ced2..16a62e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "splits-io-api" -version = "0.2.0" +version = "0.3.0" authors = ["Christopher Serr "] edition = "2021" documentation = "https://docs.rs/splits-io-api/" repository = "https://github.com/LiveSplit/splits-io-api" license = "Apache-2.0/MIT" -description = "Bindings to the Splits.io API for Rust." +description = "Bindings to the splits.io API for Rust." readme = "README.md" keywords = ["splits-io", "speedrun", "livesplit", "web", "async"] categories = ["network-programming", "api-bindings"] @@ -23,9 +23,9 @@ include = [ http = "0.2.0" serde = { version = "1.0.99", features = ["derive"] } serde_json = "1.0.40" -snafu = { version = "0.6.0", default-features = false, features = ["std"] } +snafu = { version = "0.7.1", default-features = false, features = ["std"] } url = "2.1.0" -uuid = { version = "0.8.1", default-features = false, features = ["serde"] } +uuid = { version = "1.1.2", default-features = false, features = ["serde"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] hyper = { version = "0.14.1", default-features = false, features = ["tcp", "client", "http2"] } diff --git a/src/game.rs b/src/game.rs index b319f66..f6c48d0 100644 --- a/src/game.rs +++ b/src/game.rs @@ -7,7 +7,7 @@ use crate::{ get_json, platform::Body, wrapper::{ContainsCategories, ContainsGame, ContainsGames, ContainsRunners, ContainsRuns}, - Category, Client, Error, Game, Run, Runner, UnidentifiableResource, + Category, Client, Error, Game, Run, Runner, UnidentifiableResourceSnafu, }; use http::Request; use snafu::OptionExt; @@ -28,7 +28,9 @@ impl Game { pub async fn categories(&self, client: &Client) -> Result, Error> { get_categories( client, - self.shortname.as_ref().context(UnidentifiableResource)?, + self.shortname + .as_ref() + .context(UnidentifiableResourceSnafu)?, ) .await } @@ -37,7 +39,9 @@ impl Game { pub async fn runs(&self, client: &Client) -> Result, Error> { get_runs( client, - self.shortname.as_ref().context(UnidentifiableResource)?, + self.shortname + .as_ref() + .context(UnidentifiableResourceSnafu)?, ) .await } @@ -46,7 +50,9 @@ impl Game { pub async fn runners(&self, client: &Client) -> Result, Error> { get_runners( client, - self.shortname.as_ref().context(UnidentifiableResource)?, + self.shortname + .as_ref() + .context(UnidentifiableResourceSnafu)?, ) .await } diff --git a/src/lib.rs b/src/lib.rs index 6c44bf4..183167e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -147,8 +147,7 @@ async fn get_response_unchecked( } } - let response = client.client.request(request).await.context(Download)?; - Ok(response) + client.client.request(request).await.context(DownloadSnafu) } async fn get_response(client: &Client, request: Request) -> Result, Error> { @@ -173,8 +172,10 @@ async fn get_json( request: Request, ) -> Result { let response = get_response(client, request).await?; - let reader = recv_reader(response.into_body()).await.context(Download)?; - serde_json::from_reader(reader).context(Json) + let reader = recv_reader(response.into_body()) + .await + .context(DownloadSnafu)?; + serde_json::from_reader(reader).context(JsonSnafu) } #[derive(serde::Deserialize)] diff --git a/src/platform/wasm.rs b/src/platform/wasm.rs index f80329f..4a9af57 100644 --- a/src/platform/wasm.rs +++ b/src/platform/wasm.rs @@ -57,7 +57,7 @@ impl Client { } pub async fn request(&self, request: Request) -> Result, Error> { - let window = window().context(NoWindow)?; + let window = window().context(NoWindowSnafu)?; let ( Parts { diff --git a/src/race.rs b/src/race.rs index c9b11a0..4b813f5 100644 --- a/src/race.rs +++ b/src/race.rs @@ -9,7 +9,7 @@ use crate::{ ContainsChatMessage, ContainsChatMessages, ContainsEntries, ContainsEntry, ContainsRace, ContainsRaces, }, - Attachment, ChatMessage, Client, Download, Entry, Error, Race, Visibility, + Attachment, ChatMessage, Client, DownloadSnafu, Entry, Error, Race, Visibility, }; use http::{header::CONTENT_TYPE, Request}; use snafu::ResultExt; @@ -121,7 +121,9 @@ impl Attachment { ) .await?; - recv_bytes(response.into_body()).await.context(Download) + recv_bytes(response.into_body()) + .await + .context(DownloadSnafu) } } @@ -145,7 +147,7 @@ pub async fn get(client: &Client, id: Uuid) -> Result { let mut url = Url::parse("https://splits.io/api/v4/races").unwrap(); url.path_segments_mut() .unwrap() - .push(id.to_hyphenated().encode_lower(&mut Uuid::encode_buffer())); + .push(id.hyphenated().encode_lower(&mut Uuid::encode_buffer())); let ContainsRace { race } = get_json( client, @@ -247,7 +249,7 @@ pub async fn update( let mut url = Url::parse("https://splits.io/api/v4/races").unwrap(); url.path_segments_mut() .unwrap() - .push(id.to_hyphenated().encode_lower(&mut Uuid::encode_buffer())); + .push(id.hyphenated().encode_lower(&mut Uuid::encode_buffer())); let ContainsRace { race } = get_json( client, @@ -265,7 +267,7 @@ pub async fn update( pub async fn get_entries(client: &Client, id: Uuid) -> Result, Error> { let mut url = Url::parse("https://splits.io/api/v4/races").unwrap(); url.path_segments_mut().unwrap().extend(&[ - id.to_hyphenated().encode_lower(&mut Uuid::encode_buffer()), + id.hyphenated().encode_lower(&mut Uuid::encode_buffer()), "entries", ]); @@ -282,7 +284,7 @@ pub async fn get_entries(client: &Client, id: Uuid) -> Result, Error> pub async fn get_entry(client: &Client, id: Uuid) -> Result { let mut url = Url::parse("https://splits.io/api/v4/races").unwrap(); url.path_segments_mut().unwrap().extend(&[ - id.to_hyphenated().encode_lower(&mut Uuid::encode_buffer()), + id.hyphenated().encode_lower(&mut Uuid::encode_buffer()), "entry", ]); @@ -326,7 +328,7 @@ pub async fn join( let mut url = Url::parse("https://splits.io/api/v4/races").unwrap(); url.path_segments_mut().unwrap().extend(&[ race_id - .to_hyphenated() + .hyphenated() .encode_lower(&mut Uuid::encode_buffer()), "entries", ]); @@ -357,11 +359,11 @@ pub async fn leave(client: &Client, race_id: Uuid, entry_id: Uuid) -> Result<(), let mut url = Url::parse("https://splits.io/api/v4/races").unwrap(); url.path_segments_mut().unwrap().extend(&[ race_id - .to_hyphenated() + .hyphenated() .encode_lower(&mut Uuid::encode_buffer()), "entries", entry_id - .to_hyphenated() + .hyphenated() .encode_lower(&mut Uuid::encode_buffer()), ]); @@ -399,11 +401,11 @@ pub async fn ready_up(client: &Client, race_id: Uuid, entry_id: Uuid) -> Result< let mut url = Url::parse("https://splits.io/api/v4/races").unwrap(); url.path_segments_mut().unwrap().extend(&[ race_id - .to_hyphenated() + .hyphenated() .encode_lower(&mut Uuid::encode_buffer()), "entries", entry_id - .to_hyphenated() + .hyphenated() .encode_lower(&mut Uuid::encode_buffer()), ]); @@ -431,11 +433,11 @@ pub async fn unready(client: &Client, race_id: Uuid, entry_id: Uuid) -> Result Result Resu let mut url = Url::parse("https://splits.io/api/v4/races").unwrap(); url.path_segments_mut().unwrap().extend(&[ race_id - .to_hyphenated() + .hyphenated() .encode_lower(&mut Uuid::encode_buffer()), "entries", entry_id - .to_hyphenated() + .hyphenated() .encode_lower(&mut Uuid::encode_buffer()), ]); @@ -523,11 +525,11 @@ pub async fn forfeit(client: &Client, race_id: Uuid, entry_id: Uuid) -> Result Res let mut url = Url::parse("https://splits.io/api/v4/races").unwrap(); url.path_segments_mut().unwrap().extend(&[ race_id - .to_hyphenated() + .hyphenated() .encode_lower(&mut Uuid::encode_buffer()), "entries", entry_id - .to_hyphenated() + .hyphenated() .encode_lower(&mut Uuid::encode_buffer()), ]); @@ -584,7 +586,7 @@ pub async fn undo_forfeit(client: &Client, race_id: Uuid, entry_id: Uuid) -> Res pub async fn get_chat(client: &Client, id: Uuid) -> Result, Error> { let mut url = Url::parse("https://splits.io/api/v4/races").unwrap(); url.path_segments_mut().unwrap().extend(&[ - id.to_hyphenated().encode_lower(&mut Uuid::encode_buffer()), + id.hyphenated().encode_lower(&mut Uuid::encode_buffer()), "chat", ]); @@ -615,7 +617,7 @@ pub async fn send_chat_message( ) -> Result { let mut url = Url::parse("https://splits.io/api/v4/races").unwrap(); url.path_segments_mut().unwrap().extend(&[ - id.to_hyphenated().encode_lower(&mut Uuid::encode_buffer()), + id.hyphenated().encode_lower(&mut Uuid::encode_buffer()), "chat", ]); diff --git a/src/run.rs b/src/run.rs index ce12e59..66c411c 100644 --- a/src/run.rs +++ b/src/run.rs @@ -7,7 +7,7 @@ use crate::{ platform::{recv_bytes, Body}, schema::Run, wrapper::ContainsRun, - Client, Download, Error, UnidentifiableResource, + Client, DownloadSnafu, Error, UnidentifiableResourceSnafu, }; use http::{header::CONTENT_TYPE, Request}; use snafu::{OptionExt, ResultExt}; @@ -20,7 +20,11 @@ use url::Url; impl Run { /// Downloads the splits for the Run. pub async fn download(&self, client: &Client) -> Result, Error> { - self::download(client, self.id.as_ref().context(UnidentifiableResource)?).await + self::download( + client, + self.id.as_ref().context(UnidentifiableResourceSnafu)?, + ) + .await } /// Gets a Run. @@ -46,7 +50,7 @@ impl Run { let mut url = Url::parse("https://splits.io").unwrap(); url.path_segments_mut() .unwrap() - .push(self.id.as_ref().context(UnidentifiableResource)?); + .push(self.id.as_ref().context(UnidentifiableResourceSnafu)?); Ok(url) } } @@ -65,7 +69,9 @@ pub async fn download(client: &Client, id: &str) -> Result