pub struct BrowserHost {
pub status: Arc<Mutex<PageStatus>>,
pub host_state: HostState,
/* private fields */
}Expand description
Main host-side entry point: Wasmtime engine, shared tab status, and guest-facing host state.
Use BrowserHost::new on the UI thread, then BrowserHost::fetch_and_run or
BrowserHost::run_bytes to load modules. BrowserHost::recreate builds a second host
that shares HostState and PageStatus for background workers.
Fields§
§status: Arc<Mutex<PageStatus>>Latest PageStatus for this tab, safe to share with worker threads via Arc and Mutex.
host_state: HostStateSandbox resources and host imports: module loader, KV/bookmarks, canvas, timers, console, etc.
Implementations§
Source§impl BrowserHost
impl BrowserHost
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Creates a new host with default SandboxPolicy, a persistent KV store under the platform
data directory, and an initialized BookmarkStore.
Sourcepub fn recreate(host_state: HostState, status: Arc<Mutex<PageStatus>>) -> Self
pub fn recreate(host_state: HostState, status: Arc<Mutex<PageStatus>>) -> Self
Re-creates a BrowserHost that shares the given HostState and PageStatus.
Used when worker threads need their own WasmEngine / Wasmtime instance while keeping
bookmarks, KV, canvas handles, and tab status in sync with the main host.
Sourcepub async fn fetch_and_run(&mut self, url: &str) -> Result<Option<LiveModule>>
pub async fn fetch_and_run(&mut self, url: &str) -> Result<Option<LiveModule>>
Fetches a .wasm from url, compiles it, links the oxide imports, runs start_app(),
and returns a LiveModule if the guest exports on_frame.
Updates PageStatus to PageStatus::Loading then PageStatus::Running on success.
Supports http/https (network fetch) and file:// (local read) via OxideUrl parsing;
other schemes error.
Sourcepub fn run_bytes(&mut self, wasm_bytes: &[u8]) -> Result<Option<LiveModule>>
pub fn run_bytes(&mut self, wasm_bytes: &[u8]) -> Result<Option<LiveModule>>
Compiles and runs wasm_bytes like fetch_and_run, but without a
network fetch—useful for in-memory or locally read modules.
Sets PageStatus::Running with a "(local)" label. Returns Some with a LiveModule
when on_frame is exported, otherwise None.
Auto Trait Implementations§
impl Freeze for BrowserHost
impl !RefUnwindSafe for BrowserHost
impl Send for BrowserHost
impl Sync for BrowserHost
impl Unpin for BrowserHost
impl UnsafeUnpin for BrowserHost
impl !UnwindSafe for BrowserHost
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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