Warn when not using Self
This commit is contained in:
parent
5371ba573a
commit
c0e58dec04
|
@ -29,7 +29,7 @@ impl<'xml> FromXml<'xml> for NoExtension {
|
|||
}
|
||||
|
||||
impl Extension for NoExtension {
|
||||
type Response = NoExtension;
|
||||
type Response = Self;
|
||||
}
|
||||
|
||||
/// The `<option>` type in EPP XML login requests
|
||||
|
|
|
@ -302,18 +302,18 @@ impl<'xml> FromXml<'xml> for Status {
|
|||
}
|
||||
|
||||
*into = Some(match attr.value {
|
||||
"clientDeleteProhibited" => Status::ClientDeleteProhibited,
|
||||
"serverDeleteProhibited" => Status::ServerDeleteProhibited,
|
||||
"clientTransferProhibited" => Status::ClientTransferProhibited,
|
||||
"serverTransferProhibited" => Status::ServerTransferProhibited,
|
||||
"clientUpdateProhibited" => Status::ClientUpdateProhibited,
|
||||
"serverUpdateProhibited" => Status::ServerUpdateProhibited,
|
||||
"linked" => Status::Linked,
|
||||
"ok" => Status::Ok,
|
||||
"pendingCreate" => Status::PendingCreate,
|
||||
"pendingDelete" => Status::PendingDelete,
|
||||
"pendingTransfer" => Status::PendingTransfer,
|
||||
"pendingUpdate" => Status::PendingUpdate,
|
||||
"clientDeleteProhibited" => Self::ClientDeleteProhibited,
|
||||
"serverDeleteProhibited" => Self::ServerDeleteProhibited,
|
||||
"clientTransferProhibited" => Self::ClientTransferProhibited,
|
||||
"serverTransferProhibited" => Self::ServerTransferProhibited,
|
||||
"clientUpdateProhibited" => Self::ClientUpdateProhibited,
|
||||
"serverUpdateProhibited" => Self::ServerUpdateProhibited,
|
||||
"linked" => Self::Linked,
|
||||
"ok" => Self::Ok,
|
||||
"pendingCreate" => Self::PendingCreate,
|
||||
"pendingDelete" => Self::PendingDelete,
|
||||
"pendingTransfer" => Self::PendingTransfer,
|
||||
"pendingUpdate" => Self::PendingUpdate,
|
||||
val => return Err(Error::UnexpectedValue(format!("invalid status {val:?}"))),
|
||||
});
|
||||
|
||||
|
@ -321,6 +321,6 @@ impl<'xml> FromXml<'xml> for Status {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
type Accumulator = Option<Status>;
|
||||
type Accumulator = Option<Self>;
|
||||
const KIND: instant_xml::Kind = instant_xml::Kind::Element;
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ impl Period {
|
|||
|
||||
fn new(length: u8, unit: char) -> Result<Self, Error> {
|
||||
match length {
|
||||
1..=99 => Ok(Period { length, unit }),
|
||||
1..=99 => Ok(Self { length, unit }),
|
||||
0 | 100.. => Err(Error::Other(
|
||||
"Period length must be greater than 0 and less than 100".into(),
|
||||
)),
|
||||
|
@ -316,23 +316,23 @@ impl<'xml> FromXml<'xml> for Status {
|
|||
}
|
||||
|
||||
*into = Some(match attr.value {
|
||||
"clientDeleteProhibited" => Status::ClientDeleteProhibited,
|
||||
"serverDeleteProhibited" => Status::ServerDeleteProhibited,
|
||||
"clientHold" => Status::ClientHold,
|
||||
"serverHold" => Status::ServerHold,
|
||||
"clientRenewProhibited" => Status::ClientRenewProhibited,
|
||||
"serverRenewProhibited" => Status::ServerRenewProhibited,
|
||||
"clientTransferProhibited" => Status::ClientTransferProhibited,
|
||||
"serverTransferProhibited" => Status::ServerTransferProhibited,
|
||||
"clientUpdateProhibited" => Status::ClientUpdateProhibited,
|
||||
"serverUpdateProhibited" => Status::ServerUpdateProhibited,
|
||||
"inactive" => Status::Inactive,
|
||||
"ok" => Status::Ok,
|
||||
"pendingCreate" => Status::PendingCreate,
|
||||
"pendingDelete" => Status::PendingDelete,
|
||||
"pendingRenew" => Status::PendingRenew,
|
||||
"pendingTransfer" => Status::PendingTransfer,
|
||||
"pendingUpdate" => Status::PendingUpdate,
|
||||
"clientDeleteProhibited" => Self::ClientDeleteProhibited,
|
||||
"serverDeleteProhibited" => Self::ServerDeleteProhibited,
|
||||
"clientHold" => Self::ClientHold,
|
||||
"serverHold" => Self::ServerHold,
|
||||
"clientRenewProhibited" => Self::ClientRenewProhibited,
|
||||
"serverRenewProhibited" => Self::ServerRenewProhibited,
|
||||
"clientTransferProhibited" => Self::ClientTransferProhibited,
|
||||
"serverTransferProhibited" => Self::ServerTransferProhibited,
|
||||
"clientUpdateProhibited" => Self::ClientUpdateProhibited,
|
||||
"serverUpdateProhibited" => Self::ServerUpdateProhibited,
|
||||
"inactive" => Self::Inactive,
|
||||
"ok" => Self::Ok,
|
||||
"pendingCreate" => Self::PendingCreate,
|
||||
"pendingDelete" => Self::PendingDelete,
|
||||
"pendingRenew" => Self::PendingRenew,
|
||||
"pendingTransfer" => Self::PendingTransfer,
|
||||
"pendingUpdate" => Self::PendingUpdate,
|
||||
val => return Err(Error::UnexpectedValue(format!("invalid status {val:?}"))),
|
||||
});
|
||||
|
||||
|
@ -340,6 +340,6 @@ impl<'xml> FromXml<'xml> for Status {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
type Accumulator = Option<Status>;
|
||||
type Accumulator = Option<Self>;
|
||||
const KIND: instant_xml::Kind = instant_xml::Kind::Element;
|
||||
}
|
||||
|
|
10
src/error.rs
10
src/error.rs
|
@ -25,13 +25,13 @@ impl StdError for Error {}
|
|||
impl Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Error::Command(e) => {
|
||||
Self::Command(e) => {
|
||||
write!(f, "command error: {}", e.result.message)
|
||||
}
|
||||
Error::Io(e) => write!(f, "I/O error: {e}"),
|
||||
Error::Timeout => write!(f, "timeout"),
|
||||
Error::Xml(e) => write!(f, "(de)serialization error: {e}"),
|
||||
Error::Other(e) => write!(f, "error: {e}"),
|
||||
Self::Io(e) => write!(f, "I/O error: {e}"),
|
||||
Self::Timeout => write!(f, "timeout"),
|
||||
Self::Xml(e) => write!(f, "(de)serialization error: {e}"),
|
||||
Self::Other(e) => write!(f, "error: {e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ impl GMonthDay {
|
|||
return Err("Day value within GMonthDay is to big for specified month".to_string());
|
||||
}
|
||||
|
||||
Ok(GMonthDay {
|
||||
Ok(Self {
|
||||
month,
|
||||
day,
|
||||
timezone,
|
||||
|
|
|
@ -50,7 +50,7 @@ impl<'xml> FromXml<'xml> for ServiceMenu {
|
|||
None => return Ok(()),
|
||||
};
|
||||
|
||||
*into = Some(ServiceMenu {
|
||||
*into = Some(Self {
|
||||
options: Options {
|
||||
version: flattened.version.into(),
|
||||
lang: flattened.lang.into(),
|
||||
|
|
|
@ -104,16 +104,16 @@ impl<'xml> FromXml<'xml> for Status {
|
|||
}
|
||||
|
||||
*into = Some(match attr.value {
|
||||
"clientDeleteProhibited" => Status::ClientDeleteProhibited,
|
||||
"serverDeleteProhibited" => Status::ServerDeleteProhibited,
|
||||
"clientUpdateProhibited" => Status::ClientUpdateProhibited,
|
||||
"serverUpdateProhibited" => Status::ServerUpdateProhibited,
|
||||
"linked" => Status::Linked,
|
||||
"ok" => Status::Ok,
|
||||
"pendingCreate" => Status::PendingCreate,
|
||||
"pendingDelete" => Status::PendingDelete,
|
||||
"pendingTransfer" => Status::PendingTransfer,
|
||||
"pendingUpdate" => Status::PendingUpdate,
|
||||
"clientDeleteProhibited" => Self::ClientDeleteProhibited,
|
||||
"serverDeleteProhibited" => Self::ServerDeleteProhibited,
|
||||
"clientUpdateProhibited" => Self::ClientUpdateProhibited,
|
||||
"serverUpdateProhibited" => Self::ServerUpdateProhibited,
|
||||
"linked" => Self::Linked,
|
||||
"ok" => Self::Ok,
|
||||
"pendingCreate" => Self::PendingCreate,
|
||||
"pendingDelete" => Self::PendingDelete,
|
||||
"pendingTransfer" => Self::PendingTransfer,
|
||||
"pendingUpdate" => Self::PendingUpdate,
|
||||
val => return Err(Error::UnexpectedValue(format!("invalid status {val:?}"))),
|
||||
});
|
||||
|
||||
|
@ -121,7 +121,7 @@ impl<'xml> FromXml<'xml> for Status {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
type Accumulator = Option<Status>;
|
||||
type Accumulator = Option<Self>;
|
||||
const KIND: instant_xml::Kind = instant_xml::Kind::Element;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
//! on that type for more information.
|
||||
|
||||
#![warn(unreachable_pub)]
|
||||
#![warn(clippy::use_self)]
|
||||
|
||||
pub mod client;
|
||||
pub mod common;
|
||||
|
|
|
@ -86,40 +86,40 @@ pub enum ResultCode {
|
|||
impl ResultCode {
|
||||
pub fn from_u16(code: u16) -> Option<Self> {
|
||||
match code {
|
||||
1000 => Some(ResultCode::CommandCompletedSuccessfully),
|
||||
1001 => Some(ResultCode::CommandCompletedSuccessfullyActionPending),
|
||||
1300 => Some(ResultCode::CommandCompletedSuccessfullyNoMessages),
|
||||
1301 => Some(ResultCode::CommandCompletedSuccessfullyAckToDequeue),
|
||||
1500 => Some(ResultCode::CommandCompletedSuccessfullyEndingSession),
|
||||
2000 => Some(ResultCode::UnknownCommand),
|
||||
2001 => Some(ResultCode::CommandSyntaxError),
|
||||
2002 => Some(ResultCode::CommandUseError),
|
||||
2003 => Some(ResultCode::RequiredParameterMissing),
|
||||
2004 => Some(ResultCode::ParameterValueRangeError),
|
||||
2005 => Some(ResultCode::ParameterValueSyntaxError),
|
||||
2100 => Some(ResultCode::UnimplementedProtocolVersion),
|
||||
2101 => Some(ResultCode::UnimplementedCommand),
|
||||
2102 => Some(ResultCode::UnimplementedOption),
|
||||
2103 => Some(ResultCode::UnimplementedExtension),
|
||||
2104 => Some(ResultCode::BillingFailure),
|
||||
2105 => Some(ResultCode::ObjectIsNotEligibleForRenewal),
|
||||
2106 => Some(ResultCode::ObjectIsNotEligibleForTransfer),
|
||||
2200 => Some(ResultCode::AuthenticationError),
|
||||
2201 => Some(ResultCode::AuthorizationError),
|
||||
2202 => Some(ResultCode::InvalidAuthorizationInformation),
|
||||
2300 => Some(ResultCode::ObjectPendingTransfer),
|
||||
2301 => Some(ResultCode::ObjectNotPendingTransfer),
|
||||
2302 => Some(ResultCode::ObjectExists),
|
||||
2303 => Some(ResultCode::ObjectDoesNotExist),
|
||||
2304 => Some(ResultCode::ObjectStatusProhibitsOperation),
|
||||
2305 => Some(ResultCode::ObjectAssociationProhibitsOperation),
|
||||
2306 => Some(ResultCode::ParameterValuePolicyError),
|
||||
2307 => Some(ResultCode::UnimplementedObjectService),
|
||||
2308 => Some(ResultCode::DataManagementPolicyViolation),
|
||||
2400 => Some(ResultCode::CommandFailed),
|
||||
2500 => Some(ResultCode::CommandFailedServerClosingConnection),
|
||||
2501 => Some(ResultCode::AuthenticationErrorServerClosingConnection),
|
||||
2502 => Some(ResultCode::SessionLimitExceededServerClosingConnection),
|
||||
1000 => Some(Self::CommandCompletedSuccessfully),
|
||||
1001 => Some(Self::CommandCompletedSuccessfullyActionPending),
|
||||
1300 => Some(Self::CommandCompletedSuccessfullyNoMessages),
|
||||
1301 => Some(Self::CommandCompletedSuccessfullyAckToDequeue),
|
||||
1500 => Some(Self::CommandCompletedSuccessfullyEndingSession),
|
||||
2000 => Some(Self::UnknownCommand),
|
||||
2001 => Some(Self::CommandSyntaxError),
|
||||
2002 => Some(Self::CommandUseError),
|
||||
2003 => Some(Self::RequiredParameterMissing),
|
||||
2004 => Some(Self::ParameterValueRangeError),
|
||||
2005 => Some(Self::ParameterValueSyntaxError),
|
||||
2100 => Some(Self::UnimplementedProtocolVersion),
|
||||
2101 => Some(Self::UnimplementedCommand),
|
||||
2102 => Some(Self::UnimplementedOption),
|
||||
2103 => Some(Self::UnimplementedExtension),
|
||||
2104 => Some(Self::BillingFailure),
|
||||
2105 => Some(Self::ObjectIsNotEligibleForRenewal),
|
||||
2106 => Some(Self::ObjectIsNotEligibleForTransfer),
|
||||
2200 => Some(Self::AuthenticationError),
|
||||
2201 => Some(Self::AuthorizationError),
|
||||
2202 => Some(Self::InvalidAuthorizationInformation),
|
||||
2300 => Some(Self::ObjectPendingTransfer),
|
||||
2301 => Some(Self::ObjectNotPendingTransfer),
|
||||
2302 => Some(Self::ObjectExists),
|
||||
2303 => Some(Self::ObjectDoesNotExist),
|
||||
2304 => Some(Self::ObjectStatusProhibitsOperation),
|
||||
2305 => Some(Self::ObjectAssociationProhibitsOperation),
|
||||
2306 => Some(Self::ParameterValuePolicyError),
|
||||
2307 => Some(Self::UnimplementedObjectService),
|
||||
2308 => Some(Self::DataManagementPolicyViolation),
|
||||
2400 => Some(Self::CommandFailed),
|
||||
2500 => Some(Self::CommandFailedServerClosingConnection),
|
||||
2501 => Some(Self::AuthenticationErrorServerClosingConnection),
|
||||
2502 => Some(Self::SessionLimitExceededServerClosingConnection),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ impl<'xml> FromXml<'xml> for ResultCode {
|
|||
let mut value = None;
|
||||
u16::deserialize(&mut value, field, deserializer)?;
|
||||
if let Some(value) = value {
|
||||
*into = match ResultCode::from_u16(value) {
|
||||
*into = match Self::from_u16(value) {
|
||||
Some(value) => Some(value),
|
||||
None => {
|
||||
return Err(instant_xml::Error::UnexpectedValue(format!(
|
||||
|
|
Loading…
Reference in New Issue