summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-06-28 23:07:14 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-07-03 10:53:20 -0300
commit3bfee46d36b96a90cd300098db0c6d3241140525 (patch)
treeee7ab81888b4b5965d979df1d0e1c31d0949d530
parent771cd589cf50cca9fbe070e96fb25b77dbe73ee7 (diff)
downloadmullvadvpn-3bfee46d36b96a90cd300098db0c6d3241140525.tar.xz
mullvadvpn-3bfee46d36b96a90cd300098db0c6d3241140525.zip
Create `Result` type alias
-rw-r--r--mullvad-tests/src/lib.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/mullvad-tests/src/lib.rs b/mullvad-tests/src/lib.rs
index 2723672d58..9bc4755827 100644
--- a/mullvad-tests/src/lib.rs
+++ b/mullvad-tests/src/lib.rs
@@ -32,6 +32,8 @@ use tempfile::TempDir;
use self::mock_openvpn::MOCK_OPENVPN_ARGS_FILE;
use self::platform_specific::*;
+type Result<T> = ::std::result::Result<T, String>;
+
#[cfg(unix)]
mod platform_specific {
pub const DAEMON_EXECUTABLE_PATH: &str = "../target/debug/mullvad-daemon";
@@ -228,7 +230,7 @@ impl DaemonRunner {
}
}
- pub fn rpc_client(&mut self) -> Result<DaemonRpcClient, String> {
+ pub fn rpc_client(&mut self) -> Result<DaemonRpcClient> {
if !self.rpc_address_file.exists() {
wait_for_file_write_finish(&self.rpc_address_file, Duration::from_secs(10));
}
@@ -288,7 +290,7 @@ pub struct MockOpenVpnPluginRpcClient {
}
impl MockOpenVpnPluginRpcClient {
- pub fn new(address: String, credentials: String) -> Result<Self, String> {
+ pub fn new(address: String, credentials: String) -> Result<Self> {
let rpc = WsIpcClient::connect(&address).map_err(|error| {
format!("Failed to create Mock OpenVPN plugin RPC client: {}", error)
})?;
@@ -296,19 +298,19 @@ impl MockOpenVpnPluginRpcClient {
Ok(MockOpenVpnPluginRpcClient { rpc, credentials })
}
- pub fn authenticate(&mut self) -> Result<bool, String> {
+ pub fn authenticate(&mut self) -> Result<bool> {
self.rpc
.call("authenticate", &[&self.credentials])
.map_err(|error| format!("Failed to authenticate mock OpenVPN IPC client: {}", error))
}
- pub fn authenticate_with(&mut self, credentials: &str) -> Result<bool, String> {
+ pub fn authenticate_with(&mut self, credentials: &str) -> Result<bool> {
self.rpc
.call("authenticate", &[credentials])
.map_err(|error| format!("Failed to authenticate mock OpenVPN IPC client: {}", error))
}
- pub fn up(&mut self) -> Result<(), String> {
+ pub fn up(&mut self) -> Result<()> {
let mut env: HashMap<String, String> = HashMap::new();
env.insert("dev".to_owned(), "lo".to_owned());
@@ -318,7 +320,7 @@ impl MockOpenVpnPluginRpcClient {
self.send_event(OpenVpnPluginEvent::Up, env)
}
- pub fn route_predown(&mut self) -> Result<(), String> {
+ pub fn route_predown(&mut self) -> Result<()> {
self.send_event(OpenVpnPluginEvent::RoutePredown, HashMap::new())
}
@@ -326,7 +328,7 @@ impl MockOpenVpnPluginRpcClient {
&mut self,
event: OpenVpnPluginEvent,
env: HashMap<String, String>,
- ) -> Result<(), String> {
+ ) -> Result<()> {
self.rpc
.call("openvpn_event", &(event, env))
.map_err(|error| format!("Failed to send mock OpenVPN event {:?}: {}", event, error))