diff --git a/src/impl_ureq.rs b/src/impl_ureq.rs index 2ec8ee2..87d4c12 100644 --- a/src/impl_ureq.rs +++ b/src/impl_ureq.rs @@ -33,7 +33,7 @@ fn find_cause( if let Some(msg) = error.get_ref().map(ToString::to_string) { if msg == "failed to lookup address information: Name does not resolve" { - ClientError::InvalidParameter(sharry::Parameter::URI(uri.to_string())) + ClientError::InvalidParameter(sharry::Parameter::Uri(uri.to_string())) } else { error.into() } diff --git a/src/sharry/client.rs b/src/sharry/client.rs index 8497ca6..e7733f3 100644 --- a/src/sharry/client.rs +++ b/src/sharry/client.rs @@ -34,8 +34,7 @@ pub trait Client { Ok(fid) } else { Err(super::ClientError::unknown(format!( - "Could not extract File ID from {:?}", - uri + "Could not extract File ID from {uri:?}" ))) } } @@ -90,7 +89,7 @@ pub trait Client { #[derive(Debug, Error)] pub enum Parameter { #[error("given URI {0:?}")] - URI(String), + Uri(String), #[error("given Alias ID {0:?}")] AliasID(String), @@ -104,10 +103,7 @@ pub enum Parameter { impl Parameter { fn is_fatal(&self) -> bool { - match self { - Self::URI(_) | Self::AliasID(_) => true, - _ => false, - } + matches!(self, Self::Uri(_) | Self::AliasID(_)) } } @@ -126,6 +122,12 @@ pub enum ClientError { Unknown(String), } +fn into_string(val: impl ToString) -> String { + let result = val.to_string(); + drop(val); + result +} + impl ClientError { pub fn res_status_check(actual: T, expected: T) -> super::Result<()> where @@ -141,11 +143,11 @@ impl ClientError { } pub fn response(e: impl ToString) -> Self { - Self::Response(e.to_string()) + Self::Response(into_string(e)) } pub fn unknown(e: impl ToString) -> Self { - Self::Unknown(e.to_string()) + Self::Unknown(into_string(e)) } pub fn is_fatal(&self) -> bool {