pub struct Guest<B: RuntimeBridge> {Show 19 fields
pub bridge: B,
pub global: Value,
pub env: Env,
pub nodes: BTreeMap<NodeId, Value>,
pub jobs: VecDeque<HostJob>,
pub callbacks: BTreeMap<u64, Value>,
pub next_callback: u64,
pub scope_id: u64,
pub generation: u64,
pub steps: usize,
pub depth: usize,
pub disposed: bool,
pub visible: bool,
pub frozen: bool,
pub ready_state: String,
pub console: Vec<DiagnosticEntry>,
pub errors: Vec<DiagnosticEntry>,
pub ipc_handler: Option<Box<dyn Fn(String)>>,
pub intrinsics: BTreeMap<String, NativeIntrinsic<Self>>,
/* private fields */
}Expand description
A persistent realm with bounded script entry and typed embedder bindings.
Fields§
§bridge: B§global: Value§env: Env§nodes: BTreeMap<NodeId, Value>§jobs: VecDeque<HostJob>§callbacks: BTreeMap<u64, Value>§next_callback: u64§scope_id: u64§generation: u64§steps: usize§depth: usize§disposed: bool§visible: bool§frozen: bool§ready_state: String§console: Vec<DiagnosticEntry>§errors: Vec<DiagnosticEntry>§ipc_handler: Option<Box<dyn Fn(String)>>§intrinsics: BTreeMap<String, NativeIntrinsic<Self>>Implementations§
Source§impl<B: RuntimeBridge> Guest<B>
impl<B: RuntimeBridge> Guest<B>
Sourcepub fn evaluate(
&mut self,
doc: &mut BaseDocument,
source: &str,
) -> Result<Value>
pub fn evaluate( &mut self, doc: &mut BaseDocument, source: &str, ) -> Result<Value>
Parse and execute one source unit in this guest’s persistent global scope.
Sourcepub fn call_function(
&mut self,
doc: &mut BaseDocument,
function: Rc<Function>,
this: Value,
args: Vec<Value>,
construct: bool,
) -> Result<Value>
pub fn call_function( &mut self, doc: &mut BaseDocument, function: Rc<Function>, this: Value, args: Vec<Value>, construct: bool, ) -> Result<Value>
Invoke a retained parsed function with its captured lexical environment.
Sourcepub fn await_value(
&mut self,
doc: &mut BaseDocument,
value: Value,
) -> Result<Value>
pub fn await_value( &mut self, doc: &mut BaseDocument, value: Value, ) -> Result<Value>
Resolve a settled promise or drive real bridge/jobs work for a pending one.
Sourcepub fn instance_of(
&mut self,
doc: &mut BaseDocument,
value: &Value,
constructor: &Value,
) -> Result<bool>
pub fn instance_of( &mut self, doc: &mut BaseDocument, value: &Value, constructor: &Value, ) -> Result<bool>
Test prototype identity for parsed functions and native constructors.
Source§impl<B: RuntimeBridge> Guest<B>
impl<B: RuntimeBridge> Guest<B>
Sourcepub fn invoke_retained_callback_with_document(
&mut self,
document: &mut BaseDocument,
callback: &RetainedCallback<u64, u64>,
arguments: &[Value],
) -> Result<Value>
pub fn invoke_retained_callback_with_document( &mut self, document: &mut BaseDocument, callback: &RetainedCallback<u64, u64>, arguments: &[Value], ) -> Result<Value>
Invoke a retained function while the owning document is borrowed.
Source§impl<B: RuntimeBridge> Guest<B>
impl<B: RuntimeBridge> Guest<B>
pub fn new(bridge: B) -> Self
pub fn tick(&mut self) -> Result<()>
pub fn node(&mut self, id: NodeId) -> Value
pub fn queue(&mut self, callback: Value, this: Value, args: Vec<Value>)
pub fn get_property( &mut self, document: &mut BaseDocument, receiver: &Value, key: &str, ) -> Result<Value>
pub fn set_property( &mut self, document: &mut BaseDocument, receiver: &Value, key: &str, value: Value, ) -> Result<()>
pub fn call( &mut self, document: &mut BaseDocument, callee: Value, this: Value, args: Vec<Value>, construct: bool, ) -> Result<Value>
pub fn report_error(&mut self, error: Error)
pub fn record_console(&mut self, level: &str, message: String)
Trait Implementations§
Source§impl<B: RuntimeBridge> Drop for Guest<B>
impl<B: RuntimeBridge> Drop for Guest<B>
Source§impl<B: RuntimeBridge + NativeStorageBridge> NativeDocumentRuntime for Guest<B>
impl<B: RuntimeBridge + NativeStorageBridge> NativeDocumentRuntime for Guest<B>
fn eval_named( &mut self, document: &mut BaseDocument, source: &str, _name: &str, ) -> Result<(), Self::Error>
fn eval_json( &mut self, document: &mut BaseDocument, source: &str, ) -> Result<Value, Self::Error>
fn has_pending_jobs(&self) -> bool
fn pending_task_count(&self) -> u64
fn diagnostic_batch( &self, console_after: u64, errors_after: u64, limit: usize, ) -> Result<DiagnosticBatch, Self::Error>
fn dispatch_dom_event( &mut self, document: &mut BaseDocument, event: DomEvent, ) -> Result<(), Self::Error>
fn handle_pointer_move_to_node( &mut self, document: &mut BaseDocument, event: BlitzPointerEvent, node: NodeId, ) -> Result<(), Self::Error>
fn handle_ui_event_to_node( &mut self, document: &mut BaseDocument, event: UiEvent, node: NodeId, ) -> Result<(), Self::Error>
fn dispatch_node_event( &mut self, document: &mut BaseDocument, node: NodeId, name: &str, ) -> Result<bool, Self::Error>
fn set_ipc_handler( &mut self, handler: Box<dyn Fn(String)>, ) -> Result<(), Self::Error>
Source§impl<B: RuntimeBridge> NativeGuest for Guest<B>
impl<B: RuntimeBridge> NativeGuest for Guest<B>
Source§type CallbackId = u64
type CallbackId = u64
An identifier for a callback retained by this guest.
Source§fn scope(&self) -> RealmScope<Self::RealmId>
fn scope(&self) -> RealmScope<Self::RealmId>
Return this guest’s current realm and generation, rather than accepting
a caller-supplied scope as authority to enter the guest.
Source§fn retain_callback(
&mut self,
callback: &Self::Value,
) -> Result<RetainedCallback<Self::RealmId, Self::CallbackId>, Self::Error>
fn retain_callback( &mut self, callback: &Self::Value, ) -> Result<RetainedCallback<Self::RealmId, Self::CallbackId>, Self::Error>
Root an executable guest callback until release or realm teardown.
Reject values that are not callable without evaluating their source.
Source§fn release_callback(
&mut self,
callback: &RetainedCallback<Self::RealmId, Self::CallbackId>,
) -> Result<(), Self::Error>
fn release_callback( &mut self, callback: &RetainedCallback<Self::RealmId, Self::CallbackId>, ) -> Result<(), Self::Error>
Revoke dispatch and release the guest root. Other token clones must
become unusable. Unknown, released and stale tokens must be rejected.
Source§fn register_intrinsic(
&mut self,
name: &'static str,
_arity: u8,
callback: NativeIntrinsic<Self>,
) -> Result<(), Self::Error>
fn register_intrinsic( &mut self, name: &'static str, _arity: u8, callback: NativeIntrinsic<Self>, ) -> Result<(), Self::Error>
Install a compiled typed host entry point before page scripts execute.
Guest-to-host conversions belong to the backend and must preserve value
identity, UTF-16 code units and buffer ownership without serializing JS.
Source§fn invoke_retained_callback(
&mut self,
callback: &RetainedCallback<Self::RealmId, Self::CallbackId>,
_arguments: &[Self::Value],
) -> Result<Self::Value, Self::Error>
fn invoke_retained_callback( &mut self, callback: &RetainedCallback<Self::RealmId, Self::CallbackId>, _arguments: &[Self::Value], ) -> Result<Self::Value, Self::Error>
Invoke a retained callback with typed arguments. Read more
Source§impl<B: RuntimeBridge + NativeStorageBridge> TypedNativeGuest for Guest<B>
impl<B: RuntimeBridge + NativeStorageBridge> TypedNativeGuest for Guest<B>
Source§fn supports_intl(&self) -> bool
fn supports_intl(&self) -> bool
Whether the guest implements the Intl APIs required by this runtime.
Source§fn supports_import_maps(&self) -> bool
fn supports_import_maps(&self) -> bool
Whether the guest can install and apply import maps.
Source§fn supports_modules(&self) -> bool
fn supports_modules(&self) -> bool
Whether the guest can execute ECMAScript modules.
Source§fn install_document(
&mut self,
document: &mut BaseDocument,
) -> Result<(), Self::Error>
fn install_document( &mut self, document: &mut BaseDocument, ) -> Result<(), Self::Error>
Install a parsed document and its host bindings into this guest.
Source§fn execute_source(
&mut self,
document: &mut BaseDocument,
source: &str,
_source_url: Option<&Url>,
kind: &ScriptKind,
) -> Result<(), Self::Error>
fn execute_source( &mut self, document: &mut BaseDocument, source: &str, _source_url: Option<&Url>, kind: &ScriptKind, ) -> Result<(), Self::Error>
Execute source through this guest. Implementations must return an error
when the selected script kind is unsupported.
Source§fn install_import_map(
&mut self,
_source: &str,
_base_url: Option<&Url>,
) -> Result<(), Self::Error>
fn install_import_map( &mut self, _source: &str, _base_url: Option<&Url>, ) -> Result<(), Self::Error>
Install an import map using the guest’s native import-map machinery.
Source§fn dispatch_ui_event(
&mut self,
document: &mut BaseDocument,
event: UiEvent,
) -> Result<(), Self::Error>
fn dispatch_ui_event( &mut self, document: &mut BaseDocument, event: UiEvent, ) -> Result<(), Self::Error>
Dispatch an input event through this guest’s DOM event implementation.
Source§fn poll(
&mut self,
document: &mut BaseDocument,
context: Option<Context<'_>>,
) -> Result<bool, Self::Error>
fn poll( &mut self, document: &mut BaseDocument, context: Option<Context<'_>>, ) -> Result<bool, Self::Error>
Poll guest jobs and host work associated with this document.
Source§fn poll_for_settle(
&mut self,
document: &mut BaseDocument,
context: Option<Context<'_>>,
run_timers: bool,
) -> Result<bool, Self::Error>
fn poll_for_settle( &mut self, document: &mut BaseDocument, context: Option<Context<'_>>, run_timers: bool, ) -> Result<bool, Self::Error>
Drain immediately runnable work according to the document settle policy.
Source§fn prepare_teardown(
&mut self,
_document: &mut BaseDocument,
) -> Result<(), Self::Error>
fn prepare_teardown( &mut self, _document: &mut BaseDocument, ) -> Result<(), Self::Error>
Notify the guest that this document is preparing for teardown.
Source§fn dispose_document(
&mut self,
_document: &mut BaseDocument,
) -> Result<(), Self::Error>
fn dispose_document( &mut self, _document: &mut BaseDocument, ) -> Result<(), Self::Error>
Notify the guest that this document is being disposed.
Source§fn finish_loading(
&mut self,
document: &mut BaseDocument,
) -> Result<(), Self::Error>
fn finish_loading( &mut self, document: &mut BaseDocument, ) -> Result<(), Self::Error>
Complete ready-state transitions and loading events after script bootstrap.
Source§fn set_page_visible(
&mut self,
document: &mut BaseDocument,
visible: bool,
) -> Result<(), Self::Error>
fn set_page_visible( &mut self, document: &mut BaseDocument, visible: bool, ) -> Result<(), Self::Error>
Forward visibility and page lifecycle changes to the guest.
fn freeze(&mut self, document: &mut BaseDocument) -> Result<(), Self::Error>
fn finish_restore( &mut self, document: &mut BaseDocument, ) -> Result<(), Self::Error>
fn resume(&mut self, document: &mut BaseDocument) -> Result<(), Self::Error>
Source§fn storage_get(&mut self, key: &str) -> Result<Option<Self::Value>, Self::Error>
fn storage_get(&mut self, key: &str) -> Result<Option<Self::Value>, Self::Error>
Access the guest’s native storage without stringifying guest values.
fn storage_set( &mut self, key: &str, value: Self::Value, ) -> Result<(), Self::Error>
fn storage_remove(&mut self, key: &str) -> Result<(), Self::Error>
fn storage_clear(&mut self) -> Result<(), Self::Error>
Auto Trait Implementations§
impl<B> !RefUnwindSafe for Guest<B>
impl<B> !Send for Guest<B>
impl<B> !Sync for Guest<B>
impl<B> !UnwindSafe for Guest<B>
impl<B> Forget for Guest<B>
impl<B> Freeze for Guest<B>
impl<B> Move for Guest<B>
impl<B> Unpin for Guest<B>
impl<B> UnsafeUnpin for Guest<B>where
B: UnsafeUnpin,
BTreeMap<String, fn(&mut Guest<B>, &[<Guest<B> as NativeGuest>::Value]) -> Result<<Guest<B> as NativeGuest>::Value, <Guest<B> as NativeGuest>::Error>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert