Skip to main content

JsEnv

Struct JsEnv 

Source
pub struct JsEnv(/* private fields */);

Implementations§

Source§

impl JsEnv

Source

pub fn new(env: *mut napi_env__) -> JsEnv

Source

pub fn inner(&self) -> *mut napi_env__

Source

pub fn create_string_utf8( &self, r_string: &str, ) -> Result<*mut napi_value__, NjError>

Source

pub fn create_string_utf8_from_bytes( &self, r_string: &[u8], ) -> Result<*mut napi_value__, NjError>

Source

pub fn create_double(&self, value: f64) -> Result<*mut napi_value__, NjError>

Source

pub fn create_int64(&self, value: i64) -> Result<*mut napi_value__, NjError>

Source

pub fn create_int32(&self, value: i32) -> Result<*mut napi_value__, NjError>

Source

pub fn create_uint32(&self, value: u32) -> Result<*mut napi_value__, NjError>

Source

pub fn create_bigint_uint64( &self, value: u64, ) -> Result<*mut napi_value__, NjError>

Source

pub fn create_object(&self) -> Result<*mut napi_value__, NjError>

Source

pub fn create_boolean(&self, value: bool) -> Result<*mut napi_value__, NjError>

Source

pub fn create_array_with_len( &self, len: usize, ) -> Result<*mut napi_value__, NjError>

Source

pub fn set_element( &self, object: *mut napi_value__, element: *mut napi_value__, index: usize, ) -> Result<(), NjError>

Source

pub fn get_element( &self, array: *mut napi_value__, index: u32, ) -> Result<*mut napi_value__, NjError>

Source

pub fn is_array(&self, array: *mut napi_value__) -> Result<bool, NjError>

check if napi value is array

Source

pub fn is_array_buffer(&self, array: *mut napi_value__) -> Result<bool, NjError>

check if napi value is array buffer

Source

pub fn is_buffer(&self, n_value: *mut napi_value__) -> Result<bool, NjError>

Source

pub fn is_date(&self, n_value: *mut napi_value__) -> Result<bool, NjError>

Source

pub fn is_error(&self, n_value: *mut napi_value__) -> Result<bool, NjError>

Source

pub fn get_global(&self) -> Result<*mut napi_value__, NjError>

Source

pub fn call_function( &self, recv: *mut napi_value__, func: *mut napi_value__, argv: Vec<*mut napi_value__>, ) -> Result<*mut napi_value__, NjError>

Source

pub fn get_cb_info( &self, info: *mut napi_callback_info__, max_count: usize, ) -> Result<JsCallback, NjError>

get callback information

Source

pub fn define_class( &self, name: &str, constructor: unsafe extern "C" fn(*mut napi_env__, *mut napi_callback_info__) -> *mut napi_value__, properties: PropertiesBuilder, ) -> Result<*mut napi_value__, NjError>

define classes

Source

pub fn create_reference( &self, cons: *mut napi_value__, count: u32, ) -> Result<*mut napi_ref__, NjError>

Source

pub fn delete_reference(&self, ref_: *mut napi_ref__) -> Result<(), NjError>

Source

pub fn get_new_target( &self, info: *mut napi_callback_info__, ) -> Result<*mut napi_value__, NjError>

Source

pub fn wrap( &self, js_object: *mut napi_value__, rust_obj: *mut u8, finalize: unsafe extern "C" fn(*mut napi_env__, *mut c_void, *mut c_void), ) -> Result<*mut napi_ref__, NjError>

Source

pub fn unwrap<T>( &self, js_this: *mut napi_value__, ) -> Result<&'static T, NjError>

Source

pub fn unwrap_mut<T>( &self, js_this: *mut napi_value__, ) -> Result<&'static mut T, NjError>

Source

pub fn new_instance( &self, constructor: *mut napi_value__, args: Vec<*mut napi_value__>, ) -> Result<*mut napi_value__, NjError>

Source

pub fn get_reference_value( &self, obj_ref: *mut napi_ref__, ) -> Result<*mut napi_value__, NjError>

Source

pub fn create_promise( &self, ) -> Result<(*mut napi_value__, *mut napi_deferred__), NjError>

create promise and deferred

Source

pub fn resolve_deferred( &self, deferred: *mut napi_deferred__, resolution: *mut napi_value__, ) -> Result<(), NjError>

Source

pub fn reject_deferred( &self, deferred: *mut napi_deferred__, rejection: *mut napi_value__, ) -> Result<(), NjError>

Source

pub fn create_thread_safe_function( &self, name: &str, js_func: Option<*mut napi_value__>, call_js_cb: Option<unsafe extern "C" fn(*mut napi_env__, *mut napi_value__, *mut c_void, *mut c_void)>, ) -> Result<ThreadSafeFunction, NjError>

Source

pub fn is_exception_pending(&self) -> bool

Source

pub fn throw(&self, value: *mut napi_value__)

Source

pub fn throw_type_error(&self, message: &str)

Source

pub fn create_error(&self, message: &str) -> Result<*mut napi_value__, NjError>

Source

pub fn value_type(&self, napi_value: *mut napi_value__) -> Result<u32, NjError>

get value type

Source

pub fn is_undefined_or_null( &self, napi_value: *mut napi_value__, ) -> Result<bool, NjError>

is value undefined or null

Source

pub fn value_type_string( &self, napi_value: *mut napi_value__, ) -> Result<&'static str, NjError>

get string representation of value type

Source

pub fn assert_type( &self, napi_value: *mut napi_value__, should_be_type: u32, ) -> Result<(), NjError>

assert that napi value is certain type, otherwise raise exception

Source

pub fn convert_to_rust<'a, T>( &'a self, napi_value: *mut napi_value__, ) -> Result<T, NjError>
where T: JSValue<'a>,

convert napi value to rust value

Source

pub fn get_undefined(&self) -> Result<*mut napi_value__, NjError>

Source

pub fn get_null(&self) -> Result<*mut napi_value__, NjError>

Source

pub fn get_buffer_info( &self, napi_value: *mut napi_value__, ) -> Result<&[u8], NjError>

get buffer info

Source

pub fn detach_arraybuffer( &self, napi_value: *mut napi_value__, ) -> Result<(), NjError>

Detach ArrayBuffer

Source

pub fn is_detached_arraybuffer( &self, napi_value: *mut napi_value__, ) -> Result<bool, NjError>

Is this ArrayBuffer Detached?

Source

pub unsafe fn add_env_clean_up_hook( &self, init_func: Option<unsafe extern "C" fn(*mut c_void)>, arg: *mut c_void, ) -> Result<(), NjError>

Trait Implementations§

Source§

impl Clone for JsEnv

Source§

fn clone(&self) -> JsEnv

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for JsEnv

Source§

impl Debug for JsEnv

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl ExtractArgFromJs<'_> for JsEnv

Source§

fn convert_arg_at(js_cb: &JsCallback, _index: usize) -> Result<JsEnv, NjError>

convert js callback argument at index
Source§

fn label() -> &'static str

Source§

impl ExtractFromJs<'_> for JsEnv

Source§

fn extract(js_cb: &mut JsCallback) -> Result<JsEnv, NjError>

extract from js callback
Source§

fn label() -> &'static str

Source§

impl From<*mut napi_env__> for JsEnv

Source§

fn from(env: *mut napi_env__) -> JsEnv

Converts to this type from the input type.
Source§

impl Send for JsEnv

Source§

impl Sync for JsEnv

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more