Skip to content
This repository has been archived by the owner on Feb 2, 2019. It is now read-only.

Commit

Permalink
rustfmt changes
Browse files Browse the repository at this point in the history
  • Loading branch information
iliana committed Sep 20, 2018
1 parent 00a81e6 commit 8662e72
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 30 deletions.
2 changes: 1 addition & 1 deletion benches/wire.rs
Expand Up @@ -33,7 +33,7 @@ fn encode(c: &mut Criterion) {
0x86, 0x2a, 0x01, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01,
]))).unwrap()
.respond(LookupResult::Records(&records));
.respond(LookupResult::Records(&records));
b.iter(|| {
message
.encode(&mut BytesMut::new(), &mut HashMap::new())
Expand Down
9 changes: 3 additions & 6 deletions nsd/src/bin/pepbut-nsctl.rs
Expand Up @@ -32,10 +32,8 @@ fn main() -> Result<(), failure::Error> {
.help(&format!(
"Unix control socket to listen on (default {})",
DEFAULT_SOCKET_PATH
))
.takes_value(true),
)
.subcommand(SubCommand::with_name("list-zones").about("List loaded zones"))
)).takes_value(true),
).subcommand(SubCommand::with_name("list-zones").about("List loaded zones"))
.subcommand(
SubCommand::with_name("load-zone")
.about("Load zone from a file")
Expand All @@ -46,8 +44,7 @@ fn main() -> Result<(), failure::Error> {
.takes_value(true)
.required(true),
),
)
.get_matches();
).get_matches();
if matches.subcommand_name().is_none() {
eprintln!("error: a subcommand is required\n");
eprintln!("{}", matches.usage());
Expand Down
30 changes: 11 additions & 19 deletions nsd/src/main.rs
Expand Up @@ -50,32 +50,26 @@ fn main() -> Result<(), failure::Error> {
.help(&format!(
"ipaddr:port to listen on (default {})",
DEFAULT_LISTEN_ADDR
))
.takes_value(true),
)
.arg(
)).takes_value(true),
).arg(
Arg::with_name("socket_path")
.short("s")
.long("socket")
.value_name("SOCKET_PATH")
.help(&format!(
"Unix control socket to listen on (default {})",
DEFAULT_SOCKET_PATH
))
.takes_value(true),
)
.arg(
)).takes_value(true),
).arg(
Arg::with_name("verbose")
.short("v")
.multiple(true)
.help("Sets verbosity level (max: -vvv)"),
)
.arg(
).arg(
Arg::with_name("ZONEFILE")
.help("Zone files to load on start")
.multiple(true),
)
.get_matches();
).get_matches();

// Set log level from -v option
{
Expand Down Expand Up @@ -153,11 +147,10 @@ fn main() -> Result<(), failure::Error> {
sink.send_all(
stream.map(move |b| authority.read().unwrap().process_message(b)),
).map(|_| ())
.map_err(|e| error!("error in TCP server: {:?}", e)),
.map_err(|e| error!("error in TCP server: {:?}", e)),
);
Ok(())
})
.map_err(|e| error!("error in TCP server: {:?}", e))
}).map_err(|e| error!("error in TCP server: {:?}", e))
}),
// UDP server
Box::new({
Expand All @@ -166,7 +159,7 @@ fn main() -> Result<(), failure::Error> {
sink.send_all(
stream.map(move |(b, addr)| (authority.read().unwrap().process_message(b), addr)),
).map(|_| ())
.map_err(|e| error!("error in UDP server: {:?}", e))
.map_err(|e| error!("error in UDP server: {:?}", e))
}),
// Control server
Box::new({
Expand All @@ -179,11 +172,10 @@ fn main() -> Result<(), failure::Error> {
sink.send_all(
stream.map(move |request| ctl::handle_request(request, &authority)),
).map(|_| ())
.map_err(|e| error!("error in control server: {:?}", e)),
.map_err(|e| error!("error in control server: {:?}", e)),
);
Ok(())
})
.map_err(|e| error!("error in control server: {:?}", e))
}).map_err(|e| error!("error in control server: {:?}", e))
}),
];

Expand Down
10 changes: 7 additions & 3 deletions src/name.rs
Expand Up @@ -212,8 +212,8 @@ impl FromStr for Name {
} else {
s
}).split('.')
.map(label_from_str)
.collect::<Result<Vec<_>, _>>()?,
.map(label_from_str)
.collect::<Result<Vec<_>, _>>()?,
))
}
}
Expand Down Expand Up @@ -307,7 +307,11 @@ impl ProtocolEncode for Name {
let maybe_pos = names.get(&name).cloned();
if let Some(pos) = maybe_pos {
buf.reserve(2);
buf.put_u16_be(0xc000_u16.checked_add(pos).ok_or(::cast::Error::Underflow)?);
buf.put_u16_be(
0xc000_u16
.checked_add(pos)
.ok_or(::cast::Error::Underflow)?,
);
return Ok(());
} else {
names.insert(name.clone(), u16(buf.len())?);
Expand Down
2 changes: 1 addition & 1 deletion src/wire.rs
Expand Up @@ -272,7 +272,7 @@ mod tests {
RData::A([216, 58, 211, 142].into()),
)]),
}.encode(&mut buf, &mut names)
.unwrap();
.unwrap();
assert_eq!(
buf,
vec![
Expand Down

0 comments on commit 8662e72

Please sign in to comment.