pub struct DesktopApp<S: AppState, W: Widget<S>> { /* private fields */ }Expand description
The desktop application shell that owns the window, event loop, and rendering pipeline.
Generic over S (the application state type) and W (the root widget type).
Construct via DesktopApp::new() and configure with builder methods
(with_title, with_state_init, with_key_handler, etc.) before calling
run() to start the event loop.
Implementations§
Source§impl<S: AppState + Default, W: Widget<S> + 'static> DesktopApp<S, W>
impl<S: AppState + Default, W: Widget<S> + 'static> DesktopApp<S, W>
pub fn new(root_widget: W) -> Self
pub fn with_key_handler<F>(self, handler: F) -> Self
pub fn with_title(self, title: impl Into<String>) -> Self
Sourcepub fn with_state_init<F>(self, init: F) -> Self
pub fn with_state_init<F>(self, init: F) -> Self
Mutate the initial application state before the first frame.
pub fn with_env(self, env: Env) -> Self
pub fn with_sync_env<F>(self, f: F) -> Self
Sourcepub fn with_frame_hook<F>(self, f: F) -> Self
pub fn with_frame_hook<F>(self, f: F) -> Self
Register a hook that runs on every AboutToWait event with mutable
access to the application state. Return true to request a redraw.
Useful for polling background services (e.g. LSP) between key events.
Sourcepub fn with_app_effect_handler<F>(self, handler: F) -> Selfwhere
F: Fn(Vec<u8>, u64, Option<ActionEnvelope>, Option<ActionEnvelope>, Sender<(u64, Result<EffectPayload, String>, Option<ActionEnvelope>, Option<ActionEnvelope>)>) + Send + Sync + 'static,
pub fn with_app_effect_handler<F>(self, handler: F) -> Selfwhere
F: Fn(Vec<u8>, u64, Option<ActionEnvelope>, Option<ActionEnvelope>, Sender<(u64, Result<EffectPayload, String>, Option<ActionEnvelope>, Option<ActionEnvelope>)>) + Send + Sync + 'static,
Register a handler for Effect::App(payload) effects.
The handler runs on the calling thread and should spawn its own
background work if needed, sending results through the provided
mpsc::Sender<EffectResult>.
pub fn register_reducer( &mut self, action_id: ActionId, reducer: fn(&mut S, &ActionEnvelope, NodeId) -> Result<()>, ) -> Result<()>
pub fn absorb_registry(&mut self, registry: ActionRegistry<S>)
pub fn run(self) -> Result<()>
Auto Trait Implementations§
impl<S, W> Freeze for DesktopApp<S, W>where
W: Freeze,
impl<S, W> !RefUnwindSafe for DesktopApp<S, W>
impl<S, W> Send for DesktopApp<S, W>where
W: Send,
impl<S, W> !Sync for DesktopApp<S, W>
impl<S, W> Unpin for DesktopApp<S, W>
impl<S, W> UnsafeUnpin for DesktopApp<S, W>where
W: UnsafeUnpin,
impl<S, W> !UnwindSafe for DesktopApp<S, W>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more