pub struct EngineConfig {Show 17 fields
pub app: App,
pub viewport: Size<Points>,
pub trace: bool,
pub network: Option<Arc<dyn Network>>,
pub websocket: Option<Arc<dyn WebSocketTransport>>,
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 storage: Option<Arc<dyn StorageBackend>>,
pub clock: Clock,
pub pinned: EnvironmentPins,
pub clipboard: Option<Arc<dyn ClipboardBackend>>,
}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.
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.
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.
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.
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.