Skip to main content

Guest

Struct Guest 

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

Source

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.

Source

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.

Source

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.

Source

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>

Source

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>

Source

pub fn new(bridge: B) -> Self

Source

pub fn tick(&mut self) -> Result<()>

Source

pub fn node(&mut self, id: NodeId) -> Value

Source

pub fn queue(&mut self, callback: Value, this: Value, args: Vec<Value>)

Source

pub fn get_property( &mut self, document: &mut BaseDocument, receiver: &Value, key: &str, ) -> Result<Value>

Source

pub fn set_property( &mut self, document: &mut BaseDocument, receiver: &Value, key: &str, value: Value, ) -> Result<()>

Source

pub fn call( &mut self, document: &mut BaseDocument, callee: Value, this: Value, args: Vec<Value>, construct: bool, ) -> Result<Value>

Source

pub fn report_error(&mut self, error: Error)

Source

pub fn record_console(&mut self, level: &str, message: String)

Trait Implementations§

Source§

impl<B: RuntimeBridge> Drop for Guest<B>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<B: RuntimeBridge + NativeStorageBridge> NativeDocumentRuntime for Guest<B>

Source§

fn eval_named( &mut self, document: &mut BaseDocument, source: &str, _name: &str, ) -> Result<(), Self::Error>

Source§

fn eval_json( &mut self, document: &mut BaseDocument, source: &str, ) -> Result<Value, Self::Error>

Source§

fn has_pending_jobs(&self) -> bool

Source§

fn pending_task_count(&self) -> u64

Source§

fn diagnostic_batch( &self, console_after: u64, errors_after: u64, limit: usize, ) -> Result<DiagnosticBatch, Self::Error>

Source§

fn dispatch_dom_event( &mut self, document: &mut BaseDocument, event: DomEvent, ) -> Result<(), Self::Error>

Source§

fn handle_pointer_move_to_node( &mut self, document: &mut BaseDocument, event: BlitzPointerEvent, node: NodeId, ) -> Result<(), Self::Error>

Source§

fn handle_ui_event_to_node( &mut self, document: &mut BaseDocument, event: UiEvent, node: NodeId, ) -> Result<(), Self::Error>

Source§

fn dispatch_node_event( &mut self, document: &mut BaseDocument, node: NodeId, name: &str, ) -> Result<bool, Self::Error>

Source§

fn set_ipc_handler( &mut self, handler: Box<dyn Fn(String)>, ) -> Result<(), Self::Error>

Source§

impl<B: RuntimeBridge> NativeGuest for Guest<B>

Source§

type Value = Value

The guest’s native value representation.
Source§

type RealmId = u64

An identifier for one realm owned by this guest.
Source§

type CallbackId = u64

An identifier for a callback retained by this guest.
Source§

type Error = Error

Errors produced while invoking a callback.
Source§

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>

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>

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>

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>

Invoke a retained callback with typed arguments. Read more
Source§

impl<B: RuntimeBridge + NativeStorageBridge> TypedNativeGuest for Guest<B>

Source§

fn supports_intl(&self) -> bool

Whether the guest implements the Intl APIs required by this runtime.
Source§

fn supports_import_maps(&self) -> bool

Whether the guest can install and apply import maps.
Source§

fn supports_modules(&self) -> bool

Whether the guest can execute ECMAScript modules.
Source§

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>

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>

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>

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>

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>

Drain immediately runnable work according to the document settle policy.
Source§

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>

Notify the guest that this document is being disposed.
Source§

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>

Forward visibility and page lifecycle changes to the guest.
Source§

fn freeze(&mut self, document: &mut BaseDocument) -> Result<(), Self::Error>

Source§

fn finish_restore( &mut self, document: &mut BaseDocument, ) -> Result<(), Self::Error>

Source§

fn resume(&mut self, document: &mut BaseDocument) -> Result<(), Self::Error>

Source§

fn storage_get(&mut self, key: &str) -> Result<Option<Self::Value>, Self::Error>

Access the guest’s native storage without stringifying guest values.
Source§

fn storage_set( &mut self, key: &str, value: Self::Value, ) -> Result<(), Self::Error>

Source§

fn storage_remove(&mut self, key: &str) -> Result<(), Self::Error>

Source§

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>
where B: Freeze, BTreeMap<String, fn(&mut Guest<B>, &[<Guest<B> as NativeGuest>::Value]) -> Result<<Guest<B> as NativeGuest>::Value, <Guest<B> as NativeGuest>::Error>>: Freeze,

§

impl<B> Move for Guest<B>

§

impl<B> Unpin for Guest<B>
where B: Unpin, BTreeMap<String, fn(&mut Guest<B>, &[<Guest<B> as NativeGuest>::Value]) -> Result<<Guest<B> as NativeGuest>::Value, <Guest<B> as NativeGuest>::Error>>: Unpin,

§

impl<B> UnsafeUnpin for Guest<B>

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> ErasedDestructor for T
where T: 'static,

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

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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

impl<T> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

Convert
Source§

impl<T> MaybeBoxed<T> for T

Source§

fn maybe_boxed(self) -> T

Convert
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.