Skip to main content

ComponentContext

Struct ComponentContext 

Source
pub struct ComponentContext<'a> {
    pub component_id: String,
    pub surface_id: String,
    pub data_context: DataContext<'a>,
    pub components: &'a SurfaceComponentsModel,
    pub focused_id: Option<String>,
    pub template_index: Option<usize>,
}
Expand description

Transient context created for each component during rendering.

The caller is responsible for holding the RefCell borrows on DataModel and SurfaceComponentsModel for the duration of rendering.

Fields§

§component_id: String

The component’s ID.

§surface_id: String

The surface ID this component belongs to.

§data_context: DataContext<'a>

Scoped data access for resolving dynamic values.

§components: &'a SurfaceComponentsModel

The components model (escape hatch for inspecting siblings/children).

§focused_id: Option<String>

The ID of the currently focused component, if any.

§template_index: Option<usize>

The index of this component within a template iteration, if applicable.

Implementations§

Source§

impl<'a> ComponentContext<'a>

Source

pub fn new( component_id: String, surface_id: String, data_model: &'a DataModel, components: &'a SurfaceComponentsModel, functions: &'a HashMap<String, Box<dyn FunctionImplementation>>, base_path: &str, focused_id: Option<String>, ) -> Self

Create a component context.

Callers should borrow surface.data_model and surface.components before calling this and pass the references.

Auto Trait Implementations§

§

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

§

impl<'a> !UnwindSafe for ComponentContext<'a>

§

impl<'a> Freeze for ComponentContext<'a>

§

impl<'a> Send for ComponentContext<'a>

§

impl<'a> Sync for ComponentContext<'a>

§

impl<'a> Unpin for ComponentContext<'a>

§

impl<'a> UnsafeUnpin for ComponentContext<'a>

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, 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.