simplify expressions

This commit is contained in:
uniminin
2020-11-28 19:27:23 +06:00
parent 5041abde27
commit abd3bb9525
5 changed files with 70 additions and 70 deletions

View File

@ -301,8 +301,8 @@ pub struct DnsQuestion {
impl DnsQuestion { impl DnsQuestion {
pub fn new(name: String, qtype: QueryType) -> DnsQuestion { pub fn new(name: String, qtype: QueryType) -> DnsQuestion {
DnsQuestion { DnsQuestion {
name: name, name,
qtype: qtype, qtype,
} }
} }
@ -353,19 +353,19 @@ impl DnsRecord {
); );
Ok(DnsRecord::A { Ok(DnsRecord::A {
domain: domain, domain,
addr: addr, addr,
ttl: ttl, ttl,
}) })
} }
QueryType::UNKNOWN(_) => { QueryType::UNKNOWN(_) => {
buffer.step(data_len as usize)?; buffer.step(data_len as usize)?;
Ok(DnsRecord::UNKNOWN { Ok(DnsRecord::UNKNOWN {
domain: domain, domain,
qtype: qtype_num, qtype: qtype_num,
data_len: data_len, data_len,
ttl: ttl, ttl,
}) })
} }
} }

View File

@ -337,8 +337,8 @@ pub struct DnsQuestion {
impl DnsQuestion { impl DnsQuestion {
pub fn new(name: String, qtype: QueryType) -> DnsQuestion { pub fn new(name: String, qtype: QueryType) -> DnsQuestion {
DnsQuestion { DnsQuestion {
name: name, name,
qtype: qtype, qtype,
} }
} }
@ -399,19 +399,19 @@ impl DnsRecord {
); );
Ok(DnsRecord::A { Ok(DnsRecord::A {
domain: domain, domain,
addr: addr, addr,
ttl: ttl, ttl,
}) })
} }
QueryType::UNKNOWN(_) => { QueryType::UNKNOWN(_) => {
buffer.step(data_len as usize)?; buffer.step(data_len as usize)?;
Ok(DnsRecord::UNKNOWN { Ok(DnsRecord::UNKNOWN {
domain: domain, domain,
qtype: qtype_num, qtype: qtype_num,
data_len: data_len, data_len,
ttl: ttl, ttl,
}) })
} }
} }

View File

@ -362,8 +362,8 @@ pub struct DnsQuestion {
impl DnsQuestion { impl DnsQuestion {
pub fn new(name: String, qtype: QueryType) -> DnsQuestion { pub fn new(name: String, qtype: QueryType) -> DnsQuestion {
DnsQuestion { DnsQuestion {
name: name, name,
qtype: qtype, qtype,
} }
} }
@ -445,9 +445,9 @@ impl DnsRecord {
); );
Ok(DnsRecord::A { Ok(DnsRecord::A {
domain: domain, domain,
addr: addr, addr,
ttl: ttl, ttl,
}) })
} }
QueryType::AAAA => { QueryType::AAAA => {
@ -467,9 +467,9 @@ impl DnsRecord {
); );
Ok(DnsRecord::AAAA { Ok(DnsRecord::AAAA {
domain: domain, domain,
addr: addr, addr,
ttl: ttl, ttl,
}) })
} }
QueryType::NS => { QueryType::NS => {
@ -477,9 +477,9 @@ impl DnsRecord {
buffer.read_qname(&mut ns)?; buffer.read_qname(&mut ns)?;
Ok(DnsRecord::NS { Ok(DnsRecord::NS {
domain: domain, domain,
host: ns, host: ns,
ttl: ttl, ttl,
}) })
} }
QueryType::CNAME => { QueryType::CNAME => {
@ -487,9 +487,9 @@ impl DnsRecord {
buffer.read_qname(&mut cname)?; buffer.read_qname(&mut cname)?;
Ok(DnsRecord::CNAME { Ok(DnsRecord::CNAME {
domain: domain, domain,
host: cname, host: cname,
ttl: ttl, ttl,
}) })
} }
QueryType::MX => { QueryType::MX => {
@ -498,20 +498,20 @@ impl DnsRecord {
buffer.read_qname(&mut mx)?; buffer.read_qname(&mut mx)?;
Ok(DnsRecord::MX { Ok(DnsRecord::MX {
domain: domain, domain,
priority: priority, priority,
host: mx, host: mx,
ttl: ttl, ttl,
}) })
} }
QueryType::UNKNOWN(_) => { QueryType::UNKNOWN(_) => {
buffer.step(data_len as usize)?; buffer.step(data_len as usize)?;
Ok(DnsRecord::UNKNOWN { Ok(DnsRecord::UNKNOWN {
domain: domain, domain,
qtype: qtype_num, qtype: qtype_num,
data_len: data_len, data_len,
ttl: ttl, ttl,
}) })
} }
} }

View File

@ -362,8 +362,8 @@ pub struct DnsQuestion {
impl DnsQuestion { impl DnsQuestion {
pub fn new(name: String, qtype: QueryType) -> DnsQuestion { pub fn new(name: String, qtype: QueryType) -> DnsQuestion {
DnsQuestion { DnsQuestion {
name: name, name,
qtype: qtype, qtype,
} }
} }
@ -445,9 +445,9 @@ impl DnsRecord {
); );
Ok(DnsRecord::A { Ok(DnsRecord::A {
domain: domain, domain,
addr: addr, addr,
ttl: ttl, ttl,
}) })
} }
QueryType::AAAA => { QueryType::AAAA => {
@ -467,9 +467,9 @@ impl DnsRecord {
); );
Ok(DnsRecord::AAAA { Ok(DnsRecord::AAAA {
domain: domain, domain,
addr: addr, addr,
ttl: ttl, ttl,
}) })
} }
QueryType::NS => { QueryType::NS => {
@ -477,9 +477,9 @@ impl DnsRecord {
buffer.read_qname(&mut ns)?; buffer.read_qname(&mut ns)?;
Ok(DnsRecord::NS { Ok(DnsRecord::NS {
domain: domain, domain,
host: ns, host: ns,
ttl: ttl, ttl,
}) })
} }
QueryType::CNAME => { QueryType::CNAME => {
@ -487,9 +487,9 @@ impl DnsRecord {
buffer.read_qname(&mut cname)?; buffer.read_qname(&mut cname)?;
Ok(DnsRecord::CNAME { Ok(DnsRecord::CNAME {
domain: domain, domain,
host: cname, host: cname,
ttl: ttl, ttl,
}) })
} }
QueryType::MX => { QueryType::MX => {
@ -498,20 +498,20 @@ impl DnsRecord {
buffer.read_qname(&mut mx)?; buffer.read_qname(&mut mx)?;
Ok(DnsRecord::MX { Ok(DnsRecord::MX {
domain: domain, domain,
priority: priority, priority,
host: mx, host: mx,
ttl: ttl, ttl,
}) })
} }
QueryType::UNKNOWN(_) => { QueryType::UNKNOWN(_) => {
buffer.step(data_len as usize)?; buffer.step(data_len as usize)?;
Ok(DnsRecord::UNKNOWN { Ok(DnsRecord::UNKNOWN {
domain: domain, domain,
qtype: qtype_num, qtype: qtype_num,
data_len: data_len, data_len,
ttl: ttl, ttl,
}) })
} }
} }

View File

@ -362,8 +362,8 @@ pub struct DnsQuestion {
impl DnsQuestion { impl DnsQuestion {
pub fn new(name: String, qtype: QueryType) -> DnsQuestion { pub fn new(name: String, qtype: QueryType) -> DnsQuestion {
DnsQuestion { DnsQuestion {
name: name, name,
qtype: qtype, qtype,
} }
} }
@ -445,9 +445,9 @@ impl DnsRecord {
); );
Ok(DnsRecord::A { Ok(DnsRecord::A {
domain: domain, domain,
addr: addr, addr,
ttl: ttl, ttl,
}) })
} }
QueryType::AAAA => { QueryType::AAAA => {
@ -467,9 +467,9 @@ impl DnsRecord {
); );
Ok(DnsRecord::AAAA { Ok(DnsRecord::AAAA {
domain: domain, domain,
addr: addr, addr,
ttl: ttl, ttl,
}) })
} }
QueryType::NS => { QueryType::NS => {
@ -477,9 +477,9 @@ impl DnsRecord {
buffer.read_qname(&mut ns)?; buffer.read_qname(&mut ns)?;
Ok(DnsRecord::NS { Ok(DnsRecord::NS {
domain: domain, domain,
host: ns, host: ns,
ttl: ttl, ttl,
}) })
} }
QueryType::CNAME => { QueryType::CNAME => {
@ -487,9 +487,9 @@ impl DnsRecord {
buffer.read_qname(&mut cname)?; buffer.read_qname(&mut cname)?;
Ok(DnsRecord::CNAME { Ok(DnsRecord::CNAME {
domain: domain, domain,
host: cname, host: cname,
ttl: ttl, ttl,
}) })
} }
QueryType::MX => { QueryType::MX => {
@ -498,20 +498,20 @@ impl DnsRecord {
buffer.read_qname(&mut mx)?; buffer.read_qname(&mut mx)?;
Ok(DnsRecord::MX { Ok(DnsRecord::MX {
domain: domain, domain,
priority: priority, priority,
host: mx, host: mx,
ttl: ttl, ttl,
}) })
} }
QueryType::UNKNOWN(_) => { QueryType::UNKNOWN(_) => {
buffer.step(data_len as usize)?; buffer.step(data_len as usize)?;
Ok(DnsRecord::UNKNOWN { Ok(DnsRecord::UNKNOWN {
domain: domain, domain,
qtype: qtype_num, qtype: qtype_num,
data_len: data_len, data_len,
ttl: ttl, ttl,
}) })
} }
} }