[−][src]Struct encon::Map
Represents a mapping of string keys to WithIntent
values (a wrapper around Encryptable
).
Example
use encon::Map; use serde_json::json; use serde_json::from_value; let map: Map = from_value(json!({ "k1": "foo", "k2": { "_encrypted": [ "c10a4bed22a6511e0b6724f8c62832a6d85c154272b3b57a355568bb6af62ca99cc98e", "226163081382e58b796fc212e5427546aa9efb2923f561bc7e3b2418ec9166ea69309d", "aa0fee467e6ca538d9f7c29e" ] } })).unwrap();
Implementations
impl Map
[src]
pub fn new() -> Self
[src]
Creates an empty Map
pub fn decrypt_all_in_place(
&mut self,
password: &Password
) -> Result<(), EnconError>
[src]
&mut self,
password: &Password
) -> Result<(), EnconError>
Attempts to decrypt all fields with the provided key. This does not change the intent
of the fields. You may later call .apply_all_intents()
to re-encrypt any keys that were
originally encrypted; possibly with a different password.
pub fn apply_all_intents(
&mut self,
password: &Password
) -> Result<(), EnconError>
[src]
&mut self,
password: &Password
) -> Result<(), EnconError>
Applies the intended state of each field. See WithIntent::apply_intent
for details.
pub fn to_json_pretty(&self) -> Result<String, MapToJsonError>
[src]
Converts the Map
to pretty-printed JSON.
This method requires that all intents have been applied (use apply_all_intents
to accomplish this). If intents aren't applied, then Err(MapToJsonError::ApplyRequired)
will be returned
pub fn to_json_compact(&self) -> Result<String, MapToJsonError>
[src]
Similar to to_json_pretty
, except printed as compactly as possible.
This is serde_json::to_string
, but named explicitly since you usually want
the to_json_pretty
variant.
pub fn insert(
&mut self,
key: impl Into<String>,
value: impl Into<WithIntent>
) -> Option<WithIntent>
[src]
&mut self,
key: impl Into<String>,
value: impl Into<WithIntent>
) -> Option<WithIntent>
Insert a WithIntent
/Encryptable
, returning the existing WithIntent
, if any.
pub fn keys(&self) -> impl Iterator<Item = &String>
[src]
Return an iterator over the keys of the map, in their order
pub fn values(&self) -> impl Iterator<Item = &WithIntent>
[src]
Return an iterator over the values of the map, in their order
pub fn entry(&mut self, key: String) -> Entry<'_, String, WithIntent>
[src]
Get the given key’s corresponding entry in the map for insertion and/or in-place manipulation.
pub fn get(&self, key: &String) -> Option<&WithIntent>
[src]
Return a reference to the value stored for key, if it is present, else None.
pub fn get_mut(&mut self, key: &String) -> Option<&mut WithIntent>
[src]
pub fn iter(&self) -> Iter<'_, String, WithIntent>
[src]
Returns a double-ended iterator visiting all key-value pairs in order of insertion. Iterator element type is (&'a String, &'a mut WithIntent)
pub fn iter_mut(&mut self) -> IterMut<'_, String, WithIntent>
[src]
Returns a double-ended iterator visiting all key-value pairs in order of insertion. Iterator element type is (&'a String, &'a mut WithIntent)
pub fn remove(&mut self, key: &String) -> Option<WithIntent>
[src]
pub fn sort_keys(&mut self)
[src]
pub fn reverse(&mut self)
[src]
pub fn len(&self) -> usize
[src]
Returns the number of elements in the map.
pub fn is_empty(&self) -> bool
[src]
Returns true if the map contains no elements.
Trait Implementations
impl Clone for Map
[src]
impl Debug for Map
[src]
impl Default for Map
[src]
impl<'de> Deserialize<'de> for Map
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl<'a> IntoIterator for &'a Map
[src]
type Item = (&'a String, &'a WithIntent)
The type of the elements being iterated over.
type IntoIter = Iter<'a, String, WithIntent>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a> IntoIterator for &'a mut Map
[src]
Auto Trait Implementations
impl RefUnwindSafe for Map
impl Send for Map
impl Sync for Map
impl Unpin for Map
impl UnwindSafe for Map
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,