pub struct Object { /* private fields */ }
Expand description
Type representing a Liquid object, payload of the Value::Object
variant
Implementations§
source§impl Object
impl Object
sourcepub fn get<Q>(&self, key: &Q) -> Option<&Value>
pub fn get<Q>(&self, key: &Q) -> Option<&Value>
Returns a reference to the value corresponding to the key.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Returns true if the map contains a value for the specified key.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
sourcepub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut Value>
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut Value>
Returns a mutable reference to the value corresponding to the key.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
sourcepub fn insert(&mut self, k: KStringBase<Box<str>>, v: Value) -> Option<Value>
pub fn insert(&mut self, k: KStringBase<Box<str>>, v: Value) -> Option<Value>
Inserts a key-value pair into the map.
If the map did not have this key present, None
is returned.
If the map did have this key present, the value is updated, and the old value is returned.
sourcepub fn remove<Q>(&mut self, key: &Q) -> Option<Value>
pub fn remove<Q>(&mut self, key: &Q) -> Option<Value>
Removes a key from the map, returning the value at the key if the key was previously in the map.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
sourcepub fn entry<S>(&mut self, key: S) -> Entry<'_>
pub fn entry<S>(&mut self, key: S) -> Entry<'_>
Gets the given key’s corresponding entry in the map for in-place manipulation.
sourcepub fn iter_mut(&mut self) -> IterMut<'_> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_> ⓘ
Gets a mutable iterator over the entries of the map.
sourcepub fn values_mut(&mut self) -> ValuesMut<'_> ⓘ
pub fn values_mut(&mut self) -> ValuesMut<'_> ⓘ
Gets an iterator over mutable values of the map.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Object
impl<'de> Deserialize<'de> for Object
source§fn deserialize<D>(
deserializer: D,
) -> Result<Object, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Object, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl Extend<(KStringBase<Box<str>>, Value)> for Object
impl Extend<(KStringBase<Box<str>>, Value)> for Object
source§fn extend<T>(&mut self, iter: T)
fn extend<T>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl FromIterator<(KStringBase<Box<str>>, Value)> for Object
impl FromIterator<(KStringBase<Box<str>>, Value)> for Object
source§impl<'a, Q> Index<&'a Q> for Object
impl<'a, Q> Index<&'a Q> for Object
Access an element of this map. Panics if the given key is not present in the map.
match *val {
Value::Scalar(ref s) => Some(s.to_kstr()),
Value::Array(ref arr) => Some(arr[0].to_kstr()),
Value::Object(ref map) => Some(map["type"].to_kstr()),
_ => None,
}
source§impl<'a, Q> IndexMut<&'a Q> for Object
impl<'a, Q> IndexMut<&'a Q> for Object
Mutably access an element of this map. Panics if the given key is not present in the map.
map["key"] = liquid_core::value!("value");
source§impl<'a> IntoIterator for &'a Object
impl<'a> IntoIterator for &'a Object
source§impl<'a> IntoIterator for &'a mut Object
impl<'a> IntoIterator for &'a mut Object
source§impl IntoIterator for Object
impl IntoIterator for Object
source§impl ObjectView for Object
impl ObjectView for Object
source§fn keys<'k>(&'k self) -> Box<dyn Iterator<Item = KStringCowBase<'k>> + 'k>
fn keys<'k>(&'k self) -> Box<dyn Iterator<Item = KStringCowBase<'k>> + 'k>
source§fn values<'k>(&'k self) -> Box<dyn Iterator<Item = &'k dyn ValueView> + 'k>
fn values<'k>(&'k self) -> Box<dyn Iterator<Item = &'k dyn ValueView> + 'k>
source§fn iter<'k>(
&'k self,
) -> Box<dyn Iterator<Item = (KStringCowBase<'k>, &'k dyn ValueView)> + 'k>
fn iter<'k>( &'k self, ) -> Box<dyn Iterator<Item = (KStringCowBase<'k>, &'k dyn ValueView)> + 'k>
source§fn contains_key(&self, index: &str) -> bool
fn contains_key(&self, index: &str) -> bool
BoxedValue
.source§impl Serialize for Object
impl Serialize for Object
source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
source§impl ValueView for Object
impl ValueView for Object
source§fn render(&self) -> DisplayCow<'_>
fn render(&self) -> DisplayCow<'_>
Display
for a BoxedValue
rendered for the user.source§fn source(&self) -> DisplayCow<'_>
fn source(&self) -> DisplayCow<'_>
Display
for a Value
as source code.source§fn query_state(&self, state: State) -> bool
fn query_state(&self, state: State) -> bool
source§fn to_kstr(&self) -> KStringCowBase<'_>
fn to_kstr(&self) -> KStringCowBase<'_>
source§fn as_object(&self) -> Option<&dyn ObjectView>
fn as_object(&self) -> Option<&dyn ObjectView>
impl Eq for Object
impl StructuralPartialEq for Object
Auto Trait Implementations§
impl Freeze for Object
impl RefUnwindSafe for Object
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl UnwindSafe for Object
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more