Skip to content

Commit

Permalink
Migrate from failure to anyhow (#31)
Browse files Browse the repository at this point in the history
Failure was
[deprecated](rust-lang-deprecated/failure#347).
  • Loading branch information
harrynull authored Jun 20, 2023
1 parent 0ecf07a commit dcc390b
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 30 deletions.
30 changes: 7 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
license = "GPL-3.0-or-later"

[dependencies]
failure = "0.1.8"
anyhow = "1.0"
clap = { version = "4.0.14", features = ["derive"] }
tokio = { version = "1.15", features = ["full"] }
tokio-util = { version = "0.7.4", features = ["codec"] }
Expand Down
3 changes: 2 additions & 1 deletion src/capture/audio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use bytes::Bytes;
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use cpal::{SampleFormat, Stream};

use anyhow::anyhow;
use std::sync::mpsc::Sender;
use std::sync::Arc;
use tokio::sync::Mutex;
Expand Down Expand Up @@ -127,7 +128,7 @@ impl AudioCapture {
None,
)?,
_ => {
return Err(failure::err_msg("unsupported sample format"));
return Err(anyhow!("unsupported sample format"));
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/capture/macos/display.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::capture::DisplayInfo;
use crate::result::Result;
use failure::format_err;
use anyhow::format_err;

use super::ffi::*;

Expand Down
4 changes: 2 additions & 2 deletions src/capture/macos/macos_capture.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::sync::Arc;
use std::time::Duration;
use std::{ptr, slice};
use std::sync::Arc;

use anyhow::format_err;
use async_trait::async_trait;
use block::{Block, ConcreteBlock};
use failure::format_err;
use libc::c_void;
use tokio::sync::mpsc::Receiver;
use tokio::sync::mpsc::Sender;
Expand Down
2 changes: 1 addition & 1 deletion src/inputs/parse_key.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::Result;
use failure::format_err;
use anyhow::format_err;

pub trait FromJsKey {
/// convert from KeyboardEvent.code
Expand Down
2 changes: 1 addition & 1 deletion src/result.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
use failure::Error;
use anyhow::Error;

pub type Result<T> = std::result::Result<T, Error>;

0 comments on commit dcc390b

Please sign in to comment.