diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2022-10-22 16:28:54 +0200 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2022-10-22 16:28:54 +0200 |
commit | a8ea04b12acfb4a91ec44201fff1ffc282de539e (patch) | |
tree | af47709f6fca0b2daac17e29acb2cae104ced34f | |
parent | ff5f6bd8bfb1afd482a01d900cc37129fc06caa0 (diff) |
reduce nameserver.info response to correct members
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/response/nameserver.rs | 39 |
2 files changed, 0 insertions, 40 deletions
@@ -6,7 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -iso8601 = "0.4.0" reqwest = { version = "0.11", features = ["blocking", "cookies"] } url = "2.2.2" xmlrpc = "0.15.1" diff --git a/src/response/nameserver.rs b/src/response/nameserver.rs index e9ff8db..68dab8c 100644 --- a/src/response/nameserver.rs +++ b/src/response/nameserver.rs @@ -5,8 +5,6 @@ use crate::{Error, Result}; use std::collections::BTreeMap; use std::fmt; -use iso8601::DateTime; - fn get_str(map: &BTreeMap<String, xmlrpc::Value>, key: &'static str) -> Result<String> { let value = map .get(key) @@ -37,16 +35,6 @@ fn get_bool(map: &BTreeMap<String, xmlrpc::Value>, key: &'static str) -> Result< Ok(value) } -fn get_datetime(map: &BTreeMap<String, xmlrpc::Value>, key: &'static str) -> Result<DateTime> { - let value = map - .get(key) - .ok_or(Error::Inexistent(key))? - .as_datetime() - .ok_or_else(|| Error::Type(key, "DateTime", map.get(key).unwrap().clone()))?; - - Ok(value) -} - fn get_array( map: &BTreeMap<String, xmlrpc::Value>, key: &'static str, @@ -60,19 +48,6 @@ fn get_array( Ok(value.to_vec()) } -fn get_map( - map: &BTreeMap<String, xmlrpc::Value>, - key: &'static str, -) -> Result<BTreeMap<String, xmlrpc::Value>> { - let value = map - .get(key) - .ok_or(Error::Inexistent(key))? - .as_struct() - .ok_or_else(|| Error::Type(key, "Struct", map.get(key).unwrap().clone()))?; - - Ok(value.to_owned()) -} - /// The domain type. Can be master or slave. #[derive(Clone, Debug)] pub enum DomainType { @@ -197,13 +172,6 @@ impl TryFrom<xmlrpc::Value> for Record { /// The records that match a search. #[derive(Clone, Debug)] pub struct RecordInfo { - pub domain_id: i32, - pub domain_name: String, - pub domain_type: DomainType, - pub master_address: String, - pub last_zone_check: DateTime, - pub slave_dns: SlaveDns, - pub soa_serial: String, pub records: Vec<Record>, } @@ -211,13 +179,6 @@ impl TryFrom<Response> for RecordInfo { type Error = Error; fn try_from(resp: Response) -> Result<Self> { let info = Self { - domain_id: get_i32(&resp.data, "roId")?, - domain_name: get_str(&resp.data, "domain")?, - domain_type: get_str(&resp.data, "type")?.try_into()?, - master_address: get_str(&resp.data, "masterIp")?, - last_zone_check: get_datetime(&resp.data, "lastZoneCheck")?, - slave_dns: get_map(&resp.data, "slaveDns")?.try_into()?, - soa_serial: get_str(&resp.data, "SOAserial")?, records: get_array(&resp.data, "record")? .iter() .filter_map(|v| v.to_owned().try_into().ok()) |