From c6d562a1900d1c7e3dd1d95d6577d952d7457c25 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 07:11:47 +0000 Subject: [PATCH] Update snafu requirement from 0.7.0 to 0.8.0 Updates the requirements on [snafu](https://github.com/shepmaster/snafu) to permit the latest version. - [Changelog](https://github.com/shepmaster/snafu/blob/main/CHANGELOG.md) - [Commits](https://github.com/shepmaster/snafu/compare/0.7.0...0.8.0) --- updated-dependencies: - dependency-name: snafu dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 4 +-- crates/livesplit-auto-splitting/Cargo.toml | 2 +- src/networking/splits_io.rs | 37 ++++++++++++++++------ src/platform/mod.rs | 1 + src/platform/wasm/unknown/mod.rs | 1 + src/platform/wasm/web/mod.rs | 1 + 6 files changed, 33 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b495f719..8d98559d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,7 @@ serde_json = { version = "1.0.60", default-features = false, features = [ "alloc", ] } smallstr = { version = "0.3.0", default-features = false } -snafu = { version = "0.7.0", default-features = false } +snafu = { version = "0.8.0", default-features = false } unicase = "2.6.0" # std @@ -83,7 +83,7 @@ tiny-skia = { version = "0.11.1", default-features = false, features = [ tiny-skia-path = { version = "0.11.1", default-features = false, optional = true } # Networking -splits-io-api = { version = "0.3.0", optional = true } +splits-io-api = { git = "https://github.com/LiveSplit/splits-io-api", branch = "switch-to-reqwest", optional = true } # Auto Splitting livesplit-auto-splitting = { path = "crates/livesplit-auto-splitting", version = "0.1.0", optional = true } diff --git a/crates/livesplit-auto-splitting/Cargo.toml b/crates/livesplit-auto-splitting/Cargo.toml index bfe2787f..b0cfab70 100644 --- a/crates/livesplit-auto-splitting/Cargo.toml +++ b/crates/livesplit-auto-splitting/Cargo.toml @@ -18,7 +18,7 @@ indexmap = "2.0.2" proc-maps = { version = "0.3.0", default-features = false } read-process-memory = { version = "0.1.4", default-features = false } slotmap = { version = "1.0.2", default-features = false } -snafu = "0.7.0" +snafu = "0.8.0" sysinfo = { version = "0.30.0", default-features = false, features = [ "multithread", ] } diff --git a/src/networking/splits_io.rs b/src/networking/splits_io.rs index 7905aed6..b00e017a 100644 --- a/src/networking/splits_io.rs +++ b/src/networking/splits_io.rs @@ -10,9 +10,9 @@ use crate::{ }, Run, Timer, }; -use snafu::ResultExt; +use snafu::{OptionExt, ResultExt}; -pub use api::{run::UploadedRun, Client, Error as UploadError}; +pub use api::{run::UploadedRun, Client, Error as ApiError}; pub use splits_io_api as api; /// Describes an error that happened when downloading a run from Splits.io. This @@ -33,6 +33,21 @@ pub enum DownloadError { }, } +/// Describes an error that happened when uploading a run to Splits.io. This may +/// either be because the upload itself had a problem or because the run itself +/// couldn't be saved. +#[derive(Debug, snafu::Snafu)] +#[snafu(context(suffix(false)))] +pub enum UploadError { + /// Failed to upload the run. + Upload { + /// The underlying upload error. + source: api::Error, + }, + /// Failed to save the run. + Save, +} + /// Asynchronously downloads a run from Splits.io based on its Splits.io ID. The /// run automatically gets parsed into a Run object. pub async fn download_run( @@ -48,10 +63,11 @@ pub async fn download_run( /// the uploaded run and its claim token gets returned when the run was /// successfully uploaded. pub async fn upload_run(client: &Client, run: &Run) -> Result { - api::run::upload_lazy(client, |writer| { - saver::livesplit::save_run(run, IoWrite(writer)) - }) - .await + let mut buf = Vec::new(); + saver::livesplit::save_run(run, IoWrite(&mut buf)) + .ok() + .context(Save)?; + api::run::upload(client, buf).await.context(Upload) } /// Asynchronously uploads the run of the timer provided to Splits.io. If there @@ -59,8 +75,9 @@ pub async fn upload_run(client: &Client, run: &Run) -> Result Result { - api::run::upload_lazy(client, |writer| { - saver::livesplit::save_timer(timer, IoWrite(writer)) - }) - .await + let mut buf = Vec::new(); + saver::livesplit::save_timer(timer, IoWrite(&mut buf)) + .ok() + .context(Save)?; + api::run::upload(client, buf).await.context(Upload) } diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 6c7af1a8..7130c51d 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -30,6 +30,7 @@ pub mod math; pub use std::path; #[cfg(not(feature = "std"))] +#[allow(unused)] pub mod path { pub use alloc::string::String as PathBuf; pub use str as Path; diff --git a/src/platform/wasm/unknown/mod.rs b/src/platform/wasm/unknown/mod.rs index e848ff91..1a4f81b3 100644 --- a/src/platform/wasm/unknown/mod.rs +++ b/src/platform/wasm/unknown/mod.rs @@ -1,4 +1,5 @@ mod time; pub use self::time::*; +#[allow(unused)] pub use std::sync::RwLock; diff --git a/src/platform/wasm/web/mod.rs b/src/platform/wasm/web/mod.rs index ff439fae..a0a8a223 100644 --- a/src/platform/wasm/web/mod.rs +++ b/src/platform/wasm/web/mod.rs @@ -1,3 +1,4 @@ mod time; pub use self::time::*; +#[allow(unused)] pub use std::sync::RwLock;