mirror of
https://github.com/arabianq/pipewire-soundpad.git
synced 2026-06-19 12:13:32 +00:00
refactor: replace all rust Result with anyhow::Result (#103)
This commit is contained in:
committed by
GitHub
parent
9b70bcd69d
commit
dc1ecc81ea
+4
-5
@@ -1,9 +1,10 @@
|
||||
use anyhow::{Result, anyhow};
|
||||
use clap::{Parser, Subcommand};
|
||||
use pwsp::{
|
||||
types::socket::Request,
|
||||
utils::daemon::{make_request, wait_for_daemon},
|
||||
};
|
||||
use std::{error::Error, path::PathBuf};
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
@@ -146,7 +147,7 @@ enum SetCommands {
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn Error>> {
|
||||
async fn main() -> Result<()> {
|
||||
let cli = Cli::parse();
|
||||
|
||||
wait_for_daemon().await?;
|
||||
@@ -204,9 +205,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
},
|
||||
};
|
||||
|
||||
let response = make_request(request)
|
||||
.await
|
||||
.map_err(|e| e as Box<dyn Error>)?;
|
||||
let response = make_request(request).await.map_err(|e| anyhow!(e))?;
|
||||
println!("{} : {}", response.status, response.message);
|
||||
|
||||
Ok(())
|
||||
|
||||
+5
-4
@@ -1,3 +1,4 @@
|
||||
use anyhow::{Result, anyhow};
|
||||
use pwsp::{
|
||||
types::socket::{MAX_MESSAGE_SIZE, Request, Response},
|
||||
utils::{
|
||||
@@ -11,7 +12,7 @@ use pwsp::{
|
||||
},
|
||||
};
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::{error::Error, fs, time::Duration};
|
||||
use std::{fs, time::Duration};
|
||||
use tokio::{
|
||||
io::{AsyncReadExt, AsyncWriteExt},
|
||||
net::UnixListener,
|
||||
@@ -19,11 +20,11 @@ use tokio::{
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn Error>> {
|
||||
async fn main() -> Result<()> {
|
||||
create_runtime_dir()?;
|
||||
|
||||
if is_daemon_running()? {
|
||||
return Err("Another instance is already running.".into());
|
||||
return Err(anyhow!("Another instance is already running."));
|
||||
}
|
||||
|
||||
get_daemon_config(); // Initialize daemon config
|
||||
@@ -76,7 +77,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn commands_loop(listener: UnixListener) -> Result<(), Box<dyn Error>> {
|
||||
async fn commands_loop(listener: UnixListener) -> Result<()> {
|
||||
loop {
|
||||
let (mut stream, _addr) = listener.accept().await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user