StackHandle

Struct StackHandle 

Source
pub struct StackHandle<T: ?Sized> { /* private fields */ }
Expand description

A handle to an enclosed value.

For as long as the Scope is still valid access to the reference can be temporarily fetched via the with method. Doing so after the scope is gone, this will panic on all operations.

To check if a handle is still valid is_valid can be used.

A stack handle implements the underlying object protocols from MiniJinja.

Implementations§

Source§

impl<T: ?Sized> StackHandle<T>

Source

pub fn is_valid(handle: &StackHandle<T>) -> bool

Checks if the handle is still valid.

Source

pub fn with<F: FnOnce(&T) -> R, R>(&self, f: F) -> R

Invokes a function with the resolved reference.

§Panics

This method panics if the handle is not valid.

Trait Implementations§

Source§

impl<T: Object + ?Sized> Debug for StackHandle<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Object + ?Sized> Display for StackHandle<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Object + ?Sized> Object for StackHandle<T>

Source§

fn kind(&self) -> ObjectKind<'_>

Describes the kind of an object. Read more
Source§

fn call_method( &self, state: &State<'_, '_>, name: &str, args: &[Value], ) -> Result<Value, Error>

Called when the engine tries to call a method on the object. Read more
Source§

fn call(&self, state: &State<'_, '_>, args: &[Value]) -> Result<Value, Error>

Called when the object is invoked directly. Read more
Source§

impl<T: SeqObject + Send + Sync + 'static + ?Sized> SeqObject for StackHandle<T>

Source§

fn get_item(&self, idx: usize) -> Option<Value>

Looks up an item by index. Read more
Source§

fn item_count(&self) -> usize

Returns the number of items in the sequence.
Source§

impl<T: StructObject + Send + Sync + 'static + ?Sized> StructObject for StackHandle<T>

Source§

fn get_field(&self, idx: &str) -> Option<Value>

Invoked by the engine to get a field of a struct. Read more
Source§

fn static_fields(&self) -> Option<&'static [&'static str]>

If possible returns a static vector of field names. Read more
Source§

fn fields(&self) -> Vec<Arc<str>>

Returns a vector of field names. Read more
Source§

fn field_count(&self) -> usize

Returns the number of fields. Read more
Source§

impl<T: Send + ?Sized> Send for StackHandle<T>

Source§

impl<T: Sync + ?Sized> Sync for StackHandle<T>

Auto Trait Implementations§

§

impl<T> Freeze for StackHandle<T>
where T: ?Sized,

§

impl<T> RefUnwindSafe for StackHandle<T>
where T: RefUnwindSafe + ?Sized,

§

impl<T> Unpin for StackHandle<T>
where T: ?Sized,

§

impl<T> UnwindSafe for StackHandle<T>
where T: RefUnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.