pub trait ArrayView: Sized {
type JS: Deref<Target = Object>;
const GL_TYPE: u32;
// Required method
unsafe fn view(rust: &[Self]) -> Self::JS;
}Expand description
Idiomatic transformation of Rust arrays to JS.
This trait gives an idiomatic way to transform Rust arrays into a JS typed
array (such as Float32Array) specifically for the use case of filling
WebGL2 buffers and textures.
For this, each Rust numeric type is associated with a JS typed array type
and with a constant that gives the corresponding WebGL2 data type (such as
WebGL2RenderingContext::FLOAT).
Required Associated Constants§
Required Associated Types§
Required Methods§
Sourceunsafe fn view(rust: &[Self]) -> Self::JS
unsafe fn view(rust: &[Self]) -> Self::JS
Creates a JS typed array which is a view into wasm’s linear memory at the slice specified.
This function uses the view method (such as Float32Array::view) of
the JS typed array.
§Safety
The same safety considerations as with Float32Array::view apply.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.