pub struct State<'vm, 'env> { /* private fields */ }
Expand description
Provides access to the current execution state of the engine.
A read only reference is passed to filter functions and similar objects to allow limited interfacing with the engine. The state is useful to look up information about the engine in filter, test or global functions. It not only provides access to the template environment but also the context variables of the engine, the current auto escaping behavior as well as the auto escape flag.
Notes on lifetimes: the state object exposes some of the internal lifetimes through the type. You should always elide these lifetimes as there might be lifetimes added or removed between releases.
Implementations
sourceimpl<'vm, 'env> State<'vm, 'env>
impl<'vm, 'env> State<'vm, 'env>
sourcepub fn env(&self) -> &Environment<'_>
pub fn env(&self) -> &Environment<'_>
Returns a reference to the current environment.
sourcepub fn auto_escape(&self) -> AutoEscape
pub fn auto_escape(&self) -> AutoEscape
Returns the current value of the auto escape flag.
sourcepub fn current_block(&self) -> Option<&str>
pub fn current_block(&self) -> Option<&str>
Returns the name of the innermost block.
Trait Implementations
Auto Trait Implementations
impl<'vm, 'env> !RefUnwindSafe for State<'vm, 'env>
impl<'vm, 'env> Send for State<'vm, 'env>
impl<'vm, 'env> Sync for State<'vm, 'env>
impl<'vm, 'env> Unpin for State<'vm, 'env> where
'env: 'vm,
impl<'vm, 'env> !UnwindSafe for State<'vm, 'env>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more