pub struct ProcessContext<'a> { /* private fields */ }
Expand description

Allows you to get mutable or immutable references to data exposed by the host of the RAUI application

This allows RAUI hosts to provide the UI with direct access to application data, if necessary, instead of using DataBindings.

See Application::process for more information.

Implementations§

source§

impl<'a> ProcessContext<'a>

source

pub fn new() -> ProcessContext<'a>

Create an empty ProcessContext

source

pub fn get_mut<T>(&mut self) -> Option<&mut T>where T: 'static,

Can be used to get mutable access to application data provided by the RAUI host.

Example
fn my_component(ctx: WidgetContext) -> WidgetNode {
    let app_data = ctx.process_context.get_mut::<AppData>().unwrap();
    let counter = &mut app_data.counter;
    *counter += 1;

    // widget stuff...
}
source

pub fn insert_mut<T>(&mut self, item: &'a mut T) -> &mut ProcessContext<'a>where T: 'static,

Allows RAUI hosts to add mutable references to application data to the process_context that is available to widget components.

See Application::process for more information.

source

pub fn get<T>(&self) -> Option<&T>where T: 'static,

Can be used to get immutable access to application data provided by the RAUI host.

Example
fn my_component(ctx: WidgetContext) -> WidgetNode {
    let app_data = ctx.process_context.get::<AppData>().unwrap();
    let counter = app_data.counter;

    // widget stuff...
}
source

pub fn insert<T>(&mut self, item: &'a T) -> &mut ProcessContext<'a>where T: 'static,

Allows RAUI hosts to add immutable references to application data to the process_context that is available to widget components.

See Application::process for more information.

source

pub fn owned_ref<T>(&self) -> Option<&T>where T: 'static,

Can be used to get immutable access to owned objects available for current application processing run provided by the RAUI host.

Example
fn my_component(ctx: WidgetContext) -> WidgetNode {
    let app_data = ctx.process_context.owned_ref::<AppData>().unwrap();
    let counter = app_data.counter;

    // widget stuff...
}
source

pub fn owned_mut<T>(&mut self) -> Option<&mut T>where T: 'static,

Can be used to get mutable access to owned objects available for current application processing run provided by the RAUI host.

Example
fn my_component(ctx: WidgetContext) -> WidgetNode {
    let app_data = ctx.process_context.owned_mut::<AppData>().unwrap();
    let counter = app_data.counter;

    // widget stuff...
}
source

pub fn insert_owned<T>(&mut self, item: T) -> &mut ProcessContext<'a>where T: 'static,

Allows RAUI hosts to add owned objects to application data to the process_context that is available to widget components.

source

pub fn has<T>(&self) -> boolwhere T: 'static,

Trait Implementations§

source§

impl<'a> Debug for ProcessContext<'a>

source§

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

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

impl<'a> Default for ProcessContext<'a>

source§

fn default() -> ProcessContext<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

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

§

impl<'a> !Send for ProcessContext<'a>

§

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

§

impl<'a> Unpin for ProcessContext<'a>

§

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

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Finalize for T

§

unsafe fn finalize_raw(data: *mut ())

Safety Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Initialize for Twhere T: Default,

§

fn initialize(&mut self)

§

unsafe fn initialize_raw(data: *mut ())

Safety Read more
source§

impl<T, U> Into<U> for Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.