diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-07-18 15:35:11 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-08-24 11:12:43 +0200 |
| commit | 4acde38c70f872dbda1759041d33ed4f36f7d951 (patch) | |
| tree | ec0407420de69dc461431fe57c4552fabcd1051d | |
| parent | 063ece41a0791130618c9a9c6410ecceef4ef894 (diff) | |
| download | mullvadvpn-4acde38c70f872dbda1759041d33ed4f36f7d951.tar.xz mullvadvpn-4acde38c70f872dbda1759041d33ed4f36f7d951.zip | |
Move account/location types to mullvad-types
| -rw-r--r-- | mullvad-daemon/src/management_interface.rs | 25 | ||||
| -rw-r--r-- | mullvad-types/Cargo.toml | 1 | ||||
| -rw-r--r-- | mullvad-types/src/account.rs | 9 | ||||
| -rw-r--r-- | mullvad-types/src/lib.rs | 3 | ||||
| -rw-r--r-- | mullvad-types/src/location.rs | 8 |
5 files changed, 29 insertions, 17 deletions
diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index f78f991c0e..59f2035d41 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -5,6 +5,8 @@ use jsonrpc_core::futures::{BoxFuture, Future, future, sync}; use jsonrpc_macros::pubsub; use jsonrpc_pubsub::{PubSubHandler, PubSubMetadata, Session, SubscriptionId}; use jsonrpc_ws_server; +use mullvad_types::account::{AccountData, AccountToken}; +use mullvad_types::location::{CountryCode, Location}; use mullvad_types::states::{DaemonState, TargetState}; use serde; @@ -19,22 +21,6 @@ use talpid_ipc; use uuid; -pub type AccountToken = String; -pub type CountryCode = String; - -#[derive(Serialize)] -pub struct AccountData { - pub paid_until: String, -} - -#[derive(Serialize)] -pub struct Location { - pub latlong: [f64; 2], - pub country: String, - pub city: String, -} - - build_rpc_trait! { pub trait ManagementInterfaceApi { type Metadata; @@ -252,7 +238,12 @@ impl<T: From<TunnelCommand> + 'static + Send> ManagementInterfaceApi for Managem fn get_account_data(&self, _account_token: AccountToken) -> Result<AccountData, Error> { trace!("get_account_data"); - Ok(AccountData { paid_until: "2018-12-31T16:00:00.000Z".to_owned() },) + // Just mock implementation, so locally importing temporarily. + use chrono::DateTime; + use chrono::offset::Utc; + use std::str::FromStr; + let expiry: DateTime<Utc> = DateTime::from_str("2018-12-31T16:00:00.000Z").unwrap(); + Ok(AccountData { expiry }) } fn get_countries(&self) -> Result<HashMap<CountryCode, String>, Error> { diff --git a/mullvad-types/Cargo.toml b/mullvad-types/Cargo.toml index 9f5e3a4202..cedea3d517 100644 --- a/mullvad-types/Cargo.toml +++ b/mullvad-types/Cargo.toml @@ -4,5 +4,6 @@ version = "0.1.0" authors = ["Linus Färnstrand <linus@mullvad.net>"] [dependencies] +chrono = { version = "0.4", features = ["serde"] } serde_derive = "1.0" serde = "1.0" diff --git a/mullvad-types/src/account.rs b/mullvad-types/src/account.rs new file mode 100644 index 0000000000..5b335514f1 --- /dev/null +++ b/mullvad-types/src/account.rs @@ -0,0 +1,9 @@ +use chrono::DateTime; +use chrono::offset::Utc; + +pub type AccountToken = String; + +#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)] +pub struct AccountData { + pub expiry: DateTime<Utc>, +} diff --git a/mullvad-types/src/lib.rs b/mullvad-types/src/lib.rs index 602a43cb29..4c74f3814c 100644 --- a/mullvad-types/src/lib.rs +++ b/mullvad-types/src/lib.rs @@ -1,5 +1,8 @@ +extern crate chrono; #[macro_use] extern crate serde_derive; extern crate serde; +pub mod account; +pub mod location; pub mod states; diff --git a/mullvad-types/src/location.rs b/mullvad-types/src/location.rs new file mode 100644 index 0000000000..72146998b3 --- /dev/null +++ b/mullvad-types/src/location.rs @@ -0,0 +1,8 @@ +pub type CountryCode = String; + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Location { + pub latlong: [f64; 2], + pub country: String, + pub city: String, +} |
