diff options
author | Jake McGinty <me@jake.su> | 2018-02-08 15:23:13 +0000 |
---|---|---|
committer | Jake McGinty <me@jake.su> | 2018-02-08 15:23:20 +0000 |
commit | 34ba2cd5c5826d8d01c580b05e4c9a883f8a12a9 (patch) | |
tree | 07c25501172f4f7b07594de792cfb7075e230f36 /src/interface/config.rs | |
parent | take advantage of new snow API (diff) | |
download | wireguard-rs-34ba2cd5c5826d8d01c580b05e4c9a883f8a12a9.tar.xz wireguard-rs-34ba2cd5c5826d8d01c580b05e4c9a883f8a12a9.zip |
drop error-chain in favor of Failure crate
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(()) } |