pub struct AsyncContext { /* private fields */ }
Available on crate feature futures only.
Expand description

An asynchronous single execution context with its own global variables and stack.

Can share objects with other contexts of the same runtime.

Implementations§

source§

impl AsyncContext

source

pub async fn base(runtime: &AsyncRuntime) -> Result<Self>

Creates a base context with only the required functions registered. If additional functions are required use AsyncContext::custom, AsyncContext::builder or AsyncContext::full.

source

pub async fn custom<I: Intrinsic>(runtime: &AsyncRuntime) -> Result<Self>

Creates a context with only the required intrinsics registered. If additional functions are required use AsyncContext::custom, AsyncContext::builder or AsyncContext::full.

source

pub async fn full(runtime: &AsyncRuntime) -> Result<Self>

Creates a context with all standart available intrinsics registered. If precise controll is required of which functions are available use AsyncContext::custom or AsyncContext::builder.

source

pub fn builder() -> ContextBuilder<()>

Create a context builder for creating a context with a specific set of intrinsics

source

pub async fn enable_big_num_ext(&self, enable: bool)

source

pub fn runtime(&self) -> &AsyncRuntime

Returns the associated runtime

source

pub async fn async_with<F, R>(&self, f: F) -> Rwhere F: for<'js> FnOnce(Ctx<'js>) -> Pin<Box<dyn Future<Output = R> + Send + 'js>> + ParallelSend, R: ParallelSend,

A entry point for manipulating and using javascript objects and scripts.

This function is rather limited in what environment it can capture. If you need to borrow the environment in the closure use the async_with! macro.

Unfortunatly it is currently impossible to have closures return a generic future which has a higher rank trait bound lifetime. So, to allow closures to work, the closure must return a boxed future.

source

pub async fn with<F, R>(&self, f: F) -> Rwhere F: for<'js> FnOnce(Ctx<'js>) -> R + ParallelSend, R: ParallelSend,

A entry point for manipulating and using javascript objects and scripts.

This closure can’t return a future, if you need to await javascript promises prefer the async_with! macro.

Trait Implementations§

source§

impl Clone for AsyncContext

source§

fn clone(&self) -> AsyncContext

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Drop for AsyncContext

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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.
source§

impl<T> ParallelSend for T