pub struct App<State, Build> { /* private fields */ }Expand description
A Frust application: the app state plus the build closure that maps it
to a view tree.
This is the low-level primitive. app! and run expand into
App::new(state, move |state| root.build(state)) (see
run_with_setup_and_config); ordinary apps write a Component and
start it with those instead of constructing an App by hand.
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
build fn’s impl View<State> 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, build).run()
compiles for both impl View and concrete-typed build.
Implementations§
Source§impl<State: 'static, Build> App<State, Build>
impl<State: 'static, Build> App<State, Build>
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).
// `App::new` is the low-level primitive; apps normally use a `Component`.
frust::App::new(AppState, build)
.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 build.
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, Build> Freeze for App<State, Build>
impl<State, Build> RefUnwindSafe for App<State, Build>where
State: RefUnwindSafe,
Build: RefUnwindSafe,
impl<State, Build> Send for App<State, Build>
impl<State, Build> Sync for App<State, Build>
impl<State, Build> Unpin for App<State, Build>
impl<State, Build> UnsafeUnpin for App<State, Build>where
State: UnsafeUnpin,
Build: UnsafeUnpin,
impl<State, Build> UnwindSafe for App<State, Build>where
State: UnwindSafe,
Build: 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.