rustfmt examples/*.rs

This commit is contained in:
uniminin 2020-11-28 19:29:04 +06:00
parent abd3bb9525
commit 24a949c4d4
5 changed files with 15 additions and 62 deletions

View File

@ -300,10 +300,7 @@ 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, qtype }
name,
qtype,
}
} }
pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> { pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> {
@ -352,11 +349,7 @@ impl DnsRecord {
((raw_addr >> 0) & 0xFF) as u8, ((raw_addr >> 0) & 0xFF) as u8,
); );
Ok(DnsRecord::A { Ok(DnsRecord::A { domain, addr, ttl })
domain,
addr,
ttl,
})
} }
QueryType::UNKNOWN(_) => { QueryType::UNKNOWN(_) => {
buffer.step(data_len as usize)?; buffer.step(data_len as usize)?;

View File

@ -336,10 +336,7 @@ 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, qtype }
name,
qtype,
}
} }
pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> { pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> {
@ -398,11 +395,7 @@ impl DnsRecord {
((raw_addr >> 0) & 0xFF) as u8, ((raw_addr >> 0) & 0xFF) as u8,
); );
Ok(DnsRecord::A { Ok(DnsRecord::A { domain, addr, ttl })
domain,
addr,
ttl,
})
} }
QueryType::UNKNOWN(_) => { QueryType::UNKNOWN(_) => {
buffer.step(data_len as usize)?; buffer.step(data_len as usize)?;

View File

@ -361,10 +361,7 @@ 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, qtype }
name,
qtype,
}
} }
pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> { pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> {
@ -444,11 +441,7 @@ impl DnsRecord {
((raw_addr >> 0) & 0xFF) as u8, ((raw_addr >> 0) & 0xFF) as u8,
); );
Ok(DnsRecord::A { Ok(DnsRecord::A { domain, addr, ttl })
domain,
addr,
ttl,
})
} }
QueryType::AAAA => { QueryType::AAAA => {
let raw_addr1 = buffer.read_u32()?; let raw_addr1 = buffer.read_u32()?;
@ -466,11 +459,7 @@ impl DnsRecord {
((raw_addr4 >> 0) & 0xFFFF) as u16, ((raw_addr4 >> 0) & 0xFFFF) as u16,
); );
Ok(DnsRecord::AAAA { Ok(DnsRecord::AAAA { domain, addr, ttl })
domain,
addr,
ttl,
})
} }
QueryType::NS => { QueryType::NS => {
let mut ns = String::new(); let mut ns = String::new();

View File

@ -361,10 +361,7 @@ 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, qtype }
name,
qtype,
}
} }
pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> { pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> {
@ -444,11 +441,7 @@ impl DnsRecord {
((raw_addr >> 0) & 0xFF) as u8, ((raw_addr >> 0) & 0xFF) as u8,
); );
Ok(DnsRecord::A { Ok(DnsRecord::A { domain, addr, ttl })
domain,
addr,
ttl,
})
} }
QueryType::AAAA => { QueryType::AAAA => {
let raw_addr1 = buffer.read_u32()?; let raw_addr1 = buffer.read_u32()?;
@ -466,11 +459,7 @@ impl DnsRecord {
((raw_addr4 >> 0) & 0xFFFF) as u16, ((raw_addr4 >> 0) & 0xFFFF) as u16,
); );
Ok(DnsRecord::AAAA { Ok(DnsRecord::AAAA { domain, addr, ttl })
domain,
addr,
ttl,
})
} }
QueryType::NS => { QueryType::NS => {
let mut ns = String::new(); let mut ns = String::new();
@ -793,7 +782,7 @@ fn main() -> Result<()> {
// requests is initiated. // requests is initiated.
loop { loop {
match handle_query(&socket) { match handle_query(&socket) {
Ok(_) => {}, Ok(_) => {}
Err(e) => eprintln!("An error occurred: {}", e), Err(e) => eprintln!("An error occurred: {}", e),
} }
} }

View File

@ -361,10 +361,7 @@ 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, qtype }
name,
qtype,
}
} }
pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> { pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> {
@ -444,11 +441,7 @@ impl DnsRecord {
((raw_addr >> 0) & 0xFF) as u8, ((raw_addr >> 0) & 0xFF) as u8,
); );
Ok(DnsRecord::A { Ok(DnsRecord::A { domain, addr, ttl })
domain,
addr,
ttl,
})
} }
QueryType::AAAA => { QueryType::AAAA => {
let raw_addr1 = buffer.read_u32()?; let raw_addr1 = buffer.read_u32()?;
@ -466,11 +459,7 @@ impl DnsRecord {
((raw_addr4 >> 0) & 0xFFFF) as u16, ((raw_addr4 >> 0) & 0xFFFF) as u16,
); );
Ok(DnsRecord::AAAA { Ok(DnsRecord::AAAA { domain, addr, ttl })
domain,
addr,
ttl,
})
} }
QueryType::NS => { QueryType::NS => {
let mut ns = String::new(); let mut ns = String::new();
@ -886,7 +875,7 @@ fn main() -> Result<()> {
loop { loop {
match handle_query(&socket) { match handle_query(&socket) {
Ok(_) => {}, Ok(_) => {}
Err(e) => eprintln!("An error occurred: {}", e), Err(e) => eprintln!("An error occurred: {}", e),
} }
} }