[][src]Struct encon::PlainMap

pub struct PlainMap { /* fields omitted */ }

Similar to Map, but with all fields decrypted into Values.

You can acquire this by calling Map::to_plain_map with a password.

Implementations

impl PlainMap[src]

pub fn new() -> Self[src]

pub fn to_json_pretty(&self) -> Result<String, MapToJsonError>[src]

Converts the PlainMap to pretty-printed JSON.

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 to_value(&self) -> Value[src]

Convert this to a serde_json::Value (in the Object/Map variant).

pub fn insert(
    &mut self,
    key: impl Into<String>,
    value: impl Into<Value>
) -> Option<Value>
[src]

Insert a Value, returning the existing Value, if any.

pub fn insert_before(
    &mut self,
    index: usize,
    key: impl Into<String>,
    value: impl Into<Value>
) -> Option<Value>
[src]

Inserts the item before the specified index. If the index is >= the number of items, it's simply appended to the end.

use encon::PlainMap;

let mut map = PlainMap::new();
map.insert("foo", serde_json::json!("a"));
map.insert("baz", serde_json::json!("c"));
map.insert_before(1, "bar", serde_json::json!("b"));

let keys = map.keys().map(|k| k as &str).collect::<Vec<_>>();
assert_eq!(keys, vec!["foo", "bar", "baz"]);

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 = &Value>[src]

Return an iterator over the values of the map, in their order

pub fn entry(&mut self, key: String) -> Entry<'_, String, Value>[src]

Get the given key’s corresponding entry in the map for insertion and/or in-place manipulation.

pub fn get(&self, key: impl Into<String>) -> Option<&Value>[src]

Return a reference to the value stored for key, if it is present, else None.

pub fn get_mut(&mut self, key: impl Into<String>) -> Option<&mut Value>[src]

Return a mutable reference to the value stored for key, if it is present, else None.

pub fn iter(&self) -> Iter<'_, String, Value>[src]

Returns a double-ended iterator visiting all key-value pairs in order of insertion. Iterator element type is (&'a String, &'a mut Value)

pub fn iter_mut(&mut self) -> IterMut<'_, String, Value>[src]

Returns a double-ended iterator visiting all key-value pairs in order of insertion. Iterator element type is (&'a String, &'a mut Value)

pub fn remove(&mut self, key: impl Into<String>) -> Option<Value>[src]

Remove the entry for this key, and return it if it exists.

pub fn sort_keys(&mut self)[src]

Remove the entry for this key, and return it if it exists.

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 PlainMap[src]

impl Debug for PlainMap[src]

impl Default for PlainMap[src]

impl IntoIterator for PlainMap[src]

type Item = (String, Value)

The type of the elements being iterated over.

type IntoIter = IntoIter<String, Value>

Which kind of iterator are we turning this into?

impl<'a> IntoIterator for &'a PlainMap[src]

type Item = (&'a String, &'a Value)

The type of the elements being iterated over.

type IntoIter = Iter<'a, String, Value>

Which kind of iterator are we turning this into?

impl<'a> IntoIterator for &'a mut PlainMap[src]

type Item = (&'a String, &'a mut Value)

The type of the elements being iterated over.

type IntoIter = IterMut<'a, String, Value>

Which kind of iterator are we turning this into?

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.