cargo clippy --fix
This commit is contained in:
parent
ea98b5bd05
commit
4d4da1c52a
|
@ -17,11 +17,11 @@ fn element_name_macro(ast: &syn::DeriveInput) -> TokenStream {
|
|||
let mut elem_name = ast.ident.to_string();
|
||||
let (impl_generics, type_generics, _) = &ast.generics.split_for_impl();
|
||||
|
||||
if ast.attrs.len() > 0 {
|
||||
if !ast.attrs.is_empty() {
|
||||
let attribute = &ast.attrs[0];
|
||||
match attribute.parse_meta() {
|
||||
Ok(syn::Meta::List(meta)) => {
|
||||
if meta.nested.len() > 0 {
|
||||
if !meta.nested.is_empty() {
|
||||
elem_name = match &meta.nested[0] {
|
||||
syn::NestedMeta::Meta(syn::Meta::NameValue(v)) => match &v.lit {
|
||||
syn::Lit::Str(lit) => lit.value(),
|
||||
|
|
|
@ -137,31 +137,23 @@ impl EppClientConnection {
|
|||
}
|
||||
/// Parses the client certificate chain
|
||||
fn client_certificate(&self) -> Option<Vec<Certificate>> {
|
||||
match &self.tls_files {
|
||||
Some(tls) => Some(
|
||||
rustls_pemfile::certs(&mut io::BufReader::new(
|
||||
self.tls_files.as_ref().map(|tls| rustls_pemfile::certs(&mut io::BufReader::new(
|
||||
fs::File::open(tls.cert_chain.to_string()).unwrap(),
|
||||
))
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|v| Certificate(v.clone()))
|
||||
.collect(),
|
||||
),
|
||||
None => None,
|
||||
}
|
||||
.collect())
|
||||
}
|
||||
/// Parses the client RSA private key
|
||||
fn key(&self) -> Option<PrivateKey> {
|
||||
match &self.tls_files {
|
||||
Some(tls) => Some(rustls::PrivateKey(
|
||||
self.tls_files.as_ref().map(|tls| rustls::PrivateKey(
|
||||
rustls_pemfile::rsa_private_keys(&mut io::BufReader::new(
|
||||
fs::File::open(tls.key.to_string()).unwrap(),
|
||||
))
|
||||
.unwrap()[0]
|
||||
.clone(),
|
||||
)),
|
||||
None => None,
|
||||
}
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,19 +50,14 @@ async fn connect(registry: &'static str) -> Result<EppClient, Box<dyn Error>> {
|
|||
let (tx, rx) = mpsc::channel();
|
||||
|
||||
tokio::spawn(async move {
|
||||
let stream = epp_connect(®istry_creds).await.unwrap();
|
||||
let stream = epp_connect(registry_creds).await.unwrap();
|
||||
let credentials = registry_creds.credentials();
|
||||
let ext_uris = registry_creds.ext_uris();
|
||||
|
||||
let ext_uris = match ext_uris {
|
||||
Some(uris) => Some(
|
||||
uris
|
||||
let ext_uris = ext_uris.map(|uris| uris
|
||||
.iter()
|
||||
.map(|u| u.to_string())
|
||||
.collect::<Vec<String>>()
|
||||
),
|
||||
None => None,
|
||||
};
|
||||
.collect::<Vec<String>>());
|
||||
|
||||
let connection = EppConnection::new(
|
||||
registry.to_string(),
|
||||
|
@ -119,9 +114,9 @@ impl EppClient {
|
|||
/// Makes a login request to the registry and initializes an EppClient instance with it
|
||||
async fn build(connection: EppConnection, credentials: (String, String), ext_uris: Option<Vec<String>>) -> Result<EppClient, Box<dyn Error>> {
|
||||
let mut client = EppClient {
|
||||
connection: connection,
|
||||
credentials: credentials,
|
||||
ext_uris: ext_uris,
|
||||
connection,
|
||||
credentials,
|
||||
ext_uris,
|
||||
// client_tr_id_fn: Arc::new(default_client_tr_id_fn),
|
||||
};
|
||||
|
||||
|
@ -164,12 +159,12 @@ impl EppClient {
|
|||
/// Accepts raw EPP XML and returns the raw EPP XML response to it.
|
||||
/// Not recommended for direct use but sometimes can be useful for debugging
|
||||
pub async fn transact_xml(&mut self, xml: &str) -> Result<String, Box<dyn Error>> {
|
||||
self.connection.transact(&xml).await
|
||||
self.connection.transact(xml).await
|
||||
}
|
||||
|
||||
/// Returns the greeting received on establishment of the connection in raw xml form
|
||||
pub fn xml_greeting(&self) -> String {
|
||||
return String::from(&self.connection.greeting)
|
||||
String::from(&self.connection.greeting)
|
||||
}
|
||||
|
||||
/// Returns the greeting received on establishment of the connection as an `EppGreeting`
|
||||
|
|
|
@ -38,9 +38,9 @@ impl EppConnection {
|
|||
debug!("{}: greeting: {}", registry, greeting);
|
||||
|
||||
Ok(EppConnection {
|
||||
registry: registry,
|
||||
stream: stream,
|
||||
greeting: greeting
|
||||
registry,
|
||||
stream,
|
||||
greeting
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ impl EppConnection {
|
|||
let len_u32: [u8; 4] = u32::to_be_bytes(len.try_into()?);
|
||||
|
||||
buf[..4].clone_from_slice(&len_u32);
|
||||
buf[4..].clone_from_slice(&content.as_bytes());
|
||||
buf[4..].clone_from_slice(content.as_bytes());
|
||||
|
||||
self.write(&buf).await
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ impl EppConnection {
|
|||
debug!("{}: Read: {} bytes", self.registry, read);
|
||||
buf.extend_from_slice(&read_buf[0..read]);
|
||||
|
||||
read_size = read_size + read;
|
||||
read_size += read;
|
||||
debug!("{}: Total read: {} bytes", self.registry, read_size);
|
||||
|
||||
if read == 0 {
|
||||
|
@ -117,7 +117,7 @@ impl EppConnection {
|
|||
/// receieved to the request
|
||||
pub async fn transact(&mut self, content: &str) -> Result<String, Box<dyn Error>> {
|
||||
debug!("{}: request: {}", self.registry, content);
|
||||
self.send_epp_request(&content).await?;
|
||||
self.send_epp_request(content).await?;
|
||||
|
||||
let response = self.get_epp_response().await?;
|
||||
debug!("{}: response: {}", self.registry, response);
|
||||
|
@ -149,8 +149,7 @@ pub async fn epp_connect(registry_creds: &EppClientConnection) -> Result<Connect
|
|||
|
||||
let addr = (host.as_str(), port)
|
||||
.to_socket_addrs()?
|
||||
.next()
|
||||
.ok_or_else(|| stdio::ErrorKind::NotFound)?;
|
||||
.next().ok_or(stdio::ErrorKind::NotFound)?;
|
||||
|
||||
let mut roots = RootCertStore::empty();
|
||||
roots.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
|
||||
|
@ -184,7 +183,7 @@ pub async fn epp_connect(registry_creds: &EppClientConnection) -> Result<Connect
|
|||
let (reader, writer) = split(stream);
|
||||
|
||||
Ok(ConnectionStream {
|
||||
reader: reader,
|
||||
writer: writer,
|
||||
reader,
|
||||
writer,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ impl<T: ElementName> EppObject<T> {
|
|||
pub fn build(data: T) -> EppObject<T> {
|
||||
EppObject {
|
||||
// xml: None,
|
||||
data: data,
|
||||
data,
|
||||
xmlns: EPP_XMLNS.to_string(),
|
||||
xmlns_xsi: EPP_XMLNS_XSI.to_string(),
|
||||
xsi_schema_location: EPP_XSI_SCHEMA_LOCATION.to_string(),
|
||||
|
|
|
@ -106,7 +106,7 @@ impl Period {
|
|||
pub fn new(length: u16) -> Period {
|
||||
Period {
|
||||
unit: "y".to_string(),
|
||||
length: length,
|
||||
length,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ impl Address {
|
|||
.collect::<Vec<StringValue>>();
|
||||
|
||||
Address {
|
||||
street: street,
|
||||
street,
|
||||
city: city.to_string_value(),
|
||||
province: province.to_string_value(),
|
||||
postal_code: postal_code.to_string_value(),
|
||||
|
@ -232,7 +232,7 @@ impl PostalInfo {
|
|||
info_type: info_type.to_string(),
|
||||
name: name.to_string_value(),
|
||||
organization: organization.to_string_value(),
|
||||
address: address,
|
||||
address,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ impl<T: ElementName> Command<T> {
|
|||
/// Creates a new <command> tag for an EPP document
|
||||
pub fn new(command: T, client_tr_id: &str) -> Command<T> {
|
||||
Command {
|
||||
command: command,
|
||||
command,
|
||||
extension: None,
|
||||
client_tr_id: client_tr_id.to_string_value(),
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ impl<T: ElementName, E: ElementName> CommandWithExtension<T, E> {
|
|||
/// Creates a new <command> tag for an EPP document with a containing <extension> tag
|
||||
pub fn build(command: T, ext: E, client_tr_id: &str) -> CommandWithExtension<T, E> {
|
||||
CommandWithExtension {
|
||||
command: command,
|
||||
command,
|
||||
extension: Some(Extension { data: ext }),
|
||||
client_tr_id: client_tr_id.to_string_value(),
|
||||
}
|
||||
|
@ -122,14 +122,9 @@ impl EppLogin {
|
|||
ext_uris: &Option<Vec<String>>,
|
||||
client_tr_id: &str,
|
||||
) -> EppLogin {
|
||||
let ext_uris = match ext_uris {
|
||||
Some(uris) => Some(
|
||||
uris.iter()
|
||||
let ext_uris = ext_uris.as_ref().map(|uris| uris.iter()
|
||||
.map(|u| u.to_string_value())
|
||||
.collect::<Vec<StringValue>>(),
|
||||
),
|
||||
None => None,
|
||||
};
|
||||
.collect::<Vec<StringValue>>());
|
||||
|
||||
let login = Login {
|
||||
username: username.to_string_value(),
|
||||
|
@ -144,7 +139,7 @@ impl EppLogin {
|
|||
EPP_CONTACT_XMLNS.to_string_value(),
|
||||
EPP_DOMAIN_XMLNS.to_string_value(),
|
||||
],
|
||||
svc_ext: Some(ServiceExtension { ext_uris: ext_uris }),
|
||||
svc_ext: Some(ServiceExtension { ext_uris }),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ impl EppContactCheck {
|
|||
let contact_check = ContactCheck {
|
||||
list: ContactList {
|
||||
xmlns: EPP_CONTACT_XMLNS.to_string(),
|
||||
contact_ids: contact_ids,
|
||||
contact_ids,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -99,8 +99,8 @@ impl EppContactCreate {
|
|||
contact: Contact {
|
||||
xmlns: EPP_CONTACT_XMLNS.to_string(),
|
||||
id: id.to_string_value(),
|
||||
postal_info: postal_info,
|
||||
voice: voice,
|
||||
postal_info,
|
||||
voice,
|
||||
fax: None,
|
||||
email: email.to_string_value(),
|
||||
auth_info: data::AuthInfo::new(auth_password),
|
||||
|
|
|
@ -151,7 +151,7 @@ impl EppContactUpdate {
|
|||
email: Some(res_data.info_data.email.clone()),
|
||||
postal_info: Some(res_data.info_data.postal_info.clone()),
|
||||
voice: Some(res_data.info_data.voice.clone()),
|
||||
fax: res_data.info_data.fax.clone(),
|
||||
fax: res_data.info_data.fax,
|
||||
auth_info: None,
|
||||
});
|
||||
Ok(())
|
||||
|
|
|
@ -69,7 +69,7 @@ impl EppDomainCheck {
|
|||
let domain_check = DomainCheck {
|
||||
list: DomainList {
|
||||
xmlns: EPP_DOMAIN_XMLNS.to_string(),
|
||||
domains: domains,
|
||||
domains,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ impl EppDomainRgpRestoreReport {
|
|||
.to_rfc3339_opts(SecondsFormat::AutoSi, true)
|
||||
.to_string_value(),
|
||||
restore_reason: restore_reason.to_string_value(),
|
||||
statements: statements,
|
||||
statements,
|
||||
other: other.to_string_value(),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -69,7 +69,7 @@ impl EppHostCheck {
|
|||
let host_check = HostCheck {
|
||||
list: HostList {
|
||||
xmlns: EPP_HOST_XMLNS.to_string(),
|
||||
hosts: hosts,
|
||||
hosts,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -261,14 +261,14 @@ impl<T, E: ElementName> CommandResponseWithExtension<T, E> {
|
|||
/// Returns the data under the corresponding <resData> from the EPP XML
|
||||
pub fn res_data(&self) -> Option<&T> {
|
||||
match &self.res_data {
|
||||
Some(res_data) => Some(&res_data),
|
||||
Some(res_data) => Some(res_data),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
/// Returns the data under the corresponding <msgQ> from the EPP XML
|
||||
pub fn message_queue(&self) -> Option<&MessageQueue> {
|
||||
match &self.message_queue {
|
||||
Some(queue) => Some(&queue),
|
||||
Some(queue) => Some(queue),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ impl<T: Serialize + DeserializeOwned + ElementName + Debug> EppXml for EppObject
|
|||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
return Err(error::Error::EppDeserializationError(
|
||||
format!("epp-client Deserialization Error: {}", e).to_string(),
|
||||
format!("epp-client Deserialization Error: {}", e),
|
||||
))
|
||||
}
|
||||
};
|
||||
|
|
|
@ -34,7 +34,7 @@ impl Display for Error {
|
|||
|
||||
impl From<std::boxed::Box<dyn std::error::Error>> for Error {
|
||||
fn from(e: std::boxed::Box<dyn std::error::Error>) -> Self {
|
||||
Self::Other(format!("{:?}", e).to_string())
|
||||
Self::Other(format!("{:?}", e))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ fn get_xml(path: &str) -> Result<String, Box<dyn Error>> {
|
|||
let mut buf = String::new();
|
||||
|
||||
f.read_to_string(&mut buf)?;
|
||||
if buf.len() > 0 {
|
||||
let mat = Regex::new(r"\?>").unwrap().find(&buf.as_str()).unwrap();
|
||||
if !buf.is_empty() {
|
||||
let mat = Regex::new(r"\?>").unwrap().find(buf.as_str()).unwrap();
|
||||
let start = mat.end();
|
||||
buf = format!(
|
||||
"{}\r\n{}",
|
||||
|
|
Loading…
Reference in New Issue