neon::types

Struct JsTypedArray

Source
pub struct JsTypedArray<T: Binary>(/* private fields */);
Expand description

The family of JavaScript typed array types.

§Typed Arrays

JavaScript’s typed arrays are objects that allow efficiently reading and writing raw binary data in memory. In Neon, the generic type JsTypedArray<T> represents a JavaScript typed array with element type T. For example, a JavaScript Uint32Array represents a compact array of 32-bit unsigned integers, and is represented in Neon as a JsTypedArray<u32>.

Neon also offers a set of convenience shorthands for concrete instances of JsTypedArray, named after their corresponding JavaScript type. For example, JsTypedArray<u32> can also be referred to as JsUint32Array.

The following table shows the complete set of typed array types, with both their JavaScript and Neon types:

Rust TypeConvenience TypeJavaScript Type
JsTypedArray<u8>JsUint8ArrayUint8Array
JsTypedArray<i8>JsInt8ArrayInt8Array
JsTypedArray<u16>JsUint16ArrayUint16Array
JsTypedArray<i16>JsInt16ArrayInt16Array
JsTypedArray<u32>JsUint32ArrayUint32Array
JsTypedArray<i32>JsInt32ArrayInt32Array
JsTypedArray<u64>JsBigUint64ArrayBigUint64Array
JsTypedArray<i64>JsBigInt64ArrayBigInt64Array
JsTypedArray<f32>JsFloat32ArrayFloat32Array
JsTypedArray<f64>JsFloat64ArrayFloat64Array

§Example: Creating an integer array

This example creates a typed array of unsigned 32-bit integers with a user-specified length:

fn create_int_array(mut cx: FunctionContext) -> JsResult<JsTypedArray<u32>> {
    let len = cx.argument::<JsNumber>(0)?.value(&mut cx) as usize;
    JsTypedArray::new(&mut cx, len)
}

§Buffers

Typed arrays are managed with the ArrayBuffer type, which controls the storage of the underlying data buffer, and several typed views for managing access to the buffer. Neon provides access to the ArrayBuffer class with the JsArrayBuffer type.

Node also provides a Buffer type, which is built on top of ArrayBuffer and provides additional functionality. Neon provides access to the Buffer class with the JsBuffer type.

Many of Node’s I/O APIs work with these types, and they can also be used for compact in-memory data structures, which can be shared efficiently between JavaScript and Rust without copying.

Implementations§

Source§

impl<T: Binary> JsTypedArray<T>
where JsTypedArray<T>: Value,

Source

pub fn from_slice<'cx, C>(cx: &mut C, slice: &[T]) -> JsResult<'cx, Self>
where C: Context<'cx>,

Constructs an instance from a slice by copying its contents.

This method is defined on JsTypedArray as a convenience and delegates to TypedArray::from_slice.

Source§

impl<T> JsTypedArray<T>
where T: Binary, Self: Value,

Source

pub fn from_buffer<'cx, 'b: 'cx, C>( cx: &mut C, buffer: Handle<'b, JsArrayBuffer>, ) -> JsResult<'cx, Self>
where C: Context<'cx>,

Constructs a typed array that views buffer.

The resulting typed array has (buffer.size() / size_of::<T>()) elements.

Source

pub fn from_region<'c, 'r, C>( cx: &mut C, region: &Region<'r, T>, ) -> JsResult<'c, Self>
where C: Context<'c>,

Constructs a typed array for the specified buffer region.

The resulting typed array has region.len() elements and a size of region.size() bytes.

Throws an exception if the region is invalid, for example if the starting offset is not properly aligned, or the length goes beyond the end of the buffer.

Source

pub fn region<'cx, C>(&self, cx: &mut C) -> Region<'cx, T>
where C: Context<'cx>,

Returns information about the backing buffer region for this typed array.

Source

pub fn new<'cx, C>(cx: &mut C, len: usize) -> JsResult<'cx, Self>
where C: Context<'cx>,

Constructs a new typed array of length len.

The resulting typed array has a newly allocated storage buffer of size (len * size_of::<T>()) bytes.

Source

pub fn buffer<'cx, C>(&self, cx: &mut C) -> Handle<'cx, JsArrayBuffer>
where C: Context<'cx>,

Returns the JsArrayBuffer that owns the underlying storage buffer for this typed array.

Note that the typed array might only reference a region of the buffer; use the offset() and size() methods to determine the region.

Source

pub fn offset<'cx, C>(&self, cx: &mut C) -> usize
where C: Context<'cx>,

Returns the offset (in bytes) of the typed array from the start of its JsArrayBuffer.

Source

pub fn len<'cx, C>(&self, cx: &mut C) -> usize
where C: Context<'cx>,

Returns the length of the typed array, i.e. the number of elements.

Note that, depending on the element size, this is not necessarily the same as size(). In particular:

self.size() == self.len() * size_of::<T>()

Trait Implementations§

Source§

impl<T: Debug + Binary> Debug for JsTypedArray<T>

Source§

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

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

impl Object for JsTypedArray<f32>

Source§

fn prop<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> PropOptions<'a, 'cx, Self, K>

Create a PropOptions for accessing a property. Read more
Source§

fn method<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> NeonResult<BindOptions<'a, 'cx>>

Gets a property from the object as a method and binds this to the object. Read more
Source§

fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Option<Handle<'a, V>>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_value<'a, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, JsValue>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, V>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_own_property_names<'a, C: Context<'a>>( &self, cx: &mut C, ) -> JsResult<'a, JsArray>

Available on crate feature napi-6 only.
Source§

fn freeze<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn seal<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn set<'a, C: Context<'a>, K: PropertyKey, W: Value>( &self, cx: &mut C, key: K, val: Handle<'_, W>, ) -> NeonResult<bool>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn root<'a, C: Context<'a>>(&self, cx: &mut C) -> Root<Self>

Source§

fn call_method_with<'a, C, K>( &self, cx: &mut C, method: K, ) -> NeonResult<CallOptions<'a>>
where C: Context<'a>, K: PropertyKey,

👎Deprecating in a future version: use Object::method() instead
Source§

impl Object for JsTypedArray<f64>

Source§

fn prop<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> PropOptions<'a, 'cx, Self, K>

Create a PropOptions for accessing a property. Read more
Source§

fn method<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> NeonResult<BindOptions<'a, 'cx>>

Gets a property from the object as a method and binds this to the object. Read more
Source§

fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Option<Handle<'a, V>>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_value<'a, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, JsValue>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, V>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_own_property_names<'a, C: Context<'a>>( &self, cx: &mut C, ) -> JsResult<'a, JsArray>

Available on crate feature napi-6 only.
Source§

fn freeze<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn seal<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn set<'a, C: Context<'a>, K: PropertyKey, W: Value>( &self, cx: &mut C, key: K, val: Handle<'_, W>, ) -> NeonResult<bool>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn root<'a, C: Context<'a>>(&self, cx: &mut C) -> Root<Self>

Source§

fn call_method_with<'a, C, K>( &self, cx: &mut C, method: K, ) -> NeonResult<CallOptions<'a>>
where C: Context<'a>, K: PropertyKey,

👎Deprecating in a future version: use Object::method() instead
Source§

impl Object for JsTypedArray<i16>

Source§

fn prop<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> PropOptions<'a, 'cx, Self, K>

Create a PropOptions for accessing a property. Read more
Source§

fn method<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> NeonResult<BindOptions<'a, 'cx>>

Gets a property from the object as a method and binds this to the object. Read more
Source§

fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Option<Handle<'a, V>>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_value<'a, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, JsValue>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, V>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_own_property_names<'a, C: Context<'a>>( &self, cx: &mut C, ) -> JsResult<'a, JsArray>

Available on crate feature napi-6 only.
Source§

fn freeze<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn seal<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn set<'a, C: Context<'a>, K: PropertyKey, W: Value>( &self, cx: &mut C, key: K, val: Handle<'_, W>, ) -> NeonResult<bool>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn root<'a, C: Context<'a>>(&self, cx: &mut C) -> Root<Self>

Source§

fn call_method_with<'a, C, K>( &self, cx: &mut C, method: K, ) -> NeonResult<CallOptions<'a>>
where C: Context<'a>, K: PropertyKey,

👎Deprecating in a future version: use Object::method() instead
Source§

impl Object for JsTypedArray<i32>

Source§

fn prop<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> PropOptions<'a, 'cx, Self, K>

Create a PropOptions for accessing a property. Read more
Source§

fn method<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> NeonResult<BindOptions<'a, 'cx>>

Gets a property from the object as a method and binds this to the object. Read more
Source§

fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Option<Handle<'a, V>>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_value<'a, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, JsValue>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, V>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_own_property_names<'a, C: Context<'a>>( &self, cx: &mut C, ) -> JsResult<'a, JsArray>

Available on crate feature napi-6 only.
Source§

fn freeze<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn seal<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn set<'a, C: Context<'a>, K: PropertyKey, W: Value>( &self, cx: &mut C, key: K, val: Handle<'_, W>, ) -> NeonResult<bool>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn root<'a, C: Context<'a>>(&self, cx: &mut C) -> Root<Self>

Source§

fn call_method_with<'a, C, K>( &self, cx: &mut C, method: K, ) -> NeonResult<CallOptions<'a>>
where C: Context<'a>, K: PropertyKey,

👎Deprecating in a future version: use Object::method() instead
Source§

impl Object for JsTypedArray<i64>

Source§

fn prop<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> PropOptions<'a, 'cx, Self, K>

Create a PropOptions for accessing a property. Read more
Source§

fn method<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> NeonResult<BindOptions<'a, 'cx>>

Gets a property from the object as a method and binds this to the object. Read more
Source§

fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Option<Handle<'a, V>>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_value<'a, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, JsValue>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, V>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_own_property_names<'a, C: Context<'a>>( &self, cx: &mut C, ) -> JsResult<'a, JsArray>

Available on crate feature napi-6 only.
Source§

fn freeze<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn seal<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn set<'a, C: Context<'a>, K: PropertyKey, W: Value>( &self, cx: &mut C, key: K, val: Handle<'_, W>, ) -> NeonResult<bool>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn root<'a, C: Context<'a>>(&self, cx: &mut C) -> Root<Self>

Source§

fn call_method_with<'a, C, K>( &self, cx: &mut C, method: K, ) -> NeonResult<CallOptions<'a>>
where C: Context<'a>, K: PropertyKey,

👎Deprecating in a future version: use Object::method() instead
Source§

impl Object for JsTypedArray<i8>

Source§

fn prop<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> PropOptions<'a, 'cx, Self, K>

Create a PropOptions for accessing a property. Read more
Source§

fn method<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> NeonResult<BindOptions<'a, 'cx>>

Gets a property from the object as a method and binds this to the object. Read more
Source§

fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Option<Handle<'a, V>>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_value<'a, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, JsValue>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, V>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_own_property_names<'a, C: Context<'a>>( &self, cx: &mut C, ) -> JsResult<'a, JsArray>

Available on crate feature napi-6 only.
Source§

fn freeze<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn seal<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn set<'a, C: Context<'a>, K: PropertyKey, W: Value>( &self, cx: &mut C, key: K, val: Handle<'_, W>, ) -> NeonResult<bool>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn root<'a, C: Context<'a>>(&self, cx: &mut C) -> Root<Self>

Source§

fn call_method_with<'a, C, K>( &self, cx: &mut C, method: K, ) -> NeonResult<CallOptions<'a>>
where C: Context<'a>, K: PropertyKey,

👎Deprecating in a future version: use Object::method() instead
Source§

impl Object for JsTypedArray<u16>

Source§

fn prop<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> PropOptions<'a, 'cx, Self, K>

Create a PropOptions for accessing a property. Read more
Source§

fn method<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> NeonResult<BindOptions<'a, 'cx>>

Gets a property from the object as a method and binds this to the object. Read more
Source§

fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Option<Handle<'a, V>>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_value<'a, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, JsValue>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, V>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_own_property_names<'a, C: Context<'a>>( &self, cx: &mut C, ) -> JsResult<'a, JsArray>

Available on crate feature napi-6 only.
Source§

fn freeze<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn seal<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn set<'a, C: Context<'a>, K: PropertyKey, W: Value>( &self, cx: &mut C, key: K, val: Handle<'_, W>, ) -> NeonResult<bool>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn root<'a, C: Context<'a>>(&self, cx: &mut C) -> Root<Self>

Source§

fn call_method_with<'a, C, K>( &self, cx: &mut C, method: K, ) -> NeonResult<CallOptions<'a>>
where C: Context<'a>, K: PropertyKey,

👎Deprecating in a future version: use Object::method() instead
Source§

impl Object for JsTypedArray<u32>

Source§

fn prop<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> PropOptions<'a, 'cx, Self, K>

Create a PropOptions for accessing a property. Read more
Source§

fn method<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> NeonResult<BindOptions<'a, 'cx>>

Gets a property from the object as a method and binds this to the object. Read more
Source§

fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Option<Handle<'a, V>>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_value<'a, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, JsValue>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, V>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_own_property_names<'a, C: Context<'a>>( &self, cx: &mut C, ) -> JsResult<'a, JsArray>

Available on crate feature napi-6 only.
Source§

fn freeze<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn seal<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn set<'a, C: Context<'a>, K: PropertyKey, W: Value>( &self, cx: &mut C, key: K, val: Handle<'_, W>, ) -> NeonResult<bool>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn root<'a, C: Context<'a>>(&self, cx: &mut C) -> Root<Self>

Source§

fn call_method_with<'a, C, K>( &self, cx: &mut C, method: K, ) -> NeonResult<CallOptions<'a>>
where C: Context<'a>, K: PropertyKey,

👎Deprecating in a future version: use Object::method() instead
Source§

impl Object for JsTypedArray<u64>

Source§

fn prop<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> PropOptions<'a, 'cx, Self, K>

Create a PropOptions for accessing a property. Read more
Source§

fn method<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> NeonResult<BindOptions<'a, 'cx>>

Gets a property from the object as a method and binds this to the object. Read more
Source§

fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Option<Handle<'a, V>>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_value<'a, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, JsValue>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, V>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_own_property_names<'a, C: Context<'a>>( &self, cx: &mut C, ) -> JsResult<'a, JsArray>

Available on crate feature napi-6 only.
Source§

fn freeze<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn seal<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn set<'a, C: Context<'a>, K: PropertyKey, W: Value>( &self, cx: &mut C, key: K, val: Handle<'_, W>, ) -> NeonResult<bool>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn root<'a, C: Context<'a>>(&self, cx: &mut C) -> Root<Self>

Source§

fn call_method_with<'a, C, K>( &self, cx: &mut C, method: K, ) -> NeonResult<CallOptions<'a>>
where C: Context<'a>, K: PropertyKey,

👎Deprecating in a future version: use Object::method() instead
Source§

impl Object for JsTypedArray<u8>

Source§

fn prop<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> PropOptions<'a, 'cx, Self, K>

Create a PropOptions for accessing a property. Read more
Source§

fn method<'a, 'cx: 'a, K: PropertyKey>( &self, cx: &'a mut Cx<'cx>, key: K, ) -> NeonResult<BindOptions<'a, 'cx>>

Gets a property from the object as a method and binds this to the object. Read more
Source§

fn get_opt<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Option<Handle<'a, V>>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_value<'a, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, JsValue>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get<'a, V: Value, C: Context<'a>, K: PropertyKey>( &self, cx: &mut C, key: K, ) -> NeonResult<Handle<'a, V>>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn get_own_property_names<'a, C: Context<'a>>( &self, cx: &mut C, ) -> JsResult<'a, JsArray>

Available on crate feature napi-6 only.
Source§

fn freeze<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn seal<'a, C: Context<'a>>(&self, cx: &mut C) -> NeonResult<&Self>

Source§

fn set<'a, C: Context<'a>, K: PropertyKey, W: Value>( &self, cx: &mut C, key: K, val: Handle<'_, W>, ) -> NeonResult<bool>

👎Deprecating in a future version: use Object::prop() instead
Source§

fn root<'a, C: Context<'a>>(&self, cx: &mut C) -> Root<Self>

Source§

fn call_method_with<'a, C, K>( &self, cx: &mut C, method: K, ) -> NeonResult<CallOptions<'a>>
where C: Context<'a>, K: PropertyKey,

👎Deprecating in a future version: use Object::method() instead
Source§

impl<T> TypedArray for JsTypedArray<T>
where T: Binary, Self: Value,

Source§

type Item = T

Source§

fn as_slice<'cx, 'a, C>(&self, cx: &'a C) -> &'a [Self::Item]
where C: Context<'cx>,

Statically checked immutable borrow of binary data. Read more
Source§

fn as_mut_slice<'cx, 'a, C>(&mut self, cx: &'a mut C) -> &'a mut [Self::Item]
where C: Context<'cx>,

Statically checked mutable borrow of binary data. Read more
Source§

fn try_borrow<'cx, 'b, C>( &self, lock: &'b Lock<'b, C>, ) -> Result<Ref<'b, Self::Item>, BorrowError>
where C: Context<'cx>,

Dynamically checked immutable borrow of binary data, returning an error if the the borrow would overlap with a mutable borrow. Read more
Source§

fn try_borrow_mut<'cx, 'a, C>( &mut self, lock: &'a Lock<'a, C>, ) -> Result<RefMut<'a, Self::Item>, BorrowError>
where C: Context<'cx>,

Dynamically checked mutable borrow of binary data, returning an error if the the borrow would overlap with an active borrow. Read more
Source§

fn size<'cx, C: Context<'cx>>(&self, cx: &mut C) -> usize

Returns the size, in bytes, of the allocated binary data.
Source§

fn from_slice<'cx, C>(cx: &mut C, slice: &[T]) -> JsResult<'cx, Self>
where C: Context<'cx>,

Constructs an instance from a slice by copying its contents.
Source§

impl Value for JsTypedArray<f32>

Source§

fn to_string<'cx, C: Context<'cx>>(&self, cx: &mut C) -> JsResult<'cx, JsString>

Source§

fn as_value<'cx, C: Context<'cx>>(&self, _: &mut C) -> Handle<'cx, JsValue>

Source§

fn to_raw(&self) -> Value

Available on crate feature sys only.
Get a raw reference to the wrapped Node-API value.
Source§

unsafe fn from_raw<'cx, C: Context<'cx>>( cx: &C, value: Value, ) -> Handle<'cx, Self>

Available on crate feature sys only.
Creates a value from a raw Node-API value. Read more
Source§

impl Value for JsTypedArray<f64>

Source§

fn to_string<'cx, C: Context<'cx>>(&self, cx: &mut C) -> JsResult<'cx, JsString>

Source§

fn as_value<'cx, C: Context<'cx>>(&self, _: &mut C) -> Handle<'cx, JsValue>

Source§

fn to_raw(&self) -> Value

Available on crate feature sys only.
Get a raw reference to the wrapped Node-API value.
Source§

unsafe fn from_raw<'cx, C: Context<'cx>>( cx: &C, value: Value, ) -> Handle<'cx, Self>

Available on crate feature sys only.
Creates a value from a raw Node-API value. Read more
Source§

impl Value for JsTypedArray<i16>

Source§

fn to_string<'cx, C: Context<'cx>>(&self, cx: &mut C) -> JsResult<'cx, JsString>

Source§

fn as_value<'cx, C: Context<'cx>>(&self, _: &mut C) -> Handle<'cx, JsValue>

Source§

fn to_raw(&self) -> Value

Available on crate feature sys only.
Get a raw reference to the wrapped Node-API value.
Source§

unsafe fn from_raw<'cx, C: Context<'cx>>( cx: &C, value: Value, ) -> Handle<'cx, Self>

Available on crate feature sys only.
Creates a value from a raw Node-API value. Read more
Source§

impl Value for JsTypedArray<i32>

Source§

fn to_string<'cx, C: Context<'cx>>(&self, cx: &mut C) -> JsResult<'cx, JsString>

Source§

fn as_value<'cx, C: Context<'cx>>(&self, _: &mut C) -> Handle<'cx, JsValue>

Source§

fn to_raw(&self) -> Value

Available on crate feature sys only.
Get a raw reference to the wrapped Node-API value.
Source§

unsafe fn from_raw<'cx, C: Context<'cx>>( cx: &C, value: Value, ) -> Handle<'cx, Self>

Available on crate feature sys only.
Creates a value from a raw Node-API value. Read more
Source§

impl Value for JsTypedArray<i64>

Source§

fn to_string<'cx, C: Context<'cx>>(&self, cx: &mut C) -> JsResult<'cx, JsString>

Source§

fn as_value<'cx, C: Context<'cx>>(&self, _: &mut C) -> Handle<'cx, JsValue>

Source§

fn to_raw(&self) -> Value

Available on crate feature sys only.
Get a raw reference to the wrapped Node-API value.
Source§

unsafe fn from_raw<'cx, C: Context<'cx>>( cx: &C, value: Value, ) -> Handle<'cx, Self>

Available on crate feature sys only.
Creates a value from a raw Node-API value. Read more
Source§

impl Value for JsTypedArray<i8>

Source§

fn to_string<'cx, C: Context<'cx>>(&self, cx: &mut C) -> JsResult<'cx, JsString>

Source§

fn as_value<'cx, C: Context<'cx>>(&self, _: &mut C) -> Handle<'cx, JsValue>

Source§

fn to_raw(&self) -> Value

Available on crate feature sys only.
Get a raw reference to the wrapped Node-API value.
Source§

unsafe fn from_raw<'cx, C: Context<'cx>>( cx: &C, value: Value, ) -> Handle<'cx, Self>

Available on crate feature sys only.
Creates a value from a raw Node-API value. Read more
Source§

impl Value for JsTypedArray<u16>

Source§

fn to_string<'cx, C: Context<'cx>>(&self, cx: &mut C) -> JsResult<'cx, JsString>

Source§

fn as_value<'cx, C: Context<'cx>>(&self, _: &mut C) -> Handle<'cx, JsValue>

Source§

fn to_raw(&self) -> Value

Available on crate feature sys only.
Get a raw reference to the wrapped Node-API value.
Source§

unsafe fn from_raw<'cx, C: Context<'cx>>( cx: &C, value: Value, ) -> Handle<'cx, Self>

Available on crate feature sys only.
Creates a value from a raw Node-API value. Read more
Source§

impl Value for JsTypedArray<u32>

Source§

fn to_string<'cx, C: Context<'cx>>(&self, cx: &mut C) -> JsResult<'cx, JsString>

Source§

fn as_value<'cx, C: Context<'cx>>(&self, _: &mut C) -> Handle<'cx, JsValue>

Source§

fn to_raw(&self) -> Value

Available on crate feature sys only.
Get a raw reference to the wrapped Node-API value.
Source§

unsafe fn from_raw<'cx, C: Context<'cx>>( cx: &C, value: Value, ) -> Handle<'cx, Self>

Available on crate feature sys only.
Creates a value from a raw Node-API value. Read more
Source§

impl Value for JsTypedArray<u64>

Source§

fn to_string<'cx, C: Context<'cx>>(&self, cx: &mut C) -> JsResult<'cx, JsString>

Source§

fn as_value<'cx, C: Context<'cx>>(&self, _: &mut C) -> Handle<'cx, JsValue>

Source§

fn to_raw(&self) -> Value

Available on crate feature sys only.
Get a raw reference to the wrapped Node-API value.
Source§

unsafe fn from_raw<'cx, C: Context<'cx>>( cx: &C, value: Value, ) -> Handle<'cx, Self>

Available on crate feature sys only.
Creates a value from a raw Node-API value. Read more
Source§

impl Value for JsTypedArray<u8>

Source§

fn to_string<'cx, C: Context<'cx>>(&self, cx: &mut C) -> JsResult<'cx, JsString>

Source§

fn as_value<'cx, C: Context<'cx>>(&self, _: &mut C) -> Handle<'cx, JsValue>

Source§

fn to_raw(&self) -> Value

Available on crate feature sys only.
Get a raw reference to the wrapped Node-API value.
Source§

unsafe fn from_raw<'cx, C: Context<'cx>>( cx: &C, value: Value, ) -> Handle<'cx, Self>

Available on crate feature sys only.
Creates a value from a raw Node-API value. Read more

Auto Trait Implementations§

§

impl<T> Freeze for JsTypedArray<T>

§

impl<T> RefUnwindSafe for JsTypedArray<T>
where T: RefUnwindSafe,

§

impl<T> !Send for JsTypedArray<T>

§

impl<T> !Sync for JsTypedArray<T>

§

impl<T> Unpin for JsTypedArray<T>
where T: Unpin,

§

impl<T> UnwindSafe for JsTypedArray<T>
where T: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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