Struct State
pub struct State<'tera> { /* private fields */ }
The state of the interpreter. We pass it around rather than put it on the VM to avoid multiple borrow issues when dealing with inheritance.
Implementations
impl<'t> State<'t>
fn new(context: &'t Context) -> SelfCreates a new state from a
Context. Public since it's needed to test filters/fns/tests but there are no filters registered to it.fn get<T>(&self, name: &str) -> TeraResult<Option<T>> where for<'a> T: ArgFromValue<'a, Output = T>,Get a variable from the context by name and convert it to the specified type.
Returns
Ok(None)if the variable is not defined (undefined). Returns an error if the variable exists but cannot be converted to the target type.fn call_filter(&self, name: &str, value: &Value, kwargs: Kwargs) -> TeraResult<Value>Call a filter by name. Used by filters like
mapthat need to apply other filters.
Trait Implementations
impl<'tera> Debug for State<'tera>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<'tera> !RefUnwindSafe for State<'tera>
impl<'tera> !UnwindSafe for State<'tera>
impl<'tera> Freeze for State<'tera>
impl<'tera> Send for State<'tera>
impl<'tera> Sync for State<'tera>
impl<'tera> Unpin for State<'tera>
impl<'tera> UnsafeUnpin for State<'tera>
Blanket Implementations
impl<T> Any for State<'tera>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for State<'tera>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for State<'tera>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for State<'tera>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for State<'tera>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for State<'tera>
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for State<'tera>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>