relay: performed code clean up and optimisation with clippy

This commit is contained in:
Patryk Hegenberg 2024-04-14 23:02:41 +02:00
parent d87aa69964
commit 6a862648e7
3 changed files with 16 additions and 10 deletions

View file

@ -59,6 +59,12 @@ pub enum Commands {
},
}
impl Default for Args {
fn default() -> Self {
Self::new()
}
}
impl Args {
pub fn new() -> Self {
Self::parse()
@ -68,25 +74,25 @@ impl Args {
// client: Client,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
match &self.command {
Some(Commands::Send { relay, file }) => {
Some(Commands::Send { relay: _, file }) => {
sender::send_info(file.as_deref().unwrap_or("test.txt")).await?;
}
Some(Commands::Receive {
relay,
overwrite,
relay: _,
overwrite: _,
name,
}) => {
let transfer_name = name.as_deref().unwrap_or("None");
receiver::download_info(transfer_name).await?
}
Some(Commands::Serve { port }) => {
Some(Commands::Serve { port: _ }) => {
http_server::start_server().await;
}
Some(Commands::Config {
path,
show,
edit,
reset,
path: _,
show: _,
edit: _,
reset: _,
}) => {}
None => {}
}

View file

@ -1,4 +1,4 @@
use http_body_util::{BodyExt, Empty, Full};
use http_body_util::{BodyExt, Full};
use hyper::{body::Bytes, Request, StatusCode};
use hyper_util::rt::TokioIo;
use tokio::{

View file

@ -5,7 +5,7 @@ use axum::{
routing::{get, post},
Router,
};
use axum_client_ip::{InsecureClientIp, SecureClientIp, SecureClientIpSource};
use axum_client_ip::{SecureClientIpSource};
use log::info;
use rand::{seq::SliceRandom, thread_rng};
use serde::{Deserialize, Serialize};