pub struct App<State, Logic> { /* private fields */ }Expand description
A Frust application: the app state plus the app_logic function that maps
it to a view tree.
Construct with App::new and start the event loop with App::run,
optionally naming a desktop identity with App::desktop in between.
The view type is intentionally not a parameter of this struct: capturing a
free fn app_logic(&mut State) -> impl View<State>’s opaque return type into
a stored type parameter defeats method resolution (the opaque type’s trait
bounds can’t be re-proven on the already-typed value). Instead App::run
infers the view type freshly at the call site, so
App::new(state, app_logic).run() compiles for both impl View and
concrete-typed app_logic.
Implementations§
Source§impl<State: 'static, Logic> App<State, Logic>
impl<State: 'static, Logic> App<State, Logic>
Sourcepub fn desktop(self, config: DesktopConfig) -> Self
pub fn desktop(self, config: DesktopConfig) -> Self
Give the app a desktop identity — name, reverse-DNS id, window icon,
native menu bar, last-window-close policy (see DesktopConfig).
Optional: an app that never calls this runs with
DesktopConfig::default(), which is the dev-preview window exactly as
it has always been. Each per-OS shell reads the fields it can act on and
ignores the rest (Linux has no native menu bar, macOS wants an
application icon rather than a window one, and so on).
frust::App::new(AppState, app_logic)
.desktop(frust::DesktopConfig::new().with_app_name("Huddle"))
.run()
.unwrap();Sourcepub fn run<V>(self) -> Result<()>
pub fn run<V>(self) -> Result<()>
Run the app in the desktop window until it is closed.
Blocks the calling thread on the platform event loop. Returns once the
window closes, or an error if the window/GPU surface could not be
created. The concrete view type V is inferred from logic.
Desktop-only: on Android the app is driven by the JNI bridge that
android_app! generates and on iOS by the C-ABI entry points
ios_app! generates, not by this loop.
Auto Trait Implementations§
impl<State, Logic> Freeze for App<State, Logic>
impl<State, Logic> RefUnwindSafe for App<State, Logic>where
State: RefUnwindSafe,
Logic: RefUnwindSafe,
impl<State, Logic> Send for App<State, Logic>
impl<State, Logic> Sync for App<State, Logic>
impl<State, Logic> Unpin for App<State, Logic>
impl<State, Logic> UnsafeUnpin for App<State, Logic>where
State: UnsafeUnpin,
Logic: UnsafeUnpin,
impl<State, Logic> UnwindSafe for App<State, Logic>where
State: UnwindSafe,
Logic: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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.