Skip to content

Commit

Permalink
chore: use Box<str>
Browse files Browse the repository at this point in the history
  • Loading branch information
frectonz committed Oct 30, 2024
1 parent 60631f7 commit d83dcd2
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::sync::Arc;

use clap::Parser;
use fetcher::Fetcher;
use warp::Filter;
Expand All @@ -9,11 +7,11 @@ use warp::Filter;
struct Arguments {
/// The address to bind to.
#[arg(long, env, default_value = "127.0.0.1:3030")]
address: Arc<str>,
address: Box<str>,

/// Registry URL to connect to. Example [http://127.0.0.1:3030]
#[arg(long, env)]
registry_url: Arc<str>,
registry_url: Box<str>,

/// Registry username and password separated with a colon. Example [username:password]
#[arg(long, env)]
Expand All @@ -22,8 +20,8 @@ struct Arguments {

#[derive(Debug, Clone)]
struct Credentials {
username: Arc<str>,
password: Arc<str>,
username: Box<str>,
password: Box<str>,
}

impl std::str::FromStr for Credentials {
Expand All @@ -35,8 +33,8 @@ impl std::str::FromStr for Credentials {
return Err("credentials must be in the format 'username:password'".to_string());
}
Ok(Credentials {
username: Arc::from(parts[0]),
password: Arc::from(parts[1]),
username: Box::from(parts[0]),
password: Box::from(parts[1]),
})
}
}
Expand Down Expand Up @@ -155,24 +153,22 @@ mod statics {
}

mod fetcher {
use std::sync::Arc;

use reqwest::Client;

use crate::Credentials;

#[derive(Clone)]
pub struct Fetcher {
client: Client,
url: Arc<str>,
url: Box<str>,
auth: Option<Credentials>,
}

impl Fetcher {
pub fn new(url: &str, auth: Option<Credentials>) -> Self {
Self {
client: Client::new(),
url: Arc::from(url),
url: Box::from(url),
auth,
}
}
Expand Down

0 comments on commit d83dcd2

Please sign in to comment.