pub trait Host {
// Provided methods
fn write(&mut self, stream: Stream, text: &[u8]) { ... }
fn now_ms(&mut self) -> f64 { ... }
fn local_tz_offset_minutes(&mut self, _utc_ms: f64) -> i32 { ... }
fn random_seed(&mut self) -> u64 { ... }
fn promise_rejection(&mut self, event: RejectionEvent, promise: Value) { ... }
fn read_file(&mut self, path: &str) -> Option<String> { ... }
fn interrupt(&mut self) -> bool { ... }
}Expand description
The embedder’s services. Every method has a default suitable for a standalone runtime: the process’s streams, the system clock and UTC.
Provided Methods§
Sourcefn write(&mut self, stream: Stream, text: &[u8])
fn write(&mut self, stream: Stream, text: &[u8])
Writes host output (print): UTF-8, with a lone surrogate of the
JavaScript string encoded as is (WTF-8), as QuickJS’s
JS_ToCStringLen writes it. The default writes to the process’s
streams.
Sourcefn local_tz_offset_minutes(&mut self, _utc_ms: f64) -> i32
fn local_tz_offset_minutes(&mut self, _utc_ms: f64) -> i32
UTC minus local time, in minutes, at utc_ms
(Date.prototype.getTimezoneOffset’s sign). The default is UTC.
Sourcefn random_seed(&mut self) -> u64
fn random_seed(&mut self) -> u64
The initial state of Math.random. The default derives it from the
system clock, as QuickJS seeds from host time.
Sourcefn promise_rejection(&mut self, event: RejectionEvent, promise: Value)
fn promise_rejection(&mut self, event: RejectionEvent, promise: Value)
HostPromiseRejectionTracker(promise, operation). The promise is a
value of the runtime; while rejection tracking is on
(Runtime::set_track_rejections)
the runtime also keeps every unhandled rejected promise alive in
Runtime::unhandled_rejections.
The default ignores the event.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".