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: Component>(
props: impl Fn() -> C::Props + Send + Sync + 'static,
) -> Self
pub fn new<C: Component>( props: impl Fn() -> C::Props + Send + Sync + 'static, ) -> Self
Component C with the props props makes.
Sourcepub fn translations(self, translations: Translations) -> Self
pub fn translations(self, translations: Translations) -> Self
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>) -> Self
pub fn app_id(self, id: impl Into<String>) -> Self
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 app_info(self, info: AppInfo) -> Self
pub fn app_info(self, info: AppInfo) -> Self
The app as it was built (crate::platform::AppInfo), which
nsh’s generated code sets: what crate::element::app_info
answers.
Sourcepub fn url_schemes(
self,
schemes: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn url_schemes( self, schemes: impl IntoIterator<Item = impl Into<String>>, ) -> Self
The URL schemes the app claims (nsh.json schemes): the links the
core lets through (crate::url_scheme,
crate::element::next_url_scheme_open). Replaces the schemes of
Root::links, keeping its web links.
Sourcepub fn url_schemes_ref(&self) -> &[String]
pub fn url_schemes_ref(&self) -> &[String]
The schemes the app claims (Root::url_schemes).
Sourcepub fn links(self, links: AppLinks) -> Self
pub fn links(self, links: AppLinks) -> Self
The links the app claims (nsh.json schemes and links, which
nsh’s generated code sets): URLs of its schemes and https URLs of
its web links, the links the core lets through (crate::url_scheme,
crate::element::next_url_scheme_open).
Sourcepub fn links_ref(&self) -> &AppLinks
pub fn links_ref(&self) -> &AppLinks
The links the app claims (Root::links).
Sourcepub fn capabilities(self, capabilities: Capabilities) -> Self
pub fn capabilities(self, capabilities: Capabilities) -> Self
What the app declares it may reach (nsh.json capabilities, which
nsh’s generated code sets): the engine checks the app’s requests,
URLs it opens, media, web views, clipboard, picker and the rest
against them, as it does a TSX app’s. Without a declaration the app
reaches what an app without capabilities does.
Sourcepub fn capabilities_ref(&self) -> Option<&Capabilities>
pub fn capabilities_ref(&self) -> Option<&Capabilities>
What the app declares it may reach (Root::capabilities); None:
no declaration.
Sourcepub fn tokens(self, tokens: Tokens) -> Self
pub fn tokens(self, tokens: Tokens) -> Self
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]>>) -> Self
pub fn font(self, data: impl Into<Arc<[u8]>>) -> Self
Registers a font file (TrueType / OpenType) before the first render; styles name it by its family name.
Sourcepub fn appearance(self, appearance: Appearance) -> Self
pub fn appearance(self, appearance: Appearance) -> Self
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) -> Self
pub fn status_bar(self, setting: StatusBarSetting) -> Self
The status bar’s default (nsh.json "statusBar"), under what
pages and dialogs set (Screen::status_bar, Dialog::status_bar).
Sourcepub fn main_window(self, options: MainWindowOptions) -> Self
pub fn main_window(self, options: MainWindowOptions) -> Self
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 application(self, options: ApplicationOptions) -> Self
pub fn application(self, options: ApplicationOptions) -> Self
The app’s lifecycle options (nsh.json "application", which nsh’s
generated code sets): the engine sets the quit mode before the app
runs, as for a TSX app’s bundle.
Sourcepub fn application_ref(&self) -> Option<&ApplicationOptions>
pub fn application_ref(&self) -> Option<&ApplicationOptions>
The app’s lifecycle options (Root::application).
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.