Skip to main content

ValueStore

Trait ValueStore 

Source
pub trait ValueStore: Debug {
    // Required methods
    fn contains_root(&self, name: &str) -> bool;
    fn roots(&self) -> Vec<&str>;
    fn contains_variable(&self, path: PathRef<'_, '_>) -> bool;
    fn try_get_variable<'a>(
        &'a self,
        path: PathRef<'_, '_>,
    ) -> Option<&'a Value>;
    fn get_variable<'a>(&'a self, path: PathRef<'_, '_>) -> Result<&'a Value>;
}
Expand description

Immutable view into a template’s global variables.

Required Methods§

Source

fn contains_root(&self, name: &str) -> bool

Check if root variable exists.

Source

fn roots(&self) -> Vec<&str>

Enumerate all root variables.

Source

fn contains_variable(&self, path: PathRef<'_, '_>) -> bool

Check if variable exists.

Notes to implementers:

  • Don’t forget to reverse-index on negative array indexes
  • Don’t forget about arr.first, arr.last.
Source

fn try_get_variable<'a>(&'a self, path: PathRef<'_, '_>) -> Option<&'a Value>

Access a variable.

Notes to implementers:

  • Don’t forget to reverse-index on negative array indexes
  • Don’t forget about arr.first, arr.last.
Source

fn get_variable<'a>(&'a self, path: PathRef<'_, '_>) -> Result<&'a Value>

Access a variable.

Notes to implementers:

  • Don’t forget to reverse-index on negative array indexes
  • Don’t forget about arr.first, arr.last.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ValueStore for Object

Source§

fn contains_root(&self, name: &str) -> bool

Source§

fn roots(&self) -> Vec<&str>

Source§

fn contains_variable(&self, path: PathRef<'_, '_>) -> bool

Source§

fn try_get_variable<'a>(&'a self, path: PathRef<'_, '_>) -> Option<&'a Value>

Source§

fn get_variable<'a>(&'a self, path: PathRef<'_, '_>) -> Result<&'a Value>

Implementors§