clippy fix
This commit is contained in:
parent
783346c888
commit
01bcf92d9c
2 changed files with 12 additions and 10 deletions
|
|
@ -33,7 +33,7 @@ fn find_cause(
|
||||||
|
|
||||||
if let Some(msg) = error.get_ref().map(ToString::to_string) {
|
if let Some(msg) = error.get_ref().map(ToString::to_string) {
|
||||||
if msg == "failed to lookup address information: Name does not resolve" {
|
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 {
|
} else {
|
||||||
error.into()
|
error.into()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,7 @@ pub trait Client {
|
||||||
Ok(fid)
|
Ok(fid)
|
||||||
} else {
|
} else {
|
||||||
Err(super::ClientError::unknown(format!(
|
Err(super::ClientError::unknown(format!(
|
||||||
"Could not extract File ID from {:?}",
|
"Could not extract File ID from {uri:?}"
|
||||||
uri
|
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +89,7 @@ pub trait Client {
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Parameter {
|
pub enum Parameter {
|
||||||
#[error("given URI {0:?}")]
|
#[error("given URI {0:?}")]
|
||||||
URI(String),
|
Uri(String),
|
||||||
|
|
||||||
#[error("given Alias ID {0:?}")]
|
#[error("given Alias ID {0:?}")]
|
||||||
AliasID(String),
|
AliasID(String),
|
||||||
|
|
@ -104,10 +103,7 @@ pub enum Parameter {
|
||||||
|
|
||||||
impl Parameter {
|
impl Parameter {
|
||||||
fn is_fatal(&self) -> bool {
|
fn is_fatal(&self) -> bool {
|
||||||
match self {
|
matches!(self, Self::Uri(_) | Self::AliasID(_))
|
||||||
Self::URI(_) | Self::AliasID(_) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -126,6 +122,12 @@ pub enum ClientError {
|
||||||
Unknown(String),
|
Unknown(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn into_string(val: impl ToString) -> String {
|
||||||
|
let result = val.to_string();
|
||||||
|
drop(val);
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
impl ClientError {
|
impl ClientError {
|
||||||
pub fn res_status_check<T>(actual: T, expected: T) -> super::Result<()>
|
pub fn res_status_check<T>(actual: T, expected: T) -> super::Result<()>
|
||||||
where
|
where
|
||||||
|
|
@ -141,11 +143,11 @@ impl ClientError {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn response(e: impl ToString) -> Self {
|
pub fn response(e: impl ToString) -> Self {
|
||||||
Self::Response(e.to_string())
|
Self::Response(into_string(e))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unknown(e: impl ToString) -> Self {
|
pub fn unknown(e: impl ToString) -> Self {
|
||||||
Self::Unknown(e.to_string())
|
Self::Unknown(into_string(e))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_fatal(&self) -> bool {
|
pub fn is_fatal(&self) -> bool {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue