Struct Int16Array
#[repr(transparent)]
pub struct Int16Array { /* private fields */ }
Implementations
impl Int16Array
fn set(&self, src: &JsValue, offset: u32)The
set()method stores multiple values in the typed array, reading input values from a specified array.
impl Int16Array
fn get_index(&self, idx: u32) -> i16Gets the value at
idx, equivalent to the javascriptmy_var = arr[idx].
impl Int16Array
fn new(constructor_arg: &JsValue) -> Int16ArrayThe
Int16Array()constructor creates a new array.
impl Int16Array
fn new_with_byte_offset(buffer: &JsValue, byte_offset: u32) -> Int16ArrayAn
Int16Array()which creates an array with the given buffer but is a view starting atbyte_offset.
impl Int16Array
fn buffer(&self) -> ArrayBufferThe buffer accessor property represents the
ArrayBufferreferenced by aTypedArrayat construction time.
impl Int16Array
fn for_each(&self, callback: &mut impl FnMut(i16, u32, Int16Array) + MaybeUnwindSafe)The
forEach()method executes a provided function once per array element. This method has the same algorithm asArray.prototype.forEach().TypedArrayis one of the typed array types here.
impl Int16Array
fn byte_length(&self) -> u32The byteLength accessor property represents the length (in bytes) of a typed array.
impl Int16Array
fn at(&self, idx: i32) -> Option<i16>Gets the value at
idx, counting from the end if negative.
impl Int16Array
fn set_index(&self, idx: u32, value: i16)Sets the value at
idx, equivalent to the javascriptarr[idx] = value.
impl Int16Array
fn new_with_length(length: u32) -> Int16ArrayAn
Int16Array()which creates an array with an internal buffer large enough forlengthelements.
impl Int16Array
fn new_with_byte_offset_and_length(buffer: &JsValue, byte_offset: u32, length: u32) -> Int16ArrayAn
Int16Array()which creates an array with the given buffer but is a view starting atbyte_offsetforlengthelements.
impl Int16Array
fn subarray(&self, begin: u32, end: u32) -> Int16ArrayThe
subarray()method returns a newTypedArrayon the sameArrayBufferstore and with the same element types as for thisTypedArrayobject.
impl Int16Array
fn try_for_each(&self, callback: &mut impl FnMut(i16, u32, Int16Array) -> Result<(), JsError> + MaybeUnwindSafe) -> Result<(), JsValue>The
forEach()method executes a provided function once per array element. This method has the same algorithm asArray.prototype.forEach().TypedArrayis one of the typed array types here.
impl Int16Array
fn byte_offset(&self) -> u32The byteOffset accessor property represents the offset (in bytes) of a typed array from the start of its
ArrayBuffer.
impl Int16Array
fn copy_within(&self, target: i32, start: i32, end: i32) -> Int16ArrayThe
copyWithin()method shallow copies part of a typed array to another location in the same typed array and returns it, without modifying its size.
impl Int16Array
unsafe fn view(rust: &[i16]) -> Int16ArrayCreates a JS typed array which is a view into wasm's linear memory at the slice specified.
This function returns a new typed array which is a view into wasm's memory. This view does not copy the underlying data.
Safety
Views into WebAssembly memory are only valid so long as the backing buffer isn't resized in JS. Once this function is called any future calls to
Box::new(or malloc of any form) may cause the returned value here to be invalidated. Use with caution!Additionally the returned object can be safely mutated but the input slice isn't guaranteed to be mutable.
Finally, the returned object is disconnected from the input slice's lifetime, so there's no guarantee that the data is read at the right time.
unsafe fn view_mut_raw(ptr: *mut i16, length: usize) -> Int16ArrayCreates a JS typed array which is a view into wasm's linear memory at the specified pointer with specified length.
This function returns a new typed array which is a view into wasm's memory. This view does not copy the underlying data.
Safety
Views into WebAssembly memory are only valid so long as the backing buffer isn't resized in JS. Once this function is called any future calls to
Box::new(or malloc of any form) may cause the returned value here to be invalidated. Use with caution!Additionally the returned object can be safely mutated, the changes are guaranteed to be reflected in the input array.
unsafe fn raw_copy_to_ptr(&self, dst: *mut i16)Copy the contents of this JS typed array into the destination Rust pointer.
This function will efficiently copy the memory from a typed array into this Wasm module's own linear memory, initializing the memory destination provided.
Safety
This function requires
dstto point to a buffer large enough to fit this array's contents.fn copy_to(&self, dst: &mut [i16])Copy the contents of this JS typed array into the destination Rust slice.
This function will efficiently copy the memory from a typed array into this Wasm module's own linear memory, initializing the memory destination provided.
Panics
This function will panic if this typed array's length is different than the length of the provided
dstarray.fn copy_to_uninit<'dst>(&self, dst: &'dst mut [MaybeUninit<i16>]) -> &'dst mut [i16]Copy the contents of this JS typed array into the destination Rust slice.
This function will efficiently copy the memory from a typed array into this Wasm module's own linear memory, initializing the memory destination provided.
Panics
This function will panic if this typed array's length is different than the length of the provided
dstarray.fn copy_from(&self, src: &[i16])Copy the contents of the source Rust slice into this JS typed array.
This function will efficiently copy the memory from within the Wasm module's own linear memory to this typed array.
Panics
This function will panic if this typed array's length is different than the length of the provided
srcarray.fn to_vec(&self) -> Vec<i16>Efficiently copies the contents of this JS typed array into a new Vec.
impl Int16Array
fn new_from_slice(slice: &[i16]) -> Int16ArrayAn
Int16Array()which creates an array from a Rust slice.
impl Int16Array
fn fill(&self, value: i16, start: u32, end: u32) -> Int16ArrayThe
fill()method fills all the elements of an array from a start index to an end index with a static value. The end index is not included.
impl Int16Array
fn slice(&self, begin: u32, end: u32) -> Int16ArrayThe
slice()method returns a shallow copy of a portion of a typed array into a new typed array object. This method has the same algorithm asArray.prototype.slice().
impl Int16Array
fn length(&self) -> u32The length accessor property represents the length (in elements) of a typed array.
Trait Implementations
impl AsRef<Int16Array> for Int16Array
fn as_ref(&self) -> &Int16Array
impl AsRef<JsValue> for Int16Array
fn as_ref(&self) -> &JsValue
impl AsRef<Object> for Int16Array
fn as_ref(&self) -> &Object
impl Clone for Int16Array
fn clone(&self) -> Self
impl Debug for Int16Array
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for Int16Array
fn default() -> Self
impl Deref for Int16Array
type Target = Object;fn deref(&self) -> &Object
impl ErasableGeneric for Int16Array
type Repr = JsValue;
impl From<JsValue> for Int16Array
fn from(obj: JsValue) -> Self
impl FromWasmAbi for Int16Array
type Abi = <JsValue as FromWasmAbi>::Abi;unsafe fn from_abi(js: Self::Abi) -> Self
impl IntoJsGeneric for Int16Array
where
Int16Array: JsGeneric,
type JsCanon = Int16Array;fn to_js(self) -> Int16Array
impl IntoWasmAbi for Int16Array
type Abi = <JsValue as IntoWasmAbi>::Abi;fn into_abi(self) -> Self::Abi
impl JsCast for Int16Array
fn instanceof(val: &JsValue) -> boolfn unchecked_from_js(val: JsValue) -> Selffn unchecked_from_js_ref(val: &JsValue) -> &Self
impl LongRefFromWasmAbi for Int16Array
type Abi = <JsValue as LongRefFromWasmAbi>::Abi;type Anchor = Int16Array;unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
impl OptionFromWasmAbi for Int16Array
fn is_none(abi: &Self::Abi) -> bool
impl OptionIntoWasmAbi for Int16Array
fn none() -> Self::Abi
impl Promising for Int16Array
type Resolution = Int16Array;
impl RefFromWasmAbi for Int16Array
type Abi = <JsValue as RefFromWasmAbi>::Abi;type Anchor = ManuallyDrop<Int16Array>;unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
impl TypedArray for Int16Array
impl UpcastFrom<Int16Array> for Int16Array
impl WasmDescribe for Int16Array
fn describe()
impl<'a> From<&'a [i16]> for Int16Array
fn from(slice: &'a [i16]) -> Int16Array