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: AppThe app.
viewport: Size<Points>Initial size of the root view.
trace: boolLog per-commit timings (target nsh::perf, level info).
content_culling: boolScroll 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: EnvironmentThe 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: LimitsThe 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: CacheOptionsWhere 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: ClockThe 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: EngineContextWhat 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: EnvironmentPinsValues 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: HostChannelThe 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
impl EngineConfig
Sourcepub fn new(app: impl Into<App>) -> Self
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.
Sourcepub fn main_window_placement(
&self,
displays: &[Display],
) -> Option<WindowPlacement>
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).