[−]Struct liquid::Object
Type representing a Liquid object, payload of the Value::Object
variant
Methods
impl Object
pub fn new() -> Object
Makes a new empty Object.
pub fn clear(&mut self)
Clears the map, removing all values.
pub fn get<Q>(&self, key: &Q) -> Option<&Value> where
Q: Ord + Eq + Hash + ?Sized,
KString: Borrow<Q>,
Q: Ord + Eq + Hash + ?Sized,
KString: Borrow<Q>,
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.
pub fn contains_key<Q>(&self, key: &Q) -> bool where
Q: Ord + Eq + Hash + ?Sized,
KString: Borrow<Q>,
Q: Ord + Eq + Hash + ?Sized,
KString: Borrow<Q>,
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.
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut Value> where
Q: Ord + Eq + Hash + ?Sized,
KString: Borrow<Q>,
Q: Ord + Eq + Hash + ?Sized,
KString: Borrow<Q>,
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.
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.
pub fn remove<Q>(&mut self, key: &Q) -> Option<Value> where
Q: Ord + Eq + Hash + ?Sized,
KString: Borrow<Q>,
Q: Ord + Eq + Hash + ?Sized,
KString: Borrow<Q>,
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.
pub fn entry<S>(&mut self, key: S) -> Entry where
S: Into<KString>,
S: Into<KString>,
Gets the given key's corresponding entry in the map for in-place manipulation.
pub fn len(&self) -> usize
Returns the number of elements in the map.
pub fn is_empty(&self) -> bool
Returns true if the map contains no elements.
pub fn iter(&self) -> Iter
Gets an iterator over the entries of the map.
pub fn iter_mut(&mut self) -> IterMut
Gets a mutable iterator over the entries of the map.
pub fn keys(&self) -> Keys
Gets an iterator over the keys of the map.
pub fn values(&self) -> Values
Gets an iterator over the values of the map.
pub fn values_mut(&mut self) -> ValuesMut
Gets an iterator over mutable values of the map.
Trait Implementations
impl Clone for Object
fn clone(&self) -> Object
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Object
impl Default for Object
impl<'de> Deserialize<'de> for Object
fn deserialize<D>(
deserializer: D
) -> Result<Object, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
deserializer: D
) -> Result<Object, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
impl Eq for Object
impl Extend<(KString, Value)> for Object
fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = (KString, Value)>,
T: IntoIterator<Item = (KString, Value)>,
impl FromIterator<(KString, Value)> for Object
impl<'a, Q> Index<&'a Q> for Object where
Q: Ord + Eq + Hash + ?Sized,
KString: Borrow<Q>,
Q: Ord + Eq + Hash + ?Sized,
KString: Borrow<Q>,
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, }
impl<'a, Q> IndexMut<&'a Q> for Object where
Q: Ord + Eq + Hash + ?Sized,
KString: Borrow<Q>,
Q: Ord + Eq + Hash + ?Sized,
KString: Borrow<Q>,
Mutably access an element of this map. Panics if the given key is not present in the map.
map["key"] = liquid_value::value!("value");
impl<'a> IntoIterator for &'a Object
type Item = (&'a KString, &'a Value)
The type of the elements being iterated over.
type IntoIter = Iter<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> <&'a Object as IntoIterator>::IntoIter
impl IntoIterator for Object
type Item = (KString, Value)
The type of the elements being iterated over.
type IntoIter = IntoIter
Which kind of iterator are we turning this into?
fn into_iter(self) -> <Object as IntoIterator>::IntoIter
impl<'a> IntoIterator for &'a mut Object
type Item = (&'a KString, &'a mut Value)
The type of the elements being iterated over.
type IntoIter = IterMut<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> <&'a mut Object as IntoIterator>::IntoIter
impl ObjectView for Object
fn as_value(&self) -> &dyn ValueView
fn size(&self) -> i32
fn keys(&'k self) -> Box<dyn Iterator<Item = KStringCow<'k>> + 'k>
fn values(&'k self) -> Box<dyn Iterator<Item = &'k (dyn ValueView + 'k)> + 'k>
fn iter(
&'k self
) -> Box<dyn Iterator<Item = (KStringCow<'k>, &'k (dyn ValueView + 'k))> + 'k>
&'k self
) -> Box<dyn Iterator<Item = (KStringCow<'k>, &'k (dyn ValueView + 'k))> + 'k>
fn contains_key(&self, index: &str) -> bool
fn get(&'s self, index: &str) -> Option<&'s (dyn ValueView + 's)>
impl PartialEq<Object> for Object
impl Serialize for Object
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
impl ValueView for Object
fn as_debug(&self) -> &dyn Debug
fn render(&self) -> DisplayCow
fn source(&self) -> DisplayCow
fn type_name(&self) -> &'static str
fn query_state(&self, state: State) -> bool
fn to_kstr(&self) -> KStringCow
fn to_value(&self) -> Value
fn as_object(&self) -> Option<&dyn ObjectView>
fn as_scalar(&self) -> Option<ScalarCow>
fn is_scalar(&self) -> bool
fn as_array(&self) -> Option<&dyn ArrayView>
fn is_array(&self) -> bool
fn is_object(&self) -> bool
fn as_state(&self) -> Option<State>
fn is_state(&self) -> bool
fn is_nil(&self) -> bool
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]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CloneAny for T where
T: Clone + Any,
T: Clone + Any,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,