pub struct Root { /* private fields */ }Expand description
The root of a Rust app: makes the app’s top component (on the engine
thread, where elements live). The engine mounts it as the content of the
surface (nsh_engine::App::Rust).
Implementations§
Source§impl Root
impl Root
Sourcepub fn new<C>(
props: impl Fn() -> <C as Component>::Props + Send + Sync + 'static,
) -> Rootwhere
C: Component,
pub fn new<C>(
props: impl Fn() -> <C as Component>::Props + Send + Sync + 'static,
) -> Rootwhere
C: Component,
Component C with the props props makes.
Sourcepub fn translations(self, translations: Translations) -> Root
pub fn translations(self, translations: Translations) -> Root
The app’s translations (its locales/ files, which nsh’s generated
code compiles in): what t! reads.
Sourcepub fn translations_ref(&self) -> Option<&Translations>
pub fn translations_ref(&self) -> Option<&Translations>
The app’s translations (Root::translations).
Sourcepub fn app_id(self, id: impl Into<String>) -> Root
pub fn app_id(self, id: impl Into<String>) -> Root
The app’s id (nsh.json "id", which nsh’s generated code sets):
it names where the app keeps its data (nsh/storage).
Sourcepub fn app_id_ref(&self) -> Option<&str>
pub fn app_id_ref(&self) -> Option<&str>
The app’s id (Root::app_id).
Sourcepub fn url_schemes(
self,
schemes: impl IntoIterator<Item = impl Into<String>>,
) -> Root
pub fn url_schemes( self, schemes: impl IntoIterator<Item = impl Into<String>>, ) -> Root
The URL schemes the app claims (nsh.json schemes,
which nsh’s generated code sets): the links the core lets
through (crate::url_scheme, crate::element::next_url_scheme_open).
Sourcepub fn url_schemes_ref(&self) -> &[String]
pub fn url_schemes_ref(&self) -> &[String]
The schemes the app claims (Root::url_schemes).
Sourcepub fn tokens(self, tokens: Tokens) -> Root
pub fn tokens(self, tokens: Tokens) -> Root
Renders with design tokens tokens (nsh-base‘s theme’s; by
default the UI sets’ defaults).
Sourcepub fn font(self, data: impl Into<Arc<[u8]>>) -> Root
pub fn font(self, data: impl Into<Arc<[u8]>>) -> Root
Registers a font file (TrueType / OpenType) before the first render; styles name it by its family name.
Sourcepub fn appearance(self, appearance: Appearance) -> Root
pub fn appearance(self, appearance: Appearance) -> Root
Shows the app in appearance whatever the system’s (nsh.json
"appearance"; later super::set_color_scheme calls
change it).
Sourcepub fn status_bar(self, setting: StatusBarSetting) -> Root
pub fn status_bar(self, setting: StatusBarSetting) -> Root
The status bar’s default (nsh.json "statusBar"), under what
pages and dialogs set (Screen::status_bar, Modal::status_bar).
Sourcepub fn main_window(self, options: MainWindowOptions) -> Root
pub fn main_window(self, options: MainWindowOptions) -> Root
The main window’s launch options (nsh.json "window", which nsh’s
generated code sets): the runners open the window by them, and the
engine applies their attributes with the first frame and keeps the
placement with restore_bounds, as for a TSX app’s bundle.
Sourcepub fn main_window_ref(&self) -> Option<&MainWindowOptions>
pub fn main_window_ref(&self) -> Option<&MainWindowOptions>
The main window’s launch options (Root::main_window).
Sourcepub fn status_bar_ref(&self) -> Option<StatusBarSetting>
pub fn status_bar_ref(&self) -> Option<StatusBarSetting>
The status bar’s default (Root::status_bar).
Sourcepub fn appearance_ref(&self) -> Option<Appearance>
pub fn appearance_ref(&self) -> Option<Appearance>
The appearance it starts in (Root::appearance; None: the
system’s).
Sourcepub fn tokens_ref(&self) -> Option<&Tokens>
pub fn tokens_ref(&self) -> Option<&Tokens>
The design tokens it renders with.