Struct acter_core::templates::Value

source ·
pub struct Value(/* private fields */);
Expand description

Represents a dynamically typed value in the template engine.

Implementations§

source§

impl Value

source

pub const UNDEFINED: Value = _

The undefined value.

This constant exists because the undefined type does not exist in Rust and this is the only way to construct it.

source

pub fn from_serialize<T>(value: T) -> Value
where T: Serialize,

Creates a value from something that can be serialized.

This is the method that MiniJinja will generally use whenever a serializable object is passed to one of the APIs that internally want to create a value. For instance this is what context! and render will use.

During serialization of the value, serializing_for_value will return true which makes it possible to customize serialization for MiniJinja. For more information see serializing_for_value.

let val = Value::from_serialize(&vec![1, 2, 3]);

This method does not fail but it might return a value that is not valid. Such values will when operated on fail in the template engine in most situations. This for instance can happen if the underlying implementation of Serialize fails. There are also cases where invalid objects are silently hidden in the engine today. This is for instance the case for when keys are used in hash maps that the engine cannot deal with. Invalid values are considered an implementation detail. There is currently no API to validate a value.

If the deserialization feature is enabled then the inverse of this method is to use the Value type as serializer. You can pass a value into the deserialize method of a type that supports serde deserialization.

source

pub fn from_safe_string(value: String) -> Value

Creates a value from a safe string.

A safe string is one that will bypass auto escaping. For instance if you want to have the template engine render some HTML without the user having to supply the |safe filter, you can use a value of this type instead.

let val = Value::from_safe_string("<em>note</em>".into());
source

pub fn from_object<T>(value: T) -> Value
where T: Object + Send + Sync + 'static,

Creates a value from a dynamic object.

For more information see Object.

use std::fmt;

#[derive(Debug)]
struct Thing {
    id: usize,
}

impl Object for Thing {}

let val = Value::from_object(Thing { id: 42 });
source

pub fn from_dyn_object<T>(value: T) -> Value
where T: Into<DynObject>,

Like from_object but for type erased dynamic objects.

This especially useful if you have an object that has an Arc<T> to another child object that you want to return as a Arc<T> turns into a DynObject automatically.

#[derive(Debug)]
pub struct HttpConfig {
    port: usize,
}

#[derive(Debug)]
struct Config {
    http: Arc<HttpConfig>,
}

impl Object for HttpConfig {
    fn enumerate(self: &Arc<Self>) -> Enumerator {
        Enumerator::Str(&["port"])
    }

    fn get_value(self: &Arc<Self>, key: &Value) -> Option<Value> {
        match key.as_str()? {
            "port" => Some(Value::from(self.port)),
            _ => None,
        }
    }
}

impl Object for Config {
    fn enumerate(self: &Arc<Self>) -> Enumerator {
        Enumerator::Str(&["http"])
    }

    fn get_value(self: &Arc<Self>, key: &Value) -> Option<Value> {
        match key.as_str()? {
            "http" => Some(Value::from_dyn_object(self.http.clone())),
            _ => None
        }
    }
}
source

pub fn make_iterable<I, T, F>(maker: F) -> Value
where I: Iterator<Item = T> + Send + Sync + 'static, T: Into<Value> + Send + Sync + 'static, F: Fn() -> I + Send + Sync + 'static,

Creates a value that is an iterable.

The function is invoked to create a new iterator every time the value is iterated over.

let val = Value::make_iterable(|| 0..10);

Iterators that implement ExactSizeIterator or have a matching lower and upper bound on the Iterator::size_hint report a known loop.length. Iterators that do not fulfill these requirements will not. The same is true for revindex and similar properties.

source

pub fn make_object_iterable<T, F>(object: T, maker: F) -> Value
where T: Send + Sync + 'static, F: for<'a> Fn(&'a T) -> Box<dyn Iterator<Item = Value> + Send + Sync + 'a> + Send + Sync + 'static,

Creates an iterable that iterates over the given value.

This is similar to make_iterable but it takes an extra reference to a value it can borrow out from. It’s a bit less generic in that it needs to return a boxed iterator of values directly.

let val = Value::make_object_iterable(vec![1, 2, 3], |vec| {
    Box::new(vec.iter().copied().map(Value::from))
});
assert_eq!(val.to_string(), "[1, 2, 3]");
source

pub fn make_one_shot_iterator<I, T>(iter: I) -> Value
where I: Iterator<Item = T> + Send + Sync + 'static, T: Into<Value> + Send + Sync + 'static,

Creates a value from a one-shot iterator.

This takes an iterator (yielding values that can be turned into a Value) and wraps it in a way that it turns into an iterable value. From the view of the template this can be iterated over exactly once for the most part once exhausted.

Such iterators are strongly recommended against in the general sense due to their surprising behavior, but they can be useful for more advanced use cases where data should be streamed into the template as it becomes available.

Such iterators never have any size hints.

let val = Value::make_one_shot_iterator(0..10);

Attempting to iterate over it a second time will not yield any more items.

source

pub fn from_function<F, Rv, Args>(f: F) -> Value
where F: Function<Rv, Args> + for<'a> Function<Rv, <Args as FunctionArgs<'a>>::Output>, Rv: FunctionResult, Args: for<'a> FunctionArgs<'a>,

Creates a callable value from a function.

let pow = Value::from_function(|a: u32| a * a);
source

pub fn kind(&self) -> ValueKind

Returns the kind of the value.

This can be used to determine what’s in the value before trying to perform operations on it.

source

pub fn is_number(&self) -> bool

Returns true if the value is a number.

To convert a value into a primitive number, use TryFrom or TryInto.

source

pub fn is_integer(&self) -> bool

Returns true if the number is a real integer.

This can be used to distinguish 42 from 42.0. For the most part the engine keeps these the same.

source

pub fn is_kwargs(&self) -> bool

Returns true if the map represents keyword arguments.

source

pub fn is_true(&self) -> bool

Is this value considered true?

The engine inherits the same behavior as Jinja2 when it comes to considering objects true. Empty objects are generally not considered true. For custom objects this is customized by Object::is_true.

source

pub fn is_safe(&self) -> bool

Returns true if this value is safe.

source

pub fn is_undefined(&self) -> bool

Returns true if this value is undefined.

source

pub fn is_none(&self) -> bool

Returns true if this value is none.

source

pub fn to_str(&self) -> Option<Arc<str>>

If the value is a string, return it.

source

pub fn as_str(&self) -> Option<&str>

If the value is a string, return it.

source

pub fn as_usize(&self) -> Option<usize>

If this is an i64 return it

source

pub fn as_i64(&self) -> Option<i64>

If this is an i64 return it

source

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

Returns the bytes of this value if they exist.

source

pub fn as_object(&self) -> Option<&DynObject>

If the value is an object a reference to it is returned.

The returned value is a reference to a type erased DynObject. For a specific type use downcast_object instead.

source

pub fn len(&self) -> Option<usize>

Returns the length of the contained value.

Values without a length will return None.

let seq = Value::from(vec![1, 2, 3, 4]);
assert_eq!(seq.len(), Some(4));
source

pub fn get_attr(&self, key: &str) -> Result<Value, Error>

Looks up an attribute by attribute name.

This this returns UNDEFINED when an invalid key is resolved. An error is returned if the value does not contain an object that has attributes.

let ctx = minijinja::context! {
    foo => "Foo"
};
let value = ctx.get_attr("foo")?;
assert_eq!(value.to_string(), "Foo");
source

pub fn get_item_by_index(&self, idx: usize) -> Result<Value, Error>

Looks up an index of the value.

This is a shortcut for get_item.

let seq = Value::from(vec![0u32, 1, 2]);
let value = seq.get_item_by_index(1).unwrap();
assert_eq!(value.try_into().ok(), Some(1));
source

pub fn get_item(&self, key: &Value) -> Result<Value, Error>

Looks up an item (or attribute) by key.

This is similar to get_attr but instead of using a string key this can be any key. For instance this can be used to index into sequences. Like get_attr this returns UNDEFINED when an invalid key is looked up.

let ctx = minijinja::context! {
    foo => "Foo",
};
let value = ctx.get_item(&Value::from("foo")).unwrap();
assert_eq!(value.to_string(), "Foo");
source

pub fn try_iter(&self) -> Result<ValueIter, Error>

Iterates over the value.

Depending on the kind of the value the iterator has a different behavior.

let value = Value::from({
    let mut m = std::collections::BTreeMap::new();
    m.insert("foo", 42);
    m.insert("bar", 23);
    m
});
for key in value.try_iter()? {
    let value = value.get_item(&key)?;
    println!("{} = {}", key, value);
}
source

pub fn reverse(&self) -> Result<Value, Error>

Returns a reversed view of this value.

This is implemented for the following types with the following behaviors:

  • undefined or none: value returned unchanged.
  • string and bytes: returns a reversed version of that value
  • iterables: returns a reversed version of the iterable. If the iterable is not reversable itself, it consumes it and then reverses it.
source

pub fn downcast_object_ref<T>(&self) -> Option<&T>
where T: 'static,

Returns some reference to the boxed object if it is of type T, or None if it isn’t.

This is basically the “reverse” of from_object and from_dyn_object. It’s also a shortcut for downcast_ref on the return value of as_object.

§Example
use std::fmt;

#[derive(Debug)]
struct Thing {
    id: usize,
}

impl Object for Thing {}

let x_value = Value::from_object(Thing { id: 42 });
let thing = x_value.downcast_object_ref::<Thing>().unwrap();
assert_eq!(thing.id, 42);
source

pub fn downcast_object<T>(&self) -> Option<Arc<T>>
where T: 'static,

Like downcast_object_ref but returns the actual object.

source

pub fn call( &self, state: &State<'_, '_>, args: &[Value], ) -> Result<Value, Error>

Calls the value directly.

If the value holds a function or macro, this invokes it. Note that in MiniJinja there is a separate namespace for methods on objects and callable items. To call methods (which should be a rather rare occurrence) you have to use call_method.

The args slice is for the arguments of the function call. To pass keyword arguments use the Kwargs type.

Usually the state is already available when it’s useful to call this method, but when it’s not available you can get a fresh template state straight from the Template via new_state.

let func = Value::from_function(|v: i64, kwargs: Kwargs| {
    v * kwargs.get::<i64>("mult").unwrap_or(1)
});
let rv = func.call(
    state,
    &[
        Value::from(42),
        Value::from(Kwargs::from_iter([("mult", Value::from(2))])),
    ],
).unwrap();
assert_eq!(rv, Value::from(84));

With the args! macro creating an argument slice is simplified:

let func = Value::from_function(|v: i64, kwargs: Kwargs| {
    v * kwargs.get::<i64>("mult").unwrap_or(1)
});
let rv = func.call(state, args!(42, mult => 2)).unwrap();
assert_eq!(rv, Value::from(84));
source

pub fn call_method( &self, state: &State<'_, '_>, name: &str, args: &[Value], ) -> Result<Value, Error>

Calls a method on the value.

The name of the method is name, the arguments passed are in the args slice.

Trait Implementations§

source§

impl<'a> ArgType<'a> for &Value

§

type Output = &'a Value

The output type of this argument.
source§

impl<'a> ArgType<'a> for Value

§

type Output = Value

The output type of this argument.
source§

impl Clone for Value

source§

fn clone(&self) -> Value

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 Debug for Value

source§

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

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

impl Default for Value

source§

fn default() -> Value

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Value

source§

fn deserialize<D>( deserializer: D, ) -> Result<Value, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de, 'v> Deserializer<'de> for &'v Value

§

type Error = Error

The error type that can be returned if some error occurs during deserialization.
source§

fn deserialize_any<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Require the Deserializer to figure out how to drive the visitor based on what data type is in the input. Read more
source§

fn deserialize_option<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an optional value. Read more
source§

fn deserialize_enum<V>( self, name: &'static str, variants: &'static [&'static str], visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an enum value with a particular name and possible variants.
source§

fn deserialize_unit_struct<V>( self, name: &'static str, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit struct with a particular name.
source§

fn deserialize_newtype_struct<V>( self, name: &'static str, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a newtype struct with a particular name.
source§

fn deserialize_bool<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a bool value.
source§

fn deserialize_u8<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u8 value.
source§

fn deserialize_u16<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u16 value.
source§

fn deserialize_u32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u32 value.
source§

fn deserialize_u64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u64 value.
source§

fn deserialize_i8<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i8 value.
source§

fn deserialize_i16<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i16 value.
source§

fn deserialize_i32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i32 value.
source§

fn deserialize_i64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i64 value.
source§

fn deserialize_f32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f32 value.
source§

fn deserialize_f64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f64 value.
source§

fn deserialize_char<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a char value.
source§

fn deserialize_str<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_string<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_unit<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit value.
source§

fn deserialize_seq<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values.
source§

fn deserialize_bytes<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_byte_buf<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_map<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a map of key-value pairs.
source§

fn deserialize_tuple_struct<V>( self, name: &'static str, len: usize, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a tuple struct with a particular name and number of fields.
source§

fn deserialize_struct<V>( self, name: &'static str, fields: &'static [&'static str], visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a struct with a particular name and fields.
source§

fn deserialize_tuple<V>( self, len: usize, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values and knows how many values there are without looking at the serialized data.
source§

fn deserialize_ignored_any<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type needs to deserialize a value whose type doesn’t matter because it is ignored. Read more
source§

fn deserialize_identifier<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'v Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting the name of a struct field or the discriminant of an enum variant.
source§

fn deserialize_i128<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i128 value. Read more
source§

fn deserialize_u128<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an u128 value. Read more
source§

fn is_human_readable(&self) -> bool

Determine whether Deserialize implementations should expect to deserialize their human-readable form. Read more
source§

impl<'de> Deserializer<'de> for Value

§

type Error = Error

The error type that can be returned if some error occurs during deserialization.
source§

fn deserialize_any<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Require the Deserializer to figure out how to drive the visitor based on what data type is in the input. Read more
source§

fn deserialize_option<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an optional value. Read more
source§

fn deserialize_enum<V>( self, _name: &'static str, _variants: &'static [&'static str], visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an enum value with a particular name and possible variants.
source§

fn deserialize_unit_struct<V>( self, _name: &'static str, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit struct with a particular name.
source§

fn deserialize_newtype_struct<V>( self, _name: &'static str, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a newtype struct with a particular name.
source§

fn deserialize_bool<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a bool value.
source§

fn deserialize_u8<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u8 value.
source§

fn deserialize_u16<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u16 value.
source§

fn deserialize_u32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u32 value.
source§

fn deserialize_u64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u64 value.
source§

fn deserialize_i8<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i8 value.
source§

fn deserialize_i16<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i16 value.
source§

fn deserialize_i32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i32 value.
source§

fn deserialize_i64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i64 value.
source§

fn deserialize_f32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f32 value.
source§

fn deserialize_f64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f64 value.
source§

fn deserialize_char<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a char value.
source§

fn deserialize_str<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_string<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_unit<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit value.
source§

fn deserialize_seq<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values.
source§

fn deserialize_bytes<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_byte_buf<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_map<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a map of key-value pairs.
source§

fn deserialize_tuple_struct<V>( self, name: &'static str, len: usize, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a tuple struct with a particular name and number of fields.
source§

fn deserialize_struct<V>( self, name: &'static str, fields: &'static [&'static str], visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a struct with a particular name and fields.
source§

fn deserialize_tuple<V>( self, len: usize, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values and knows how many values there are without looking at the serialized data.
source§

fn deserialize_ignored_any<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type needs to deserialize a value whose type doesn’t matter because it is ignored. Read more
source§

fn deserialize_identifier<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting the name of a struct field or the discriminant of an enum variant.
source§

fn deserialize_i128<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i128 value. Read more
source§

fn deserialize_u128<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an u128 value. Read more
source§

fn is_human_readable(&self) -> bool

Determine whether Deserialize implementations should expect to deserialize their human-readable form. Read more
source§

impl Display for Value

source§

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

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

impl<'a> From<&'a [u8]> for Value

source§

fn from(val: &'a [u8]) -> Value

Converts to this type from the input type.
source§

impl<'a> From<&'a String> for Value

source§

fn from(val: &'a String) -> Value

Converts to this type from the input type.
source§

impl<'a> From<&'a str> for Value

source§

fn from(val: &'a str) -> Value

Converts to this type from the input type.
source§

impl From<()> for Value

source§

fn from(_: ()) -> Value

Converts to this type from the input type.
source§

impl From<Arc<Vec<u8>>> for Value

source§

fn from(val: Arc<Vec<u8>>) -> Value

Converts to this type from the input type.
source§

impl From<Arc<str>> for Value

source§

fn from(value: Arc<str>) -> Value

Converts to this type from the input type.
source§

impl<'a, V> From<BTreeMap<&'a str, V>> for Value
where V: Into<Value> + Send + Sync + Clone + Debug + 'static,

source§

fn from(val: BTreeMap<&'a str, V>) -> Value

Converts to this type from the input type.
source§

impl<V> From<BTreeMap<Arc<str>, V>> for Value
where V: Into<Value> + Send + Sync + Clone + Debug + 'static,

source§

fn from(val: BTreeMap<Arc<str>, V>) -> Value

Converts to this type from the input type.
source§

impl<'a, V> From<BTreeMap<Cow<'a, str>, V>> for Value
where V: Into<Value> + Send + Sync + Clone + Debug + 'static,

source§

fn from(val: BTreeMap<Cow<'a, str>, V>) -> Value

Converts to this type from the input type.
source§

impl<V> From<BTreeMap<String, V>> for Value
where V: Into<Value> + Send + Sync + Clone + Debug + 'static,

source§

fn from(val: BTreeMap<String, V>) -> Value

Converts to this type from the input type.
source§

impl<V> From<BTreeMap<Value, V>> for Value
where V: Into<Value> + Send + Sync + Clone + Debug + 'static,

source§

fn from(val: BTreeMap<Value, V>) -> Value

Converts to this type from the input type.
source§

impl<T> From<BTreeSet<T>> for Value
where T: Into<Value> + Clone + Send + Sync + Debug + 'static,

source§

fn from(val: BTreeSet<T>) -> Value

Converts to this type from the input type.
source§

impl<'a> From<Cow<'a, str>> for Value

source§

fn from(val: Cow<'a, str>) -> Value

Converts to this type from the input type.
source§

impl From<DynObject> for Value

source§

fn from(val: DynObject) -> Value

Converts to this type from the input type.
source§

impl From<Error> for Value

source§

fn from(value: Error) -> Value

Converts to this type from the input type.
source§

impl<'a, V> From<HashMap<&'a str, V>> for Value
where V: Into<Value> + Send + Sync + Clone + Debug + 'static,

source§

fn from(val: HashMap<&'a str, V>) -> Value

Converts to this type from the input type.
source§

impl<V> From<HashMap<Arc<str>, V>> for Value
where V: Into<Value> + Send + Sync + Clone + Debug + 'static,

source§

fn from(val: HashMap<Arc<str>, V>) -> Value

Converts to this type from the input type.
source§

impl<'a, V> From<HashMap<Cow<'a, str>, V>> for Value
where V: Into<Value> + Send + Sync + Clone + Debug + 'static,

source§

fn from(val: HashMap<Cow<'a, str>, V>) -> Value

Converts to this type from the input type.
source§

impl<V> From<HashMap<String, V>> for Value
where V: Into<Value> + Send + Sync + Clone + Debug + 'static,

source§

fn from(val: HashMap<String, V>) -> Value

Converts to this type from the input type.
source§

impl<V> From<HashMap<Value, V>> for Value
where V: Into<Value> + Send + Sync + Clone + Debug + 'static,

source§

fn from(val: HashMap<Value, V>) -> Value

Converts to this type from the input type.
source§

impl<T> From<HashSet<T>> for Value
where T: Into<Value> + Clone + Send + Sync + Debug + 'static,

source§

fn from(val: HashSet<T>) -> Value

Converts to this type from the input type.
source§

impl From<Kwargs> for Value

source§

fn from(value: Kwargs) -> Value

Converts to this type from the input type.
source§

impl<T> From<LinkedList<T>> for Value
where T: Into<Value> + Clone + Send + Sync + Debug + 'static,

source§

fn from(val: LinkedList<T>) -> Value

Converts to this type from the input type.
source§

impl<I> From<Option<I>> for Value
where I: Into<Value>,

source§

fn from(value: Option<I>) -> Value

Converts to this type from the input type.
source§

impl From<String> for Value

source§

fn from(val: String) -> Value

Converts to this type from the input type.
source§

impl From<ValueRepr> for Value

source§

fn from(val: ValueRepr) -> Value

Converts to this type from the input type.
source§

impl<T> From<Vec<T>> for Value
where T: Into<Value> + Clone + Send + Sync + Debug + 'static,

source§

fn from(val: Vec<T>) -> Value

Converts to this type from the input type.
source§

impl<T> From<VecDeque<T>> for Value
where T: Into<Value> + Clone + Send + Sync + Debug + 'static,

source§

fn from(val: VecDeque<T>) -> Value

Converts to this type from the input type.
source§

impl From<bool> for Value

source§

fn from(val: bool) -> Value

Converts to this type from the input type.
source§

impl From<char> for Value

source§

fn from(val: char) -> Value

Converts to this type from the input type.
source§

impl From<f32> for Value

source§

fn from(val: f32) -> Value

Converts to this type from the input type.
source§

impl From<f64> for Value

source§

fn from(val: f64) -> Value

Converts to this type from the input type.
source§

impl From<i128> for Value

source§

fn from(val: i128) -> Value

Converts to this type from the input type.
source§

impl From<i16> for Value

source§

fn from(val: i16) -> Value

Converts to this type from the input type.
source§

impl From<i32> for Value

source§

fn from(val: i32) -> Value

Converts to this type from the input type.
source§

impl From<i64> for Value

source§

fn from(val: i64) -> Value

Converts to this type from the input type.
source§

impl From<i8> for Value

source§

fn from(val: i8) -> Value

Converts to this type from the input type.
source§

impl From<isize> for Value

source§

fn from(val: isize) -> Value

Converts to this type from the input type.
source§

impl From<u128> for Value

source§

fn from(val: u128) -> Value

Converts to this type from the input type.
source§

impl From<u16> for Value

source§

fn from(val: u16) -> Value

Converts to this type from the input type.
source§

impl From<u32> for Value

source§

fn from(val: u32) -> Value

Converts to this type from the input type.
source§

impl From<u64> for Value

source§

fn from(val: u64) -> Value

Converts to this type from the input type.
source§

impl From<u8> for Value

source§

fn from(val: u8) -> Value

Converts to this type from the input type.
source§

impl From<usize> for Value

source§

fn from(val: usize) -> Value

Converts to this type from the input type.
source§

impl<K, V> FromIterator<(K, V)> for Value
where K: Into<Value>, V: Into<Value>,

source§

fn from_iter<T>(iter: T) -> Value
where T: IntoIterator<Item = (K, V)>,

Creates a value from an iterator. Read more
source§

impl<V> FromIterator<V> for Value
where V: Into<Value>,

source§

fn from_iter<T>(iter: T) -> Value
where T: IntoIterator<Item = V>,

Creates a value from an iterator. Read more
source§

impl Hash for Value

source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'de> IntoDeserializer<'de, Error> for &'de Value

§

type Deserializer = &'de Value

The type of the deserializer being converted into.
source§

fn into_deserializer(self) -> &'de Value

Convert this value into a deserializer.
source§

impl<'de> IntoDeserializer<'de, Error> for Value

§

type Deserializer = Value

The type of the deserializer being converted into.
source§

fn into_deserializer(self) -> Value

Convert this value into a deserializer.
source§

impl Ord for Value

source§

fn cmp(&self, other: &Value) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Value

source§

fn eq(&self, other: &Value) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Value

source§

fn partial_cmp(&self, other: &Value) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Value

source§

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

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

impl Eq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl !RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl !UnwindSafe for Value

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§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn compare(&self, key: &K) -> Ordering

Compares self to key and returns their ordering.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compares self to key and returns true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<I> FunctionResult for I
where I: Into<Value>,

source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

source§

const WITNESS: W = W::MAKE

A constant of the type witness
source§

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

§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> Any for T
where T: Any,

source§

impl<T> AsyncTraitDeps for T

source§

impl<T> CloneAny for T
where T: Any + Clone,

source§

impl<T> CloneAnySend for T
where T: Any + Send + Clone,

source§

impl<T> CloneAnySendSync for T
where T: Any + Send + Sync + Clone,

source§

impl<T> CloneAnySync for T
where T: Any + Sync + Clone,

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> SendOutsideWasm for T
where T: Send,

source§

impl<T> SyncOutsideWasm for T
where T: Sync,