Skip to main content

EngineConfig

Struct EngineConfig 

Source
pub struct EngineConfig {
Show 23 fields pub app: App, pub viewport: Size<Points>, pub trace: bool, pub network: Option<Arc<dyn Network>>, pub websocket: Option<Arc<dyn WebSocketTransport>>, pub refuse_connections: Option<RefuseConnections>, pub filesystem: Option<Arc<dyn FileSystem>>, pub assets: Option<Arc<dyn Assets>>, pub environment: Environment, pub header_heights: (Points, Points), pub limits: Limits, pub ui_sets: Vec<Registry>, pub runtime: Option<Handle>, pub data_dir: Option<PathBuf>, pub cache: CacheOptions, pub storage: Option<Arc<dyn StorageBackend>>, pub clock: Clock, pub context: EngineContext, pub pinned: EnvironmentPins, pub clipboard: Option<Arc<dyn ClipboardBackend>>, pub host: HostChannel, pub picker: Option<Arc<dyn PickerBackend>>, pub speech: Option<Arc<dyn SpeechBackend>>,
}
Expand description

Engine settings.

Fields§

§app: App

The app.

§viewport: Size<Points>

Initial size of the root view.

§trace: bool

Log per-commit timings (target nsh::perf, level info).

§network: Option<Arc<dyn Network>>

The HTTP stack behind fetch; without one, requests fail.

§websocket: Option<Arc<dyn WebSocketTransport>>

The host transport for WebSockets, including the browser WebSocket API.

§refuse_connections: Option<RefuseConnections>

Refuses the app’s connections (net sockets and both WebSocket APIs) with the error it gives for what they connect to, before they reach the network: a test’s, which reaches it only when the test asks (nsh test’s network: "live"). None: they connect.

§filesystem: Option<Arc<dyn FileSystem>>

App-private host filesystem service (for browser storage).

§assets: Option<Arc<dyn Assets>>

Source of bundled files such as fonts; without one, they fail to load.

§environment: Environment

The surface’s initial environment (its window is viewport).

§header_heights: (Points, Points)

Height of the platform’s screen header bar, normal and with a large title (status bar excluded).

§limits: Limits

The JS VM’s resource limits (a JS app’s; Rust code has none).

§ui_sets: Vec<Registry>

The UI sets JS imports (nsh_base::registry() by default, the app’s own): their Rust components and modules. A Rust app’s components need no registration.

§runtime: Option<Handle>

The tokio runtime the components’ async tasks use (timers, IO, background work); None: one shared by the engines of the process.

§data_dir: Option<PathBuf>

Where apps keep their data: each app in <data_dir>/<app id> (App::app_id; default without one), its storage (nsh/storage) in storage.json there. The platform’s: the system’s data directory (data_dir) for apps of their own, …/nsh in an embedding app’s. None: nothing is kept.

§cache: CacheOptions

Where the app’s caches are kept and how much each keeps: the engine opens them in <root>/<app id>/<kind> (Engine::image_cache). EngineConfig::new: none.

§storage: Option<Arc<dyn StorageBackend>>

The app’s storage, overriding the one EngineConfig::data_dir names (the browser’s localStorage, an embedder’s own); None with no data directory either: in memory, for the engine’s life.

§clock: Clock

The time the app runs on: the system’s, or a manual clock a test moves (nsh_core::time::Clock::manual), which its timers, frames and Date follow.

§context: EngineContext

What the host gives this engine’s Rust code, which its UI sets’ functions and components read while it runs them (nsh_core::element::engine_context): a host serving several engines tells them apart by it.

§pinned: EnvironmentPins

Values of the environment kept whatever the platform reports (a test’s locale, reduced motion and safe area: nsh test --target).

§clipboard: Option<Arc<dyn ClipboardBackend>>

Serves the app’s clipboard calls in place of the platform’s clipboard (a test’s own: nsh test --target); None: the platform’s.

§host: HostChannel

The embedding app’s channel with the app (nsh/host): its launch parameters, its events and its handlers of the app’s calls and posts. A view keeps one for every app it runs; the default is a channel of the engine’s own, with none of them.

§picker: Option<Arc<dyn PickerBackend>>

Answers the app’s picks (Picker.pickImages) in place of the platform’s picker: the embedding app’s own picker, or a test’s files; None: the platform’s.

§speech: Option<Arc<dyn SpeechBackend>>

Recognizes the app’s speech (Speech.start) instead of the platform’s recognizer: the embedding app’s own, or a test’s fake (nsh_testing’s). None (the default): the platform’s, where it has one (Environment::speech).

Implementations§

Source§

impl EngineConfig

Source

pub fn new(app: impl Into<App>) -> Self

app on a phone-sized surface (390 × 844 points, iOS’s header heights) with nothing else: no network, assets, data directory or UI sets, the default environment and limits, the shared runtime. Set the fields that matter over it (EngineConfig { ui_sets, ..EngineConfig::new(app) }). There is no Default: an engine has no app to run by default.

Trait Implementations§

Source§

impl Clone for EngineConfig

Source§

fn clone(&self) -> Self

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 EngineConfig

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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