Trait trimmer::Variable [] [src]

pub trait Variable<'render>: Debug {
    fn typename(&self) -> &'static str;

    fn attr<'x>(&'x self, _attr: &str) -> Result<Var<'x, 'render>, DataError>
    where
        'render: 'x
, { ... }
fn index<'x>(
        &'x self,
        _key: &(Variable<'render> + 'render)
    ) -> Result<Var<'x, 'render>, DataError>
    where
        'render: 'x
, { ... }
fn output(&self) -> Result<Output, DataError> { ... }
fn as_str_key<'x>(&'x self) -> Result<&'x str, DataError> { ... }
fn as_int_key(&self) -> Result<usize, DataError> { ... }
fn as_bool(&self) -> Result<bool, DataError> { ... }
fn as_number(&self) -> Result<Number, DataError> { ... }
fn as_comparable(&self) -> Result<Comparable, DataError> { ... }
fn iterate<'x>(
        &'x self
    ) -> Result<Box<Iterator<Item = Var<'x, 'render>> + 'x>, DataError>
    where
        'render: 'x
, { ... }
fn iterate_pairs<'x>(
        &'x self
    ) -> Result<Box<Iterator<Item = (Var<'x, 'render>, Var<'x, 'render>)> + 'x>, DataError>
    where
        'render: 'x
, { ... } }

A trait that you need to implement to put variable into the rendering context

Note: by default all operations return unsupported error

Required Methods

Returns type name to use in error messages

Note this must return actual type of value from user point of view not just rust type. For example for Json type it should describe Json::Object as a mapping and Json::Array as an array, not just return Json

Provided Methods

Evaluates a.b operation

Depending on your domain a.x may be equivalent of a["x"] or maybe not. Integer arguments a.0 are not supported.

Evaluates a[b]

Depending on your domain a["x"] may be equivalent of a.x or maybe not.

You may exract string value for a key with key.as_str_key() and key.as_int_key().

Note that actual key may have a (rust) type that is different from type of self (i.e. may come from different library).

Evaluates {{ x }}

This operation may not be useful for array-, and mapping-like values

Return string value of the variable used as key in index

String keys are used for indexing dicts

It's okay not to implement this method for complex variables

Return intenger value of the variable used as key

Integer keys are used for indexing arrays

It's okay not to implement this method for complex variables

Return boolean value of this object

This is used in conditions ## if x

Return value as it could be treated in numeric context

Numeric context is where +,-,*,/,% operators are used. Use standard into() conversion to convert built-in value into internal representation.

Return value of the object that might be compared to another value

Note we can only compare numbers with number and strings with strings. All other types of comparisons are unsupported. Use standard into() conversion to convert built-in value into internal representation.

Return iterator over the value if appropriate

Return iterator over pairs if appropriate

Implementations on Foreign Types

impl<'a, 'render: 'a> Variable<'render> for &'a str
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for String
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for IpAddr
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for Ipv4Addr
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for Ipv6Addr
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for SocketAddr
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for Option<&'x str>
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for u8
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for i8
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for u16
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for i16
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for u32
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for i32
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for u64
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for i64
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for f32
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for f64
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for usize
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for isize
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'render, V> Variable<'render> for HashMap<String, V> where
    V: Variable<'render> + 'render, 
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'a: 'render, 'render, V> Variable<'render> for HashMap<&'a str, V> where
    V: Variable<'render> + 'render, 
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'render, V> Variable<'render> for BTreeMap<String, V> where
    V: Variable<'render> + 'render, 
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'a: 'render, 'render, V> Variable<'render> for BTreeMap<&'a str, V> where
    V: Variable<'render> + 'render, 
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'a, 'render, T: Variable<'render> + 'render> Variable<'render> for Vec<T>
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'a, 'render, T> Variable<'render> for HashSet<T> where
    T: Variable<'render> + Hash + Eq + 'render, 
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'a, 'render, T> Variable<'render> for BTreeSet<T> where
    T: Variable<'render> + Ord + Eq + 'render, 
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'x> Variable<'x> for bool
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'render, T: Variable<'render>> Variable<'render> for Box<T>
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'render, T: Variable<'render>> Variable<'render> for Rc<T>
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'render, T: Variable<'render>> Variable<'render> for Arc<T>
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'render, T: Variable<'render>> Variable<'render> for &'render T
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl<'render> Variable<'render> for Value
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

Implementors