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§
Sourcefn contains_root(&self, name: &str) -> bool
fn contains_root(&self, name: &str) -> bool
Check if root variable exists.
Sourcefn contains_variable(&self, path: PathRef<'_, '_>) -> bool
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.
Sourcefn try_get_variable<'a>(&'a self, path: PathRef<'_, '_>) -> Option<&'a Value>
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.
Sourcefn get_variable<'a>(&'a self, path: PathRef<'_, '_>) -> Result<&'a Value>
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.