summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2018-12-12 16:45:02 +0100
committerLinus Färnstrand <linus@mullvad.net>2018-12-12 17:13:02 +0100
commitff1cdbfa21f976bb9862f1a20642a3192aad8ca1 (patch)
tree0145e0440fe3bb2b7df6bb4864e6e7ff0c8a95af
parent26878962c66a1f76af86b8fd1c9e66b41b9a8a1f (diff)
downloadmullvadvpn-ff1cdbfa21f976bb9862f1a20642a3192aad8ca1.tar.xz
mullvadvpn-ff1cdbfa21f976bb9862f1a20642a3192aad8ca1.zip
Upgrade mullvad-types to Rust 2018
-rw-r--r--Cargo.lock1
-rw-r--r--mullvad-types/Cargo.toml4
-rw-r--r--mullvad-types/src/account.rs4
-rw-r--r--mullvad-types/src/auth_failed.rs2
-rw-r--r--mullvad-types/src/custom_tunnel.rs3
-rw-r--r--mullvad-types/src/lib.rs12
-rw-r--r--mullvad-types/src/location.rs1
-rw-r--r--mullvad-types/src/relay_constraints.rs15
-rw-r--r--mullvad-types/src/relay_list.rs3
-rw-r--r--mullvad-types/src/settings.rs9
-rw-r--r--mullvad-types/src/states.rs2
-rw-r--r--mullvad-types/src/version.rs2
-rw-r--r--talpid-types/src/net.rs2
-rw-r--r--talpid-types/src/tunnel.rs2
14 files changed, 25 insertions, 37 deletions
diff --git a/Cargo.lock b/Cargo.lock
index f816b5051f..42776fe2fa 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1096,7 +1096,6 @@ dependencies = [
"mullvad-paths 0.1.0",
"regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)",
"talpid-types 0.1.0",
]
diff --git a/mullvad-types/Cargo.toml b/mullvad-types/Cargo.toml
index 0f67cb1eb7..8239696b9b 100644
--- a/mullvad-types/Cargo.toml
+++ b/mullvad-types/Cargo.toml
@@ -4,11 +4,11 @@ version = "0.1.0"
authors = ["Mullvad VPN <admin@mullvad.net>"]
description = "Common base data structures for Mullvad VPN client"
license = "GPL-3.0"
+edition = "2018"
[dependencies]
chrono = { version = "0.4", features = ["serde"] }
-serde_derive = "1.0"
-serde = "1.0"
+serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
error-chain = "0.12"
log = "0.4"
diff --git a/mullvad-types/src/account.rs b/mullvad-types/src/account.rs
index 631c5fbdc8..c8de40ac54 100644
--- a/mullvad-types/src/account.rs
+++ b/mullvad-types/src/account.rs
@@ -1,5 +1,5 @@
-use chrono::offset::Utc;
-use chrono::DateTime;
+use chrono::{offset::Utc, DateTime};
+use serde::{Deserialize, Serialize};
pub type AccountToken = String;
diff --git a/mullvad-types/src/auth_failed.rs b/mullvad-types/src/auth_failed.rs
index 58c6ecd370..a580563137 100644
--- a/mullvad-types/src/auth_failed.rs
+++ b/mullvad-types/src/auth_failed.rs
@@ -50,7 +50,7 @@ impl<'a> From<&'a str> for AuthFailed {
}
impl ::std::fmt::Display for AuthFailed {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
use self::AuthFailedInner::*;
match self.reason {
InvalidAccount => write!(f, "{}", INVALID_ACCOUNT_MSG),
diff --git a/mullvad-types/src/custom_tunnel.rs b/mullvad-types/src/custom_tunnel.rs
index 0ada1c7643..0c1da70c50 100644
--- a/mullvad-types/src/custom_tunnel.rs
+++ b/mullvad-types/src/custom_tunnel.rs
@@ -1,3 +1,4 @@
+use serde::{Deserialize, Serialize};
use std::{
fmt,
net::{IpAddr, ToSocketAddrs},
@@ -29,7 +30,7 @@ impl CustomTunnelEndpoint {
}
impl fmt::Display for CustomTunnelEndpoint {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} over {}", self.host, self.tunnel)
}
}
diff --git a/mullvad-types/src/lib.rs b/mullvad-types/src/lib.rs
index 905ff8aaf4..a972719460 100644
--- a/mullvad-types/src/lib.rs
+++ b/mullvad-types/src/lib.rs
@@ -6,20 +6,8 @@
//! GNU General Public License as published by the Free Software Foundation, either version 3 of
//! the License, or (at your option) any later version.
-extern crate chrono;
-extern crate regex;
-extern crate serde;
-#[macro_use]
-extern crate serde_derive;
-
-extern crate mullvad_paths;
-extern crate talpid_types;
-
-extern crate log;
#[macro_use]
extern crate error_chain;
-extern crate lazy_static;
-
pub mod account;
pub mod auth_failed;
diff --git a/mullvad-types/src/location.rs b/mullvad-types/src/location.rs
index 2c420fafc5..7f326ead42 100644
--- a/mullvad-types/src/location.rs
+++ b/mullvad-types/src/location.rs
@@ -1,3 +1,4 @@
+use serde::{Deserialize, Serialize};
use std::net::IpAddr;
pub type CountryCode = String;
diff --git a/mullvad-types/src/relay_constraints.rs b/mullvad-types/src/relay_constraints.rs
index 59df5e902b..f2799cc07c 100644
--- a/mullvad-types/src/relay_constraints.rs
+++ b/mullvad-types/src/relay_constraints.rs
@@ -1,8 +1,7 @@
use crate::location::{CityCode, CountryCode, Hostname};
use crate::CustomTunnelEndpoint;
-
+use serde::{Deserialize, Serialize};
use std::fmt;
-
use talpid_types::net::{OpenVpnEndpointData, TransportProtocol, WireguardEndpointData};
@@ -58,7 +57,7 @@ pub enum RelaySettings {
}
impl fmt::Display for RelaySettings {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self {
RelaySettings::CustomTunnelEndpoint(endpoint) => {
write!(f, "custom endpoint {}", endpoint)
@@ -107,7 +106,7 @@ impl RelayConstraints {
}
impl fmt::Display for RelayConstraints {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self.tunnel {
Constraint::Any => write!(f, "any relay")?,
Constraint::Only(ref tunnel_constraint) => tunnel_constraint.fmt(f)?,
@@ -133,7 +132,7 @@ pub enum LocationConstraint {
}
impl fmt::Display for LocationConstraint {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self {
LocationConstraint::Country(country) => write!(f, "country {}", country),
LocationConstraint::City(country, city) => write!(f, "city {}, {}", city, country),
@@ -154,7 +153,7 @@ pub enum TunnelConstraints {
}
impl fmt::Display for TunnelConstraints {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self {
TunnelConstraints::OpenVpn(openvpn_constraints) => {
write!(f, "OpenVPN over ")?;
@@ -193,7 +192,7 @@ pub struct OpenVpnConstraints {
}
impl fmt::Display for OpenVpnConstraints {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self.port {
Constraint::Any => write!(f, "any port")?,
Constraint::Only(port) => write!(f, "port {}", port)?,
@@ -218,7 +217,7 @@ pub struct WireguardConstraints {
}
impl fmt::Display for WireguardConstraints {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self.port {
Constraint::Any => write!(f, "any port"),
Constraint::Only(port) => write!(f, "port {}", port),
diff --git a/mullvad-types/src/relay_list.rs b/mullvad-types/src/relay_list.rs
index 26fcbffee2..bc5d66eb80 100644
--- a/mullvad-types/src/relay_list.rs
+++ b/mullvad-types/src/relay_list.rs
@@ -1,7 +1,6 @@
use crate::location::{CityCode, CountryCode, Location};
-
+use serde::{Deserialize, Serialize};
use std::net::Ipv4Addr;
-
use talpid_types::net::{OpenVpnEndpointData, WireguardEndpointData};
diff --git a/mullvad-types/src/settings.rs b/mullvad-types/src/settings.rs
index a6a1b95e2c..70f5d6b35e 100644
--- a/mullvad-types/src/settings.rs
+++ b/mullvad-types/src/settings.rs
@@ -1,13 +1,10 @@
-extern crate serde_json;
-
use crate::relay_constraints::{
Constraint, LocationConstraint, RelayConstraints, RelaySettings, RelaySettingsUpdate,
};
use log::{debug, info};
-
-use std::fs::File;
-use std::io;
-use std::path::PathBuf;
+use serde::{Deserialize, Serialize};
+use serde_json;
+use std::{fs::File, io, path::PathBuf};
use talpid_types::net::{OpenVpnProxySettings, OpenVpnProxySettingsValidation, TunnelOptions};
error_chain! {
diff --git a/mullvad-types/src/states.rs b/mullvad-types/src/states.rs
index 9f83a9655d..a5bb8a8b59 100644
--- a/mullvad-types/src/states.rs
+++ b/mullvad-types/src/states.rs
@@ -1,3 +1,5 @@
+use serde::{Deserialize, Serialize};
+
/// Represents the state the client strives towards.
/// When in `Secured`, the client should keep the computer from leaking and try to
/// establish a VPN tunnel if it is not up.
diff --git a/mullvad-types/src/version.rs b/mullvad-types/src/version.rs
index 6efa47806e..16e28734bc 100644
--- a/mullvad-types/src/version.rs
+++ b/mullvad-types/src/version.rs
@@ -1,3 +1,5 @@
+use serde::{Deserialize, Serialize};
+
/// AppVersionInfo represents the current stable and the current latest release versions of the
/// Mullvad VPN app.
#[derive(Debug, Clone, Serialize, Deserialize)]
diff --git a/talpid-types/src/net.rs b/talpid-types/src/net.rs
index 03bb113bf1..b7a67f37c5 100644
--- a/talpid-types/src/net.rs
+++ b/talpid-types/src/net.rs
@@ -1,10 +1,10 @@
+use serde::{Deserialize, Serialize};
use std::{
error::Error,
fmt,
net::{IpAddr, SocketAddr},
str::FromStr,
};
-use serde::{Deserialize, Serialize};
/// Represents one tunnel endpoint. Address, plus extra parameters specific to tunnel protocol.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize, Serialize)]
diff --git a/talpid-types/src/tunnel.rs b/talpid-types/src/tunnel.rs
index 7ac42aa92c..f3b28e8bfe 100644
--- a/talpid-types/src/tunnel.rs
+++ b/talpid-types/src/tunnel.rs
@@ -1,6 +1,6 @@
+use super::net::TunnelEndpoint;
use serde::{Deserialize, Serialize};
use std::fmt;
-use super::net::TunnelEndpoint;
/// Event resulting from a transition to a new tunnel state.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]