Struct Object

Source
pub struct Object<'a> { /* private fields */ }
Expand description

Container that stores its elements with numeric keys and provides get by key access. Keys are of &str type

Implementations§

Source§

impl<'a> Object<'a>

Source

pub fn add_value<'c, 'p: 'c, 'd>( &'p mut self, key: &str, value: impl AsValue<'d>, ) -> Result<Value<'c>, Error>

Adds new field with given name and value to this object

Source

pub fn as_bytes(&self) -> &[u8]

Returns slice of bytes representing current document.

It’s guaranteed to be subslice of initial buffer and for root document it will starting at 0.

So by taking it’s len you can get how many bytes in buffer are used

Source

pub fn count(&self) -> usize

Returns number of elements in this object

Source

pub fn empty() -> Object<'static>

Returns new empty object

Object is read only so no new elements can be added to it

Source

pub fn empty_mut(allocation: impl Into<Allocation<'a>>) -> Result<Self, Error>

Creates a new object that uses given allocation for storage

Source

pub fn get(&self, key: &str) -> Option<Value<'_>>

Get value with specific key

Source

pub fn iter(&self) -> impl Iterator<Item = (&str, Value<'_>)>

Iterate over elements of this object

Trait Implementations§

Source§

impl<'a> Debug for Object<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for Object<'a>

Source§

fn eq(&self, other: &Object<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> TryFrom<Value<'a>> for Object<'a>

Source§

type Error = Value<'a>

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value<'a>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> Eq for Object<'a>

Source§

impl<'a> StructuralPartialEq for Object<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Object<'a>

§

impl<'a> RefUnwindSafe for Object<'a>

§

impl<'a> !Send for Object<'a>

§

impl<'a> !Sync for Object<'a>

§

impl<'a> Unpin for Object<'a>

§

impl<'a> UnwindSafe for Object<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.