From 44aceb109c9fd53190ef8ea8b632f78ad917f745 Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Wed, 12 Jan 2022 16:26:11 -0600 Subject: [PATCH] wireguard-control: cargo fmt --- wireguard-control/src/backends/kernel.rs | 42 ++++++++++++++---------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/wireguard-control/src/backends/kernel.rs b/wireguard-control/src/backends/kernel.rs index 3a0624d..4cf3baa 100644 --- a/wireguard-control/src/backends/kernel.rs +++ b/wireguard-control/src/backends/kernel.rs @@ -359,28 +359,34 @@ pub fn get_by_name(name: &InterfaceName) -> Result { nlas: vec![WgDeviceAttrs::IfName(name.as_str_lossy().to_string())], }); let responses = netlink_request_genl(genlmsg, Some(NLM_F_REQUEST | NLM_F_DUMP | NLM_F_ACK))?; - log::debug!("get_by_name: got {} response message(s) from netlink request", responses.len()); + log::debug!( + "get_by_name: got {} response message(s) from netlink request", + responses.len() + ); - let nlas = - responses - .into_iter() - .fold(Ok(vec![]), |nlas_res, nlmsg| { - let mut nlas = nlas_res?; - let mut message = match nlmsg { - NetlinkMessage { - payload: NetlinkPayload::InnerMessage(message), - .. - } => message, - _ => return Err(io::Error::new( + let nlas = responses.into_iter().fold(Ok(vec![]), |nlas_res, nlmsg| { + let mut nlas = nlas_res?; + let mut message = match nlmsg { + NetlinkMessage { + payload: NetlinkPayload::InnerMessage(message), + .. + } => message, + _ => { + return Err(io::Error::new( io::ErrorKind::InvalidData, format!("unexpected netlink payload: {:?}", nlmsg), - )), - }; - nlas.append(&mut message.payload.nlas); - Ok(nlas) - })?; + )) + }, + }; + nlas.append(&mut message.payload.nlas); + Ok(nlas) + })?; let device = Device::try_from(&nlas[..])?; - log::debug!("get_by_name: parsed wireguard device {} with {} peer(s)", device.name, device.peers.len()); + log::debug!( + "get_by_name: parsed wireguard device {} with {} peer(s)", + device.name, + device.peers.len() + ); Ok(device) }