From 9b5bc94b5de8c7c1e226887f5e986ecef5967d06 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 21 Feb 2021 21:57:38 -0500 Subject: persist uri match type when editing --- src/api.rs | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'src/api.rs') diff --git a/src/api.rs b/src/api.rs index ca92e25..40fe422 100644 --- a/src/api.rs +++ b/src/api.rs @@ -4,6 +4,41 @@ use crate::json::{ DeserializeJsonWithPath as _, DeserializeJsonWithPathAsync as _, }; +#[derive( + serde_repr::Serialize_repr, + serde_repr::Deserialize_repr, + Debug, + Copy, + Clone, + PartialEq, + Eq, +)] +#[repr(u8)] +pub enum UriMatchType { + Domain = 0, + Host = 1, + StartsWith = 2, + Exact = 3, + RegularExpression = 4, + Never = 5, +} + +impl std::fmt::Display for UriMatchType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + #[allow(clippy::enum_glob_use)] + use UriMatchType::*; + let s = match self { + Domain => "domain", + Host => "host", + StartsWith => "starts_with", + Exact => "exact", + RegularExpression => "regular_expression", + Never => "never", + }; + write!(f, "{}", s) + } +} + #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum TwoFactorProviderType { Authenticator = 0, @@ -245,7 +280,12 @@ impl SyncResCipher { std::vec::Vec::new, |uris| { uris.iter() - .filter_map(|uri| uri.uri.clone()) + .filter_map(|uri| { + uri.uri.clone().map(|s| crate::db::Uri { + uri: s, + match_type: uri.match_type, + }) + }) .collect() }, ), @@ -351,6 +391,8 @@ struct CipherLogin { struct CipherLoginUri { #[serde(rename = "Uri")] uri: Option, + #[serde(rename = "Match")] + match_type: Option, } #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] @@ -648,7 +690,8 @@ impl Client { Some( uris.iter() .map(|s| CipherLoginUri { - uri: Some(s.to_string()), + uri: Some(s.uri.to_string()), + match_type: s.match_type, }) .collect(), ) @@ -780,7 +823,8 @@ impl Client { Some( uris.iter() .map(|s| CipherLoginUri { - uri: Some(s.to_string()), + uri: Some(s.uri.to_string()), + match_type: s.match_type, }) .collect(), ) -- cgit v1.2.3-54-g00ecf