Struct Float16Array

#[repr(transparent)]
pub struct Float16Array { /* private fields */ }

Implementations

impl Float16Array

fn new_with_byte_offset(buffer: &JsValue, byte_offset: u32) -> Float16Array

The Float16Array() constructor creates an array with the given buffer but is a view starting at byte_offset.

MDN documentation

impl Float16Array

fn buffer(&self) -> ArrayBuffer

The buffer accessor property represents the ArrayBuffer referenced by a TypedArray at construction time.

impl Float16Array

fn for_each_as_f32(&self, callback: &mut impl FnMut(f32, u32, Float16Array) + MaybeUnwindSafe)

The forEach() method executes a provided function once per array element, passing values as f32.

impl Float16Array

fn byte_length(&self) -> u32

The byteLength accessor property represents the length (in bytes) of a typed array.

impl Float16Array

fn at_as_f32(&self, idx: i32) -> Option<f32>

Gets the value at idx as an f32, counting from the end if negative.

impl Float16Array

fn set_index_from_f32(&self, idx: u32, value: f32)

Sets the value at idx from an f32, equivalent to JavaScript arr[idx] = value.

impl Float16Array

fn new(constructor_arg: &JsValue) -> Float16Array

The Float16Array() constructor creates a new array.

MDN documentation

impl Float16Array

fn new_with_byte_offset_and_length(buffer: &JsValue, byte_offset: u32, length: u32) -> Float16Array

The Float16Array() constructor creates an array with the given buffer but is a view starting at byte_offset for length elements.

MDN documentation

impl Float16Array

fn subarray(&self, begin: u32, end: u32) -> Float16Array

The subarray() method returns a new TypedArray on the same ArrayBuffer store and with the same element types as this array.

impl Float16Array

fn try_for_each_as_f32(&self, callback: &mut impl FnMut(f32, u32, Float16Array) -> Result<(), JsError> + MaybeUnwindSafe) -> Result<(), JsValue>

The forEach() method executes a provided function once per array element, passing values as f32.

impl Float16Array

fn byte_offset(&self) -> u32

The byteOffset accessor property represents the offset (in bytes) of a typed array from the start of its ArrayBuffer.

impl Float16Array

fn copy_within(&self, target: i32, start: i32, end: i32) -> Float16Array

The copyWithin() method shallow copies part of a typed array to another location in the same typed array and returns it, without modifying its size.

MDN documentation

impl Float16Array

fn new_from_u16_slice(slice: &[u16]) -> Float16Array

Creates an array from raw IEEE 754 binary16 bit patterns.

This pairs naturally with the optional half crate:

use half::f16;
use js_sys::Float16Array;

let values = [f16::from_f32(1.0), f16::from_f32(-2.0)];
let bits = values.map(f16::to_bits);
let array = Float16Array::new_from_u16_slice(&bits);
fn copy_to_u16_slice(&self, dst: &mut [u16])

Copy the raw IEEE 754 binary16 bit patterns from this JS typed array into the destination Rust slice.

Panics

This function will panic if this typed array's length is different than the length of the provided dst array.

Values copied into dst can be converted back into half::f16 with half::f16::from_bits.

fn copy_from_u16_slice(&self, src: &[u16])

Copy raw IEEE 754 binary16 bit patterns from the source Rust slice into this JS typed array.

Panics

This function will panic if this typed array's length is different than the length of the provided src array.

When using the optional half crate, populate src with half::f16::to_bits().

fn to_u16_vec(&self) -> Vec<u16>

Efficiently copies the contents of this JS typed array into a new Vec of raw IEEE 754 binary16 bit patterns.

This makes it easy to round-trip through the optional half crate:

use half::f16;

let bits = array.to_u16_vec();
let values: Vec<f16> = bits.into_iter().map(f16::from_bits).collect();

impl Float16Array

fn new_with_length(length: u32) -> Float16Array

The Float16Array() constructor creates an array with an internal buffer large enough for length elements.

MDN documentation

impl Float16Array

fn fill_with_f32(&self, value: f32, start: u32, end: u32) -> Float16Array

The fill() method fills all elements from a start index to an end index with a static f32 value.

MDN documentation

impl Float16Array

fn slice(&self, begin: u32, end: u32) -> Float16Array

The slice() method returns a shallow copy of a portion of a typed array into a new typed array object.

impl Float16Array

fn length(&self) -> u32

The length accessor property represents the length (in elements) of a typed array.

impl Float16Array

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 Float16Array

fn get_index_as_f32(&self, idx: u32) -> f32

Gets the value at idx as an f32, equivalent to JavaScript arr[idx].

Trait Implementations

impl AsRef<Float16Array> for Float16Array

fn as_ref(&self) -> &Float16Array

impl AsRef<JsValue> for Float16Array

fn as_ref(&self) -> &JsValue

impl AsRef<Object> for Float16Array

fn as_ref(&self) -> &Object

impl Clone for Float16Array

fn clone(&self) -> Self

impl Debug for Float16Array

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

impl Default for Float16Array

fn default() -> Self

impl Deref for Float16Array

type Target = Object;
fn deref(&self) -> &Object

impl ErasableGeneric for Float16Array

type Repr = JsValue;

impl From<JsValue> for Float16Array

fn from(obj: JsValue) -> Self

impl FromWasmAbi for Float16Array

type Abi = <JsValue as FromWasmAbi>::Abi;
unsafe fn from_abi(js: Self::Abi) -> Self

impl IntoJsGeneric for Float16Array where Float16Array: JsGeneric,

type JsCanon = Float16Array;
fn to_js(self) -> Float16Array

impl IntoWasmAbi for Float16Array

type Abi = <JsValue as IntoWasmAbi>::Abi;
fn into_abi(self) -> Self::Abi

impl JsCast for Float16Array

fn instanceof(val: &JsValue) -> bool
fn unchecked_from_js(val: JsValue) -> Self
fn unchecked_from_js_ref(val: &JsValue) -> &Self

impl LongRefFromWasmAbi for Float16Array

type Abi = <JsValue as LongRefFromWasmAbi>::Abi;
type Anchor = Float16Array;
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

impl OptionFromWasmAbi for Float16Array

fn is_none(abi: &Self::Abi) -> bool

impl OptionIntoWasmAbi for Float16Array

fn none() -> Self::Abi

impl Promising for Float16Array

type Resolution = Float16Array;

impl RefFromWasmAbi for Float16Array

type Abi = <JsValue as RefFromWasmAbi>::Abi;
type Anchor = ManuallyDrop<Float16Array>;
unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

impl TypedArray for Float16Array

impl UpcastFrom<Float16Array> for Float16Array

impl WasmDescribe for Float16Array

fn describe()

Auto Trait Implementations

impl Freeze for Float16Array

impl RefUnwindSafe for Float16Array

impl Send for Float16Array

impl Sync for Float16Array

impl Unpin for Float16Array

impl UnsafeUnpin for Float16Array

impl UnwindSafe for Float16Array

Blanket Implementations

impl<P, T> Receiver for Float16Array where P: Deref<Target = T> + ?Sized, T: ?Sized,

impl<S, T> Upcast<T> for Float16Array where T: UpcastFrom<S> + ?Sized, S: ?Sized,

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

impl<T> Borrow<T> for Float16Array where T: ?Sized,

impl<T> BorrowMut<T> for Float16Array where T: ?Sized,

impl<T> CloneToUninit for Float16Array where T: Clone,

impl<T> From<T> for Float16Array

impl<T> JsGeneric for Float16Array where T: ErasableGeneric<Repr = JsValue> + UpcastFrom<T> + Upcast<JsValue> + JsCast + 'static,

impl<T> ReturnWasmAbi for Float16Array where T: IntoWasmAbi,

impl<T> ToOwned for Float16Array where T: Clone,

impl<T> TryFromJsValue for Float16Array where T: JsCast,

impl<T> VectorFromWasmAbi for Float16Array where T: ErasableGeneric<Repr = JsValue> + WasmDescribe,

impl<T> VectorIntoWasmAbi for Float16Array where T: ErasableGeneric<Repr = JsValue> + WasmDescribe,

impl<T> VectorRefIntoWasmAbi for Float16Array where &'a T: for<'a> Into<JsValue>,

impl<T, U> Into<U> for Float16Array where U: From<T>,

impl<T, U> TryFrom<U> for Float16Array where U: Into<T>,

impl<T, U> TryInto<U> for Float16Array where U: TryFrom<T>,