Struct oxygengine_user_interface::raui::core::application::ProcessContext
source · 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 DataBinding
s.
See Application::process
for more information.
Implementations§
source§impl<'a> ProcessContext<'a>
impl<'a> ProcessContext<'a>
sourcepub fn new() -> ProcessContext<'a>
pub fn new() -> ProcessContext<'a>
Create an empty ProcessContext
sourcepub fn get_mut<T>(&mut self) -> Option<&mut T>where
T: 'static,
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...
}
sourcepub fn insert_mut<T>(&mut self, item: &'a mut T) -> &mut ProcessContext<'a>where
T: 'static,
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.
sourcepub fn get<T>(&self) -> Option<&T>where
T: 'static,
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...
}
sourcepub fn insert<T>(&mut self, item: &'a T) -> &mut ProcessContext<'a>where
T: 'static,
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.
sourcepub fn owned_ref<T>(&self) -> Option<&T>where
T: 'static,
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...
}
sourcepub fn owned_mut<T>(&mut self) -> Option<&mut T>where
T: 'static,
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...
}
sourcepub fn insert_owned<T>(&mut self, item: T) -> &mut ProcessContext<'a>where
T: 'static,
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.