diff --git a/src/fetchers.rs b/src/fetchers.rs index 16691707..952b90fe 100644 --- a/src/fetchers.rs +++ b/src/fetchers.rs @@ -1,6 +1,7 @@ use std::path::Path; use std::sync::Arc; +use compact_str::CompactString; pub use gh_crate_meta::*; pub use log::debug; pub use quickinstall::*; @@ -35,7 +36,7 @@ pub trait Fetcher: Send + Sync { fn pkg_fmt(&self) -> PkgFmt; /// A short human-readable name or descriptor for the package source - fn source_name(&self) -> String; + fn source_name(&self) -> CompactString; /// Should return true if the remote is from a third-party source fn is_third_party(&self) -> bool; diff --git a/src/fetchers/gh_crate_meta.rs b/src/fetchers/gh_crate_meta.rs index 7a4381db..6375d7df 100644 --- a/src/fetchers/gh_crate_meta.rs +++ b/src/fetchers/gh_crate_meta.rs @@ -1,6 +1,7 @@ use std::path::Path; use std::sync::Arc; +use compact_str::{CompactString, ToCompactString}; use log::{debug, info, warn}; use once_cell::sync::OnceCell; use reqwest::Client; @@ -79,19 +80,19 @@ impl super::Fetcher for GhCrateMeta { self.data.meta.pkg_fmt } - fn source_name(&self) -> String { + fn source_name(&self) -> CompactString { self.url .get() .map(|url| { if let Some(domain) = url.domain() { - domain.to_string() + domain.to_compact_string() } else if let Some(host) = url.host_str() { - host.to_string() + host.to_compact_string() } else { - url.to_string() + url.to_compact_string() } }) - .unwrap_or_else(|| "invalid url".to_string()) + .unwrap_or_else(|| "invalid url".into()) } fn is_third_party(&self) -> bool { diff --git a/src/fetchers/quickinstall.rs b/src/fetchers/quickinstall.rs index bdca2762..f79b9bc1 100644 --- a/src/fetchers/quickinstall.rs +++ b/src/fetchers/quickinstall.rs @@ -1,6 +1,7 @@ use std::path::Path; use std::sync::Arc; +use compact_str::CompactString; use log::{debug, info}; use reqwest::Client; use reqwest::Method; @@ -49,8 +50,8 @@ impl super::Fetcher for QuickInstall { PkgFmt::Tgz } - fn source_name(&self) -> String { - String::from("QuickInstall") + fn source_name(&self) -> CompactString { + CompactString::from("QuickInstall") } fn is_third_party(&self) -> bool {