Struct neon::context::ModuleContext[][src]

pub struct ModuleContext<'a> { /* fields omitted */ }
Expand description

An execution context of module initialization.

Implementations

impl<'a> ModuleContext<'a>[src]

pub fn export_function<T: Value>(
    &mut self,
    key: &str,
    f: fn(_: FunctionContext<'_>) -> JsResult<'_, T>
) -> NeonResult<()>
[src]

Convenience method for exporting a Neon function from a module.

pub fn export_class<T: Class>(&mut self, key: &str) -> NeonResult<()>[src]

Convenience method for exporting a Neon class constructor from a module.

pub fn export_value<T: Value>(
    &mut self,
    key: &str,
    val: Handle<'_, T>
) -> NeonResult<()>
[src]

Exports a JavaScript value from a Neon module.

pub fn exports_object(&mut self) -> JsResult<'a, JsObject>[src]

Produces a handle to a module’s exports object.

Trait Implementations

impl<'a> Context<'a> for ModuleContext<'a>[src]

fn lock(&self) -> Lock<'_>[src]

Lock the JavaScript engine, returning an RAII guard that keeps the lock active as long as the guard is alive. Read more

fn borrow<'c, V, T, F>(&self, v: &'c Handle<'_, V>, f: F) -> T where
    V: Value,
    &'c V: Borrow,
    F: for<'b> FnOnce(Ref<'b, <&'c V as Borrow>::Target>) -> T, 
[src]

Convenience method for locking the JavaScript engine and borrowing a single JS value’s internals. Read more

fn borrow_mut<'c, V, T, F>(&self, v: &'c mut Handle<'_, V>, f: F) -> T where
    V: Value,
    &'c mut V: BorrowMut,
    F: for<'b> FnOnce(RefMut<'b, <&'c mut V as Borrow>::Target>) -> T, 
[src]

Convenience method for locking the JavaScript engine and mutably borrowing a single JS value’s internals. Read more

fn execute_scoped<T, F>(&self, f: F) -> T where
    F: for<'b> FnOnce(ExecuteContext<'b>) -> T, 
[src]

Executes a computation in a new memory management scope. Read more

fn compute_scoped<V, F>(&self, f: F) -> JsResult<'a, V> where
    V: Value,
    F: for<'b, 'c> FnOnce(ComputeContext<'b, 'c>) -> JsResult<'b, V>, 
[src]

Executes a computation in a new memory management scope and computes a single result value that outlives the computation. Read more

fn try_catch<T, F>(&mut self, f: F) -> Result<T, Handle<'a, JsValue>> where
    F: FnOnce(&mut Self) -> NeonResult<T>, 
[src]

fn boolean(&mut self, b: bool) -> Handle<'a, JsBoolean>[src]

Convenience method for creating a JsBoolean value.

fn number<T: Into<f64>>(&mut self, x: T) -> Handle<'a, JsNumber>[src]

Convenience method for creating a JsNumber value.

fn string<S: AsRef<str>>(&mut self, s: S) -> Handle<'a, JsString>[src]

Convenience method for creating a JsString value. Read more

fn try_string<S: AsRef<str>>(&mut self, s: S) -> StringResult<'a>[src]

Convenience method for creating a JsString value. Read more

fn null(&mut self) -> Handle<'a, JsNull>[src]

Convenience method for creating a JsNull value.

fn undefined(&mut self) -> Handle<'a, JsUndefined>[src]

Convenience method for creating a JsUndefined value.

fn empty_object(&mut self) -> Handle<'a, JsObject>[src]

Convenience method for creating an empty JsObject value.

fn empty_array(&mut self) -> Handle<'a, JsArray>[src]

Convenience method for creating an empty JsArray value.

fn array_buffer(&mut self, size: u32) -> JsResult<'a, JsArrayBuffer>[src]

Convenience method for creating an empty JsArrayBuffer value.

fn buffer(&mut self, size: u32) -> JsResult<'a, JsBuffer>[src]

Convenience method for creating an empty JsBuffer value.

fn global(&mut self) -> Handle<'a, JsObject>[src]

Produces a handle to the JavaScript global object.

fn throw<T: Value, U>(&mut self, v: Handle<'_, T>) -> NeonResult<U>[src]

Throws a JS value.

fn error<S: AsRef<str>>(&mut self, msg: S) -> JsResult<'a, JsError>[src]

Creates a direct instance of the Error class.

fn type_error<S: AsRef<str>>(&mut self, msg: S) -> JsResult<'a, JsError>[src]

Creates an instance of the TypeError class.

fn range_error<S: AsRef<str>>(&mut self, msg: S) -> JsResult<'a, JsError>[src]

Creates an instance of the RangeError class.

fn throw_error<S: AsRef<str>, T>(&mut self, msg: S) -> NeonResult<T>[src]

Throws a direct instance of the Error class.

fn throw_type_error<S: AsRef<str>, T>(&mut self, msg: S) -> NeonResult<T>[src]

Throws an instance of the TypeError class.

fn throw_range_error<S: AsRef<str>, T>(&mut self, msg: S) -> NeonResult<T>[src]

Throws an instance of the RangeError class.

impl<'a> UnwindSafe for ModuleContext<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for ModuleContext<'a>

impl<'a> !Send for ModuleContext<'a>

impl<'a> !Sync for ModuleContext<'a>

impl<'a> Unpin for ModuleContext<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.