diff options
Diffstat (limited to 'src/interface/config.rs')
-rw-r--r-- | src/interface/config.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/interface/config.rs b/src/interface/config.rs index 0efd4d9..277de08 100644 --- a/src/interface/config.rs +++ b/src/interface/config.rs @@ -4,7 +4,6 @@ // * Configuration service should use channels to report updates it receives over its interface. use bytes::BytesMut; -use error::Result; use std; use std::fs::{create_dir, remove_file}; use std::iter::Iterator; @@ -98,7 +97,7 @@ impl Decoder for ConfigurationCodec { type Item = Command; type Error = io::Error; - fn decode(&mut self, buf: &mut BytesMut) -> std::result::Result<Option<Self::Item>, Self::Error> { + fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> { // Determine we have a full command ready for parsing. let mut items = Vec::new(); let utf8 = String::from_utf8(buf.to_vec()).unwrap(); @@ -130,7 +129,7 @@ impl Encoder for ConfigurationCodec { type Item = String; type Error = io::Error; - fn encode(&mut self, msg: Self::Item, buf: &mut BytesMut) -> std::result::Result<(), Self::Error> { + fn encode(&mut self, msg: Self::Item, buf: &mut BytesMut) -> Result<(), Self::Error> { buf.extend(msg.as_bytes()); buf.extend(b"\n\n"); Ok(()) @@ -149,14 +148,14 @@ impl ConfigurationServiceManager { } /// Creates a new `WireGuard` instance - pub fn get_path(&self) -> Result<PathBuf> { + pub fn get_path(&self) -> Result<PathBuf, ()> { // let _tun = Tun::create(Some("hey")); // Create the socket directory if not existing let mut socket_path = Self::get_run_path().join("wireguard"); if !socket_path.exists() { debug!("Creating socket path: {}", socket_path.display()); - create_dir(&socket_path)?; + create_dir(&socket_path).map_err(|_|())?; } debug!("Setting chmod 0700 of socket path: {}", socket_path.display()); @@ -167,7 +166,7 @@ impl ConfigurationServiceManager { socket_path.set_extension("sock"); if socket_path.exists() { debug!("Removing existing socket: {}", socket_path.display()); - remove_file(&socket_path)?; + remove_file(&socket_path).map_err(|_|())?; } Ok(socket_path) @@ -175,16 +174,16 @@ impl ConfigurationServiceManager { #[cfg(unix)] /// Sets the permissions to a given `Path` - fn chmod(path: &Path, perms: u32) -> Result<()> { + fn chmod(path: &Path, perms: u32) -> Result<(), ()> { use std::os::unix::prelude::PermissionsExt; use std::fs::{set_permissions, Permissions}; - set_permissions(path, Permissions::from_mode(perms))?; + set_permissions(path, Permissions::from_mode(perms)).map_err(|_|())?; Ok(()) } #[cfg(windows)] /// Sets the permissions to a given `Path` - fn chmod(_path: &Path, _perms: u32) -> Result<()> { + fn chmod(_path: &Path, _perms: u32) -> Result<(), ()> { Ok(()) } |