pub struct JsRuntime { /* private fields */ }Expand description
One VM + global object, created once, never released. !Send: only touched from the thread that created it.
Implementations§
Source§impl JsRuntime
impl JsRuntime
Sourcepub fn init()
pub fn init()
Boots JSC and installs the web platform layer. Once per PROCESS: a second boot reapplies
SK_JSC_OPTIONS after the first VM froze them and JSC fast-fails, so it panics instead.
pub fn with<R>(f: impl FnOnce(&JsRuntime) -> R) -> R
pub fn try_with<R>(f: impl FnOnce(&JsRuntime) -> R) -> Option<R>
pub fn raw(&self) -> *mut c_void
pub fn ctx(&self) -> &Context
pub fn eval(&self, src: &str, url: &str) -> Result<(), JsError>
pub fn register(&self, name: &str, arity: u32, f: *const c_void)
pub fn pump(&self, flags: u32) -> RjsPumpStats
pub fn drain_errors(&self) -> Vec<JsError>
Sourcepub fn set_content_provider(
&self,
f: impl Fn(&str) -> Option<Vec<u8>> + Send + Sync + 'static,
)
pub fn set_content_provider( &self, f: impl Fn(&str) -> Option<Vec<u8>> + Send + Sync + 'static, )
Installs the host content provider consulted by fetch() and image loads before the disk roots. The
closure lives in a process global behind a trampoline (the raw ABI has no user-data pointer), hence
Send + Sync. One provider per process; a second call is a no-op with an advisory.
pub fn clear_content_provider(&self)
pub fn describe(&self, exc: Value) -> JsError
Auto Trait Implementations§
impl !Send for JsRuntime
impl !Sync for JsRuntime
impl Forget for JsRuntime
impl Freeze for JsRuntime
impl Move for JsRuntime
impl RefUnwindSafe for JsRuntime
impl Unpin for JsRuntime
impl UnsafeUnpin for JsRuntime
impl UnwindSafe for JsRuntime
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
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 more