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: AppThe app.
viewport: Size<Points>Initial size of the root view.
trace: boolLog 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: 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>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: 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 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: 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) 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
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.