Skip to content

Commit

Permalink
Update snafu requirement from 0.7.0 to 0.8.0
Browse files Browse the repository at this point in the history
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](shepmaster/snafu@0.7.0...0.8.0)

---
updated-dependencies:
- dependency-name: snafu
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
  • Loading branch information
dependabot[bot] authored and CryZe committed Jan 18, 2024
1 parent d099838 commit c6d562a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion crates/livesplit-auto-splitting/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
] }
Expand Down
37 changes: 27 additions & 10 deletions src/networking/splits_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -48,19 +63,21 @@ 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<UploadedRun, UploadError> {
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
/// is an attempt in progress, a copy that has been reset will be uploaded. An
/// object representing the ID of the uploaded run and its claim token gets
/// returned when the run was successfully uploaded.
pub async fn upload_timer(client: &Client, timer: &Timer) -> Result<UploadedRun, UploadError> {
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)
}
1 change: 1 addition & 0 deletions src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/platform/wasm/unknown/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod time;

pub use self::time::*;
#[allow(unused)]
pub use std::sync::RwLock;
1 change: 1 addition & 0 deletions src/platform/wasm/web/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod time;
pub use self::time::*;
#[allow(unused)]
pub use std::sync::RwLock;

0 comments on commit c6d562a

Please sign in to comment.