Skip to main content

Host

Trait Host 

Source
pub trait Host {
Show 14 methods // Provided methods fn write_stdout(&mut self, _bytes: &[u8]) { ... } fn write_stderr(&mut self, _bytes: &[u8]) { ... } fn exit_code(&self) -> i32 { ... } fn set_exit_code(&mut self, _exit_code: i32) { ... } fn argv(&self) -> &[String] { ... } fn env(&self, _name: &str) -> Option<&str> { ... } fn set_env(&mut self, _name: &str, _value: &str) { ... } fn delete_env(&mut self, _name: &str) -> bool { ... } fn now_ms(&mut self) -> u64 { ... } fn monotonic_ns(&mut self) -> u64 { ... } fn random(&mut self) -> f64 { ... } fn hash(&mut self, _algorithm: &str, _data: &[u8]) -> Option<Vec<u8>> { ... } fn script_compiler( &mut self, ) -> Option<&mut (dyn CompileProvider + 'static)> { ... } fn timers(&mut self) -> Option<&mut (dyn TimerProvider + 'static)> { ... }
}
Expand description

External capabilities available to the JavaScript runtime.

Runtime values never cross this boundary. The engine owns all JavaScript objects and value semantics; hosts provide byte sinks and process services.

Provided Methods§

Source

fn write_stdout(&mut self, _bytes: &[u8])

Source

fn write_stderr(&mut self, _bytes: &[u8])

Source

fn exit_code(&self) -> i32

Source

fn set_exit_code(&mut self, _exit_code: i32)

Source

fn argv(&self) -> &[String]

Source

fn env(&self, _name: &str) -> Option<&str>

Source

fn set_env(&mut self, _name: &str, _value: &str)

Source

fn delete_env(&mut self, _name: &str) -> bool

Source

fn now_ms(&mut self) -> u64

Source

fn monotonic_ns(&mut self) -> u64

Source

fn random(&mut self) -> f64

Source

fn hash(&mut self, _algorithm: &str, _data: &[u8]) -> Option<Vec<u8>>

Source

fn script_compiler(&mut self) -> Option<&mut (dyn CompileProvider + 'static)>

This host’s script compiler, or None when it provides none.

Presence MUST remain stable for the lifetime of one machine because it determines whether node:vm is installed during construction.

Source

fn timers(&mut self) -> Option<&mut (dyn TimerProvider + 'static)>

This host’s timer scheduler, or None when it provides none.

Presence MUST remain stable for the lifetime of one machine because it determines whether setTimeout/clearTimeout are installed during construction.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§