Skip to main content

Scope

Struct Scope 

Source
pub struct Scope<'a> {
    pub data: &'a DataModel,
    pub path: String,
    pub index: Option<usize>,
    pub catalog: Option<String>,
    pub activation: bool,
    /* private fields */
}
Expand description

Where an expression is evaluated.

Fields§

§data: &'a DataModel

The surface’s data model.

§path: String

The data context a relative path resolves against (/ at the root, the item’s path inside a template).

§index: Option<usize>

The innermost template’s item index, for @index.

§catalog: Option<String>

The catalog a call without its own catalogId resolves in.

§activation: bool

Whether this runs from a user gesture (an action), which functions that need one require.

Implementations§

Source§

impl<'a> Scope<'a>

Source

pub fn root(data: &'a DataModel, catalog: Option<&str>) -> Self

The root scope of a surface whose default catalog is catalog.

Source

pub fn item(&self, path: String, index: usize) -> Scope<'a>

This scope inside a template item.

Source

pub fn take_effects(&self) -> Vec<Effect>

The effects functions asked for, in order, taken out of the scope.

Source

pub fn get(&self, path: &str) -> Option<Value>

Read the data model at a path relative to this scope (None when absent or not allowed).

Source

pub fn set(&self, path: &str, value: Value)

Ask for a data model write, for a local function: applied when the action that ran it finishes, and dropped when it ran from a binding.

Auto Trait Implementations§

§

impl<'a> !Freeze for Scope<'a>

§

impl<'a> !RefUnwindSafe for Scope<'a>

§

impl<'a> !Sync for Scope<'a>

§

impl<'a> Forget for Scope<'a>

§

impl<'a> Move for Scope<'a>

§

impl<'a> Send for Scope<'a>
where &'a DataModel: Send, RawVecInner: Send, RefCell<Vec<Effect>>: Send,

§

impl<'a> Unpin for Scope<'a>
where &'a DataModel: Unpin, *const u8 is !null: Unpin,

§

impl<'a> UnsafeUnpin for Scope<'a>

§

impl<'a> UnwindSafe for Scope<'a>
where &'a DataModel: UnwindSafe, RawVecInner: UnwindSafe, NonNull<u8>: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.