Skip to main content

Root

Struct Root 

Source
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

Source

pub fn new<C>( props: impl Fn() -> <C as Component>::Props + Send + Sync + 'static, ) -> Root
where C: Component,

Component C with the props props makes.

Source

pub fn translations(self, translations: Translations) -> Root

The app’s translations (its locales/ files, which nsh’s generated code compiles in): what t! reads.

Source

pub fn translations_ref(&self) -> Option<&Translations>

The app’s translations (Root::translations).

Source

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).

Source

pub fn app_id_ref(&self) -> Option<&str>

The app’s id (Root::app_id).

Source

pub fn app_info(self, info: AppInfo) -> Root

The app as it was built (crate::platform::AppInfo), which nsh’s generated code sets: what crate::element::app_info answers.

Source

pub fn url_schemes( self, schemes: impl IntoIterator<Item = impl Into<String>>, ) -> Root

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.

Source

pub fn url_schemes_ref(&self) -> &[String]

The schemes the app claims (Root::url_schemes).

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).

The links the app claims (Root::links).

Source

pub fn capabilities(self, capabilities: Capabilities) -> Root

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.

Source

pub fn capabilities_ref(&self) -> Option<&Capabilities>

What the app declares it may reach (Root::capabilities); None: no declaration.

Source

pub fn tokens(self, tokens: Tokens) -> Root

Renders with design tokens tokens (nsh-base‘s theme’s; by default the UI sets’ defaults).

Source

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.

Source

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).

Source

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, Dialog::status_bar).

Source

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.

Source

pub fn main_window_ref(&self) -> Option<&MainWindowOptions>

The main window’s launch options (Root::main_window).

Source

pub fn application(self, options: ApplicationOptions) -> Root

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.

Source

pub fn application_ref(&self) -> Option<&ApplicationOptions>

The app’s lifecycle options (Root::application).

Source

pub fn status_bar_ref(&self) -> Option<StatusBarSetting>

The status bar’s default (Root::status_bar).

Source

pub fn appearance_ref(&self) -> Option<Appearance>

The appearance it starts in (Root::appearance; None: the system’s).

Source

pub fn tokens_ref(&self) -> Option<&Tokens>

The design tokens it renders with.

Source

pub fn fonts(&self) -> &[Arc<[u8]>]

The font files to register.

Source

pub fn of<C>() -> Root
where C: Component, <C as Component>::Props: Default,

Component C with default props.

Trait Implementations§

Source§

impl Clone for Root

Source§

fn clone(&self) -> Root

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Root

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<Root> for App

Source§

fn from(root: Root) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Root

§

impl !UnwindSafe for Root

§

impl Forget for Root

§

impl Freeze for Root

§

impl Move for Root

§

impl Send for Root
where Arc<dyn Fn() -> AnyElement + Send + Sync>: Send, Arc<Tokens>: Send, RawVecInner: Send, Arc<[u8]>: Send, Arc<Inner>: Send,

§

impl Sync for Root
where Arc<dyn Fn() -> AnyElement + Send + Sync>: Sync, Arc<Tokens>: Sync, RawVecInner: Sync, Arc<[u8]>: Sync, Arc<Inner>: Sync,

§

impl Unpin for Root
where Arc<dyn Fn() -> AnyElement + Send + Sync>: Unpin, Arc<Tokens>: Unpin, *const u8 is !null: Unpin, Arc<[u8]>: Unpin, Arc<Inner>: Unpin,

§

impl UnsafeUnpin for Root

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ParallelSend for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more