Skip to main content

SystemHost

Struct SystemHost 

Source
pub struct SystemHost;
Expand description

A default host over the process: its streams, the system clock, UTC. The default host: the process’s streams, the system clock, UTC.

Trait Implementations§

Source§

impl Debug for SystemHost

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for SystemHost

Source§

fn default() -> SystemHost

Returns the “default value” for a type. Read more
Source§

impl Host for SystemHost

Source§

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

fn now_ms(&mut self) -> f64

Milliseconds since the Unix epoch (Date.now()).
Source§

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

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

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

fn read_file(&mut self, path: &str) -> Option<String>

The text of the file at path, for the CLI’s load and read (qjs --std). The default reads the process’s file system.
Source§

fn interrupt(&mut self) -> bool

Polled about every thousand loop back-edges and calls while a script runs: true stops the script with an uncatchable InternalError: interrupted. The default never interrupts.

Auto Trait Implementations§

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.