pub struct State<'tera> { /* private fields */ }Expand description
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§
Source§impl<'t> State<'t>
impl<'t> State<'t>
Sourcepub fn new(context: &'t Context) -> State<'t>
pub fn new(context: &'t Context) -> State<'t>
Creates a new state from a Context.
Public since it’s needed to test filters/fns/tests but there are no filters registered to it.
Sourcepub fn get<T>(&self, name: &str) -> Result<Option<T>, Error>where
T: for<'a> ArgFromValue<'a, Output = T>,
pub fn get<T>(&self, name: &str) -> Result<Option<T>, Error>where
T: for<'a> 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.
Trait Implementations§
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more