pub struct Object { /* private fields */ }
Expand description
Type representing a Liquid object, payload of the Value::Object
variant
Implementations
sourceimpl Object
impl Object
sourcepub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&Value> where
KString: Borrow<Q>,
Q: Ord + Eq + Hash,
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&Value> where
KString: Borrow<Q>,
Q: Ord + Eq + Hash,
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: ?Sized>(&self, key: &Q) -> bool where
KString: Borrow<Q>,
Q: Ord + Eq + Hash,
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
KString: Borrow<Q>,
Q: Ord + Eq + Hash,
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: ?Sized>(&mut self, key: &Q) -> Option<&mut Value> where
KString: Borrow<Q>,
Q: Ord + Eq + Hash,
pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut Value> where
KString: Borrow<Q>,
Q: Ord + Eq + Hash,
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: KString, v: Value) -> Option<Value>
pub fn insert(&mut self, k: KString, 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: ?Sized>(&mut self, key: &Q) -> Option<Value> where
KString: Borrow<Q>,
Q: Ord + Eq + Hash,
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<Value> where
KString: Borrow<Q>,
Q: Ord + Eq + Hash,
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<'_> where
S: Into<KString>,
pub fn entry<S>(&mut self, key: S) -> Entry<'_> where
S: Into<KString>,
Gets the given key’s corresponding entry in the map for in-place manipulation.
sourcepub fn iter(&self) -> Iter<'_>ⓘNotable traits for Iter<'a>impl<'a> Iterator for Iter<'a> type Item = (&'a KString, &'a Value);
pub fn iter(&self) -> Iter<'_>ⓘNotable traits for Iter<'a>impl<'a> Iterator for Iter<'a> type Item = (&'a KString, &'a Value);
Gets an iterator over the entries of the map.
sourcepub fn iter_mut(&mut self) -> IterMut<'_>ⓘNotable traits for IterMut<'a>impl<'a> Iterator for IterMut<'a> type Item = (&'a KString, &'a mut Value);
pub fn iter_mut(&mut self) -> IterMut<'_>ⓘNotable traits for IterMut<'a>impl<'a> Iterator for IterMut<'a> type Item = (&'a KString, &'a mut Value);
Gets a mutable iterator over the entries of the map.
sourcepub fn keys(&self) -> Keys<'_>ⓘNotable traits for Keys<'a>impl<'a> Iterator for Keys<'a> type Item = &'a KString;
pub fn keys(&self) -> Keys<'_>ⓘNotable traits for Keys<'a>impl<'a> Iterator for Keys<'a> type Item = &'a KString;
Gets an iterator over the keys of the map.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Object
impl<'de> Deserialize<'de> for Object
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Extend<(KStringBase<Box<str, Global>>, Value)> for Object
impl Extend<(KStringBase<Box<str, Global>>, Value)> for Object
sourcefn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = (KString, Value)>,
fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = (KString, Value)>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl FromIterator<(KStringBase<Box<str, Global>>, Value)> for Object
impl FromIterator<(KStringBase<Box<str, Global>>, Value)> for Object
sourceimpl<'a, Q: ?Sized> Index<&'a Q> for Object where
KString: Borrow<Q>,
Q: Ord + Eq + Hash,
impl<'a, Q: ?Sized> Index<&'a Q> for Object where
KString: Borrow<Q>,
Q: Ord + Eq + Hash,
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,
}
sourceimpl<'a, Q: ?Sized> IndexMut<&'a Q> for Object where
KString: Borrow<Q>,
Q: Ord + Eq + Hash,
impl<'a, Q: ?Sized> IndexMut<&'a Q> for Object where
KString: Borrow<Q>,
Q: Ord + Eq + Hash,
Mutably access an element of this map. Panics if the given key is not present in the map.
map["key"] = liquid_core::value!("value");
sourceimpl<'a> IntoIterator for &'a Object
impl<'a> IntoIterator for &'a Object
sourceimpl<'a> IntoIterator for &'a mut Object
impl<'a> IntoIterator for &'a mut Object
sourceimpl IntoIterator for Object
impl IntoIterator for Object
sourceimpl ObjectView for Object
impl ObjectView for Object
sourcefn keys<'k>(&'k self) -> Box<dyn Iterator<Item = KStringCow<'k>> + 'k>
fn keys<'k>(&'k self) -> Box<dyn Iterator<Item = KStringCow<'k>> + 'k>
Keys available for lookup.
sourcefn 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>
Keys available for lookup.
sourcefn iter<'k>(
&'k self
) -> Box<dyn Iterator<Item = (KStringCow<'k>, &'k dyn ValueView)> + 'k>
fn iter<'k>(
&'k self
) -> Box<dyn Iterator<Item = (KStringCow<'k>, &'k dyn ValueView)> + 'k>
Returns an iterator .
sourcefn contains_key(&self, index: &str) -> bool
fn contains_key(&self, index: &str) -> bool
Access a contained BoxedValue
.
sourceimpl ValueView for Object
impl ValueView for Object
sourcefn render(&self) -> DisplayCow<'_>
fn render(&self) -> DisplayCow<'_>
A Display
for a BoxedValue
rendered for the user.
sourcefn source(&self) -> DisplayCow<'_>
fn source(&self) -> DisplayCow<'_>
A Display
for a Value
as source code.
sourcefn query_state(&self, state: State) -> bool
fn query_state(&self, state: State) -> bool
Query the value’s state
sourcefn to_kstr(&self) -> KStringCow<'_>
fn to_kstr(&self) -> KStringCow<'_>
Interpret as a string.
sourcefn as_object(&self) -> Option<&dyn ObjectView>
fn as_object(&self) -> Option<&dyn ObjectView>
Extracts the object value if it is a object.
impl Eq for Object
impl StructuralEq for Object
impl StructuralPartialEq for Object
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more