diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2018-12-12 16:36:25 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2018-12-12 16:36:25 +0100 |
| commit | 26878962c66a1f76af86b8fd1c9e66b41b9a8a1f (patch) | |
| tree | 5a6a43150cb097e8705adf361af0f2c9dcdfef9b | |
| parent | f0baa65b0957f84e0b514b3d50368073495c19ed (diff) | |
| download | mullvadvpn-26878962c66a1f76af86b8fd1c9e66b41b9a8a1f.tar.xz mullvadvpn-26878962c66a1f76af86b8fd1c9e66b41b9a8a1f.zip | |
Upgrade talpid-types to Rust 2018
| -rw-r--r-- | Cargo.lock | 1 | ||||
| -rw-r--r-- | talpid-types/Cargo.toml | 4 | ||||
| -rw-r--r-- | talpid-types/src/lib.rs | 3 | ||||
| -rw-r--r-- | talpid-types/src/net.rs | 23 | ||||
| -rw-r--r-- | talpid-types/src/tunnel.rs | 4 |
5 files changed, 17 insertions, 18 deletions
diff --git a/Cargo.lock b/Cargo.lock index 52030fc501..f816b5051f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1837,7 +1837,6 @@ name = "talpid-types" version = "0.1.0" dependencies = [ "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)", ] [[package]] diff --git a/talpid-types/Cargo.toml b/talpid-types/Cargo.toml index d54fc0e303..39ef556cd3 100644 --- a/talpid-types/Cargo.toml +++ b/talpid-types/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Mullvad VPN <admin@mullvad.net>"] description = "Common base structures for talpid" license = "GPL-3.0" +edition = "2018" [dependencies] -serde_derive = "1.0" -serde = "1.0" +serde = { version = "1.0", features = ["derive"] } diff --git a/talpid-types/src/lib.rs b/talpid-types/src/lib.rs index 4baf3e0e1d..84654734b6 100644 --- a/talpid-types/src/lib.rs +++ b/talpid-types/src/lib.rs @@ -6,8 +6,5 @@ //! GNU General Public License as published by the Free Software Foundation, either version 3 of //! the License, or (at your option) any later version. -#[macro_use] -extern crate serde_derive; - pub mod net; pub mod tunnel; diff --git a/talpid-types/src/net.rs b/talpid-types/src/net.rs index 8798ecf1d9..03bb113bf1 100644 --- a/talpid-types/src/net.rs +++ b/talpid-types/src/net.rs @@ -1,7 +1,10 @@ -use std::error::Error; -use std::fmt; -use std::net::{IpAddr, SocketAddr}; -use std::str::FromStr; +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)] @@ -34,7 +37,7 @@ pub enum TunnelEndpointData { } impl fmt::Display for TunnelEndpointData { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { match self { TunnelEndpointData::OpenVpn(openvpn_data) => { write!(f, "OpenVPN ")?; @@ -71,7 +74,7 @@ pub struct OpenVpnEndpointData { } impl fmt::Display for OpenVpnEndpointData { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { write!(f, "{} port {}", self.protocol, self.port) } } @@ -82,7 +85,7 @@ pub struct WireguardEndpointData { } impl fmt::Display for WireguardEndpointData { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { write!(f, "port {}", self.port) } } @@ -108,7 +111,7 @@ impl Endpoint { } impl fmt::Display for Endpoint { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { write!(f, "{}:{}", self.address, self.protocol) } } @@ -136,7 +139,7 @@ impl FromStr for TransportProtocol { } impl fmt::Display for TransportProtocol { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { TransportProtocol::Udp => "UDP".fmt(fmt), TransportProtocol::Tcp => "TCP".fmt(fmt), @@ -148,7 +151,7 @@ impl fmt::Display for TransportProtocol { pub struct TransportProtocolParseError; impl fmt::Display for TransportProtocolParseError { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.write_str(self.description()) } } diff --git a/talpid-types/src/tunnel.rs b/talpid-types/src/tunnel.rs index 642714969b..7ac42aa92c 100644 --- a/talpid-types/src/tunnel.rs +++ b/talpid-types/src/tunnel.rs @@ -1,5 +1,5 @@ +use serde::{Deserialize, Serialize}; use std::fmt; - use super::net::TunnelEndpoint; /// Event resulting from a transition to a new tunnel state. @@ -59,7 +59,7 @@ pub enum BlockReason { } impl fmt::Display for BlockReason { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use self::BlockReason::*; let description = match *self { AuthFailed(ref reason) => { |
