Skip to main content

EngineConfig

Struct EngineConfig 

Source
pub struct EngineConfig {
Show 26 fields pub app: App, pub viewport: Size<Points>, pub trace: bool, pub content_culling: 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 audio: Option<Arc<dyn AudioBackend>>, pub windows: Option<Arc<dyn WindowBackend>>, pub login_item: Option<Arc<dyn LoginItemBackend>>, /* private fields */
}
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).

§content_culling: bool

Scroll views make the native views of their content only near their viewport (the platforms’ apps); off, they make all of it (tests, which read whole pages). EngineConfig::new: off.

§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>

The app’s own data directory, used as it is (no app id appended): its storage (nsh/storage, storage.json there), process.dataDir and the ${dataDir} of its file grants. The desktop runners set it from nsh.json "dataDir". None: <support_dir>/<app id>.

§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 storage.json in its data directory (the browser’s localStorage, an embedder’s own, a test’s stand-in); None where the system has 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, Picker.pickFiles) in place of the platform’s picker: the embedding app’s own picker, or a test’s files; None: the platform’s.

§audio: Option<Arc<dyn AudioBackend>>

Plays the app’s sound (Sound, AudioPlayer) instead of the platform: the embedding app’s own audio stack, or a test’s fake (nsh_testing’s). None (the default): the platform’s, where it has one (Environment::audio).

§windows: Option<Arc<dyn WindowBackend>>

Opens and applies the app’s windows of its own (<Window>, Window.open) instead of the platform: the embedding app’s own windows, or a test’s fake. None (the default): the platform’s built-in backend, which every desktop backend has, embedded or standalone. The main window’s commands always go to the platform.

§login_item: Option<Arc<dyn LoginItemBackend>>

The app’s login item (Application.launchAtLogin): the platform’s, which a standalone app’s runner gives (run_app with the backend’s login_item option), or a test’s fake. None (the default): the app does not launch at login.

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.

Source

pub fn main_window_placement( &self, displays: &[Display], ) -> Option<WindowPlacement>

Where a runner opens the main window of an app with nsh.json window.restoreBounds: the placement its last run kept in its storage (EngineConfig::storage, or the file in its data directory), fitted on displays, the ones there are now. Read before making the window; None without restoreBounds or a kept placement. The engine keeps it as the window changes (the environment’s window state).

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§

§

impl !RefUnwindSafe for EngineConfig

§

impl !UnwindSafe for EngineConfig

§

impl Forget for EngineConfig

§

impl Freeze for EngineConfig
where *const ArcInner<dyn Fn() -> AnyElement + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn() -> AnyElement + Sync + Send>>: Freeze, *const ArcInner<Tokens> is !null: Freeze, PhantomData<ArcInner<Tokens>>: Freeze, *const u8 is !null: Freeze, PhantomData<Arc<[u8]>>: Freeze, PhantomData<u8>: Freeze, PhantomData<String>: Freeze, PhantomData<WebLink>: Freeze, PhantomData<HostPattern>: Freeze, PhantomData<HttpGrant>: Freeze, PhantomData<SocketGrant>: Freeze, PhantomData<WebMedia>: Freeze, PhantomData<WindowKind>: Freeze, PhantomData<WindowLevel>: Freeze, *const ArcInner<Inner> is !null: Freeze, PhantomData<ArcInner<Inner>>: Freeze, *const ArcInner<str> is !null: Freeze, PhantomData<ArcInner<str>>: Freeze, *const ArcInner<Vec<Chunk>> is !null: Freeze, PhantomData<ArcInner<Vec<Chunk>>>: Freeze, *const ArcInner<PackageInfo> is !null: Freeze, PhantomData<ArcInner<PackageInfo>>: Freeze, *const ArcInner<[u8]> is !null: Freeze, PhantomData<ArcInner<[u8]>>: Freeze, *const ArcInner<dyn Trial> is !null: Freeze, PhantomData<ArcInner<dyn Trial>>: Freeze, *const ArcInner<dyn Network> is !null: Freeze, PhantomData<ArcInner<dyn Network>>: Freeze, *const ArcInner<dyn WebSocketTransport> is !null: Freeze, PhantomData<ArcInner<dyn WebSocketTransport>>: Freeze, *const ArcInner<dyn Fn(&str) -> JsError + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(&str) -> JsError + Sync + Send>>: Freeze, *const ArcInner<dyn FileSystem> is !null: Freeze, PhantomData<ArcInner<dyn FileSystem>>: Freeze, *const ArcInner<dyn Assets> is !null: Freeze, PhantomData<ArcInner<dyn Assets>>: Freeze, &'static str: Freeze, PhantomData<Registry>: Freeze, *const ArcInner<Handle> is !null: Freeze, PhantomData<ArcInner<Handle>>: Freeze, *const ArcInner<Handle> is !null: Freeze, PhantomData<ArcInner<Handle>>: Freeze, *const ArcInner<dyn StorageBackend> is !null: Freeze, PhantomData<ArcInner<dyn StorageBackend>>: Freeze, *const ArcInner<Mutex<Manual>> is !null: Freeze, PhantomData<ArcInner<Mutex<Manual>>>: Freeze, *const ArcInner<HashMap<TypeId, Arc<dyn Any + Sync + Send>, FxBuildHasher>> is !null: Freeze, PhantomData<ArcInner<HashMap<TypeId, Arc<dyn Any + Sync + Send>, FxBuildHasher>>>: Freeze, *const ArcInner<dyn ClipboardBackend> is !null: Freeze, PhantomData<ArcInner<dyn ClipboardBackend>>: Freeze, *const ArcInner<Mutex<Inner>> is !null: Freeze, PhantomData<ArcInner<Mutex<Inner>>>: Freeze, *const ArcInner<CallCount> is !null: Freeze, PhantomData<ArcInner<CallCount>>: Freeze, *const ArcInner<dyn PickerBackend> is !null: Freeze, PhantomData<ArcInner<dyn PickerBackend>>: Freeze, *const ArcInner<dyn AudioBackend> is !null: Freeze, PhantomData<ArcInner<dyn AudioBackend>>: Freeze, *const ArcInner<dyn WindowBackend> is !null: Freeze, PhantomData<ArcInner<dyn WindowBackend>>: Freeze, *const ArcInner<dyn LoginItemBackend> is !null: Freeze, PhantomData<ArcInner<dyn LoginItemBackend>>: Freeze,

§

impl Move for EngineConfig

§

impl Send for EngineConfig
where Arc<dyn Fn() -> AnyElement + Sync + Send>: Send, Arc<Tokens>: Send, RawVecInner: Send, Arc<[u8]>: Send, Arc<Inner>: Send, Arc<str>: Send, Arc<Vec<Chunk>>: Send, Arc<PackageInfo>: Send, Arc<dyn Trial>: Send, Arc<dyn Network>: Send, Arc<dyn WebSocketTransport>: Send, Arc<dyn Fn(&str) -> JsError + Sync + Send>: Send, Arc<dyn FileSystem>: Send, Arc<dyn Assets>: Send, &'static str: Send, Arc<HashMap<&'static str, ComponentType, FxBuildHasher>>: Send, Arc<HashMap<&'static str, ModuleType, FxBuildHasher>>: Send, Arc<HashMap<(Option<&'static str>, &'static str), ClassType, FxBuildHasher>>: Send, Arc<(Vec<&'static str>, Vec<&'static str>)>: Send, Arc<Vec<&'static str>>: Send, Arc<Vec<(&'static [Os], &'static [AssetFile])>>: Send, Arc<Vec<Registry>>: Send, Arc<Vec<Arc<dyn Fn() + Sync + Send>>>: Send, Arc<Vec<(&'static str, Arc<dyn Fake>)>>: Send, Arc<Vec<(&'static str, GpuSource)>>: Send, Arc<Handle>: Send, Arc<Handle>: Send, Arc<dyn StorageBackend>: Send, Arc<Mutex<Manual>>: Send, Arc<HashMap<TypeId, Arc<dyn Any + Sync + Send>, FxBuildHasher>>: Send, Arc<dyn ClipboardBackend>: Send, Arc<Mutex<Inner>>: Send, Arc<CallCount>: Send, Arc<dyn PickerBackend>: Send, Arc<dyn AudioBackend>: Send, Arc<dyn WindowBackend>: Send, Arc<dyn LoginItemBackend>: Send,

§

impl Sync for EngineConfig
where Arc<dyn Fn() -> AnyElement + Sync + Send>: Sync, Arc<Tokens>: Sync, RawVecInner: Sync, Arc<[u8]>: Sync, Arc<Inner>: Sync, Arc<str>: Sync, Arc<Vec<Chunk>>: Sync, Arc<PackageInfo>: Sync, Arc<dyn Trial>: Sync, Arc<dyn Network>: Sync, Arc<dyn WebSocketTransport>: Sync, Arc<dyn Fn(&str) -> JsError + Sync + Send>: Sync, Arc<dyn FileSystem>: Sync, Arc<dyn Assets>: Sync, Arc<HashMap<&'static str, ComponentType, FxBuildHasher>>: Sync, Arc<HashMap<&'static str, ModuleType, FxBuildHasher>>: Sync, Arc<HashMap<(Option<&'static str>, &'static str), ClassType, FxBuildHasher>>: Sync, Arc<(Vec<&'static str>, Vec<&'static str>)>: Sync, Arc<Vec<&'static str>>: Sync, Arc<Vec<(&'static [Os], &'static [AssetFile])>>: Sync, Arc<Vec<Registry>>: Sync, Arc<Vec<Arc<dyn Fn() + Sync + Send>>>: Sync, Arc<Vec<(&'static str, Arc<dyn Fake>)>>: Sync, Arc<Vec<(&'static str, GpuSource)>>: Sync, Arc<Handle>: Sync, Arc<Handle>: Sync, Arc<dyn StorageBackend>: Sync, Arc<Mutex<Manual>>: Sync, Arc<HashMap<TypeId, Arc<dyn Any + Sync + Send>, FxBuildHasher>>: Sync, Arc<dyn ClipboardBackend>: Sync, Arc<Mutex<Inner>>: Sync, Arc<CallCount>: Sync, Arc<dyn PickerBackend>: Sync, Arc<dyn AudioBackend>: Sync, Arc<dyn WindowBackend>: Sync, Arc<dyn LoginItemBackend>: Sync,

§

impl Unpin for EngineConfig
where Arc<dyn Fn() -> AnyElement + Sync + Send>: Unpin, Arc<Tokens>: Unpin, *const u8 is !null: Unpin, Arc<[u8]>: Unpin, Arc<Inner>: Unpin, Arc<str>: Unpin, Arc<Vec<Chunk>>: Unpin, Arc<PackageInfo>: Unpin, Arc<dyn Trial>: Unpin, Arc<dyn Network>: Unpin, Arc<dyn WebSocketTransport>: Unpin, Arc<dyn Fn(&str) -> JsError + Sync + Send>: Unpin, Arc<dyn FileSystem>: Unpin, Arc<dyn Assets>: Unpin, &'static str: Unpin, Arc<HashMap<&'static str, ComponentType, FxBuildHasher>>: Unpin, Arc<HashMap<&'static str, ModuleType, FxBuildHasher>>: Unpin, Arc<HashMap<(Option<&'static str>, &'static str), ClassType, FxBuildHasher>>: Unpin, Arc<(Vec<&'static str>, Vec<&'static str>)>: Unpin, Arc<Vec<&'static str>>: Unpin, Arc<Vec<(&'static [Os], &'static [AssetFile])>>: Unpin, Arc<Vec<Registry>>: Unpin, Arc<Vec<Arc<dyn Fn() + Sync + Send>>>: Unpin, Arc<Vec<(&'static str, Arc<dyn Fake>)>>: Unpin, Arc<Vec<(&'static str, GpuSource)>>: Unpin, Arc<Handle>: Unpin, Arc<Handle>: Unpin, Arc<dyn StorageBackend>: Unpin, Arc<Mutex<Manual>>: Unpin, Arc<HashMap<TypeId, Arc<dyn Any + Sync + Send>, FxBuildHasher>>: Unpin, Arc<dyn ClipboardBackend>: Unpin, Arc<Mutex<Inner>>: Unpin, Arc<CallCount>: Unpin, Arc<dyn PickerBackend>: Unpin, Arc<dyn AudioBackend>: Unpin, Arc<dyn WindowBackend>: Unpin, Arc<dyn LoginItemBackend>: Unpin,

§

impl UnsafeUnpin for EngineConfig
where *const ArcInner<dyn Fn() -> AnyElement + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn() -> AnyElement + Sync + Send>>: UnsafeUnpin, *const ArcInner<Tokens> is !null: UnsafeUnpin, PhantomData<ArcInner<Tokens>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<Arc<[u8]>>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<String>: UnsafeUnpin, PhantomData<WebLink>: UnsafeUnpin, PhantomData<HostPattern>: UnsafeUnpin, PhantomData<HttpGrant>: UnsafeUnpin, PhantomData<SocketGrant>: UnsafeUnpin, PhantomData<WebMedia>: UnsafeUnpin, PhantomData<WindowKind>: UnsafeUnpin, PhantomData<WindowLevel>: UnsafeUnpin, *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: UnsafeUnpin, *const ArcInner<str> is !null: UnsafeUnpin, PhantomData<ArcInner<str>>: UnsafeUnpin, *const ArcInner<Vec<Chunk>> is !null: UnsafeUnpin, PhantomData<ArcInner<Vec<Chunk>>>: UnsafeUnpin, *const ArcInner<PackageInfo> is !null: UnsafeUnpin, PhantomData<ArcInner<PackageInfo>>: UnsafeUnpin, *const ArcInner<[u8]> is !null: UnsafeUnpin, PhantomData<ArcInner<[u8]>>: UnsafeUnpin, *const ArcInner<dyn Trial> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Trial>>: UnsafeUnpin, *const ArcInner<dyn Network> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Network>>: UnsafeUnpin, *const ArcInner<dyn WebSocketTransport> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn WebSocketTransport>>: UnsafeUnpin, *const ArcInner<dyn Fn(&str) -> JsError + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(&str) -> JsError + Sync + Send>>: UnsafeUnpin, *const ArcInner<dyn FileSystem> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn FileSystem>>: UnsafeUnpin, *const ArcInner<dyn Assets> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Assets>>: UnsafeUnpin, &'static str: UnsafeUnpin, PhantomData<Registry>: UnsafeUnpin, *const ArcInner<Handle> is !null: UnsafeUnpin, PhantomData<ArcInner<Handle>>: UnsafeUnpin, *const ArcInner<Handle> is !null: UnsafeUnpin, PhantomData<ArcInner<Handle>>: UnsafeUnpin, *const ArcInner<dyn StorageBackend> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn StorageBackend>>: UnsafeUnpin, *const ArcInner<Mutex<Manual>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<Manual>>>: UnsafeUnpin, *const ArcInner<HashMap<TypeId, Arc<dyn Any + Sync + Send>, FxBuildHasher>> is !null: UnsafeUnpin, PhantomData<ArcInner<HashMap<TypeId, Arc<dyn Any + Sync + Send>, FxBuildHasher>>>: UnsafeUnpin, *const ArcInner<dyn ClipboardBackend> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn ClipboardBackend>>: UnsafeUnpin, *const ArcInner<Mutex<Inner>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<Inner>>>: UnsafeUnpin, *const ArcInner<CallCount> is !null: UnsafeUnpin, PhantomData<ArcInner<CallCount>>: UnsafeUnpin, *const ArcInner<dyn PickerBackend> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn PickerBackend>>: UnsafeUnpin, *const ArcInner<dyn AudioBackend> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn AudioBackend>>: UnsafeUnpin, *const ArcInner<dyn WindowBackend> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn WindowBackend>>: UnsafeUnpin, *const ArcInner<dyn LoginItemBackend> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn LoginItemBackend>>: UnsafeUnpin,

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