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§
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>>
Sourcefn script_compiler(&mut self) -> Option<&mut (dyn CompileProvider + 'static)>
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.
Sourcefn timers(&mut self) -> Option<&mut (dyn TimerProvider + 'static)>
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".