juniper

Struct Object

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

An Object value

Implementations§

Source§

impl<S> Object<S>

Source

pub fn with_capacity(size: usize) -> Self

Create a new Object value with a fixed number of preallocated slots for field-value pairs

Source

pub fn add_field<K>(&mut self, k: K, value: Value<S>) -> Option<Value<S>>
where K: AsRef<str> + Into<String>,

Add a new field with a value

If there is already a field for the given key any both values are objects, they are merged.

Otherwise the existing value is replaced and returned.

Source

pub fn contains_field<K: AsRef<str>>(&self, k: K) -> bool

Check if the object already contains a field with the given name

Source

pub fn iter(&self) -> impl Iterator<Item = (&String, &Value<S>)>

Get a iterator over all field value pairs

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = (&String, &mut Value<S>)>

Get a iterator over all mutable field value pairs

Source

pub fn field_count(&self) -> usize

Get the current number of fields

Source

pub fn get_field_value<K: AsRef<str>>(&self, key: K) -> Option<&Value<S>>

Get the value for a given field

Source

pub fn get_mut_field_value<K: AsRef<str>>( &mut self, key: K, ) -> Option<&mut Value<S>>

Get the mutable value for a given field

Trait Implementations§

Source§

impl<S: Clone> Clone for Object<S>

Source§

fn clone(&self) -> Object<S>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug> Debug for Object<S>

Source§

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

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

impl<S> From<Object<S>> for Value<S>

Source§

fn from(o: Object<S>) -> Self

Converts to this type from the input type.
Source§

impl<K, S> FromIterator<(K, Value<S>)> for Object<S>
where K: AsRef<str> + Into<String>,

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = (K, Value<S>)>,

Creates a value from an iterator. Read more
Source§

impl<S> IntoIterator for Object<S>

Source§

type Item = (String, Value<S>)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<String, Value<S>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<S: PartialEq> PartialEq for Object<S>

Source§

fn eq(&self, other: &Object<S>) -> 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<T: Serialize> Serialize for Object<T>

Source§

fn serialize<S: Serializer>(&self, ser: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl<S> StructuralPartialEq for Object<S>

Auto Trait Implementations§

§

impl<S> Freeze for Object<S>

§

impl<S> RefUnwindSafe for Object<S>
where S: RefUnwindSafe,

§

impl<S> Send for Object<S>
where S: Send,

§

impl<S> Sync for Object<S>
where S: Sync,

§

impl<S> Unpin for Object<S>
where S: Unpin,

§

impl<S> UnwindSafe for Object<S>
where S: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.