Struct unsegen_jsonviewer::json_ext::Object[][src]

pub struct Object { /* fields omitted */ }
Expand description

A binary tree implementation of a string -> JsonValue map. You normally don’t have to interact with instances of Object, much more likely you will be using the JsonValue::Object variant, which wraps around this struct.

Implementations

impl Object[src]

pub fn new() -> Object[src]

Create a new, empty instance of Object. Empty Object performs no allocation until a value is inserted into it.

pub fn with_capacity(capacity: usize) -> Object[src]

Create a new Object with memory preallocated for capacity number of entries.

pub fn insert(&mut self, key: &str, value: JsonValue)[src]

Insert a new entry, or override an existing one. Note that key has to be a &str slice and not an owned String. The internals of Object will handle the heap allocation of the key if needed for better performance.

pub fn override_last(&mut self, value: JsonValue)[src]

👎 Deprecated since 0.11.11:

Was only meant for internal use

pub fn get(&self, key: &str) -> Option<&JsonValue>[src]

pub fn get_mut(&mut self, key: &str) -> Option<&mut JsonValue>[src]

pub fn remove(&mut self, key: &str) -> Option<JsonValue>[src]

Attempts to remove the value behind key, if successful will return the JsonValue stored behind the key.

pub fn len(&self) -> usize[src]

pub fn is_empty(&self) -> bool[src]

pub fn clear(&mut self)[src]

Wipe the Object clear. The capacity will remain untouched.

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

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

pub fn dump(&self) -> String[src]

Prints out the value as JSON string.

pub fn pretty(&self, spaces: u16) -> String[src]

Pretty prints out the value as JSON string. Takes an argument that’s number of spaces to indent new blocks with.

Trait Implementations

impl Clone for Object[src]

pub fn clone(&self) -> Object[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Object[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl From<Object> for JsonValue[src]

pub fn from(val: Object) -> JsonValue[src]

Performs the conversion.

impl<'a> Index<&'a String> for Object[src]

type Output = JsonValue

The returned type after indexing.

pub fn index(&self, index: &String) -> &JsonValue[src]

Performs the indexing (container[index]) operation. Read more

impl<'a> Index<&'a str> for Object[src]

Implements indexing by &str to easily access object members:

Example

let value = object!{
    "foo" => "bar"
};

if let JsonValue::Object(object) = value {
  assert!(object["foo"] == "bar");
}

type Output = JsonValue

The returned type after indexing.

pub fn index(&self, index: &str) -> &JsonValue[src]

Performs the indexing (container[index]) operation. Read more

impl Index<String> for Object[src]

type Output = JsonValue

The returned type after indexing.

pub fn index(&self, index: String) -> &JsonValue[src]

Performs the indexing (container[index]) operation. Read more

impl<'a> IndexMut<&'a String> for Object[src]

pub fn index_mut(&mut self, index: &String) -> &mut JsonValue[src]

Performs the mutable indexing (container[index]) operation. Read more

impl<'a> IndexMut<&'a str> for Object[src]

Implements mutable indexing by &str to easily modify object members:

Example

let value = object!{};

if let JsonValue::Object(mut object) = value {
  object["foo"] = 42.into();

  assert!(object["foo"] == 42);
}

pub fn index_mut(&mut self, index: &str) -> &mut JsonValue[src]

Performs the mutable indexing (container[index]) operation. Read more

impl IndexMut<String> for Object[src]

pub fn index_mut(&mut self, index: String) -> &mut JsonValue[src]

Performs the mutable indexing (container[index]) operation. Read more

impl PartialEq<JsonValue> for Object[src]

pub fn eq(&self, other: &JsonValue) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<'a> PartialEq<Object> for &'a JsonValue[src]

pub fn eq(&self, other: &Object) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<Object> for JsonValue[src]

pub fn eq(&self, other: &Object) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialEq<Object> for Object[src]

pub fn eq(&self, other: &Object) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

Auto Trait Implementations

impl RefUnwindSafe for Object

impl Send for Object

impl Sync for Object

impl Unpin for Object

impl UnwindSafe for Object

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.