gossamer/array_buffer
Types
A generic raw binary data buffer.
See ArrayBuffer on MDN.
pub type ArrayBuffer
Values
pub fn byte_length(of array_buffer: ArrayBuffer) -> Int
pub fn is_detached(array_buffer: ArrayBuffer) -> Bool
pub fn is_resizable(array_buffer: ArrayBuffer) -> Bool
pub fn max_byte_length(of array_buffer: ArrayBuffer) -> Int
pub fn new(
byte_length: Int,
) -> Result(ArrayBuffer, js_error.JsError)
Creates a fixed-size ArrayBuffer of byte_length bytes. Returns an
error if byte_length is negative or exceeds the maximum allocatable
size.
pub fn new_resizable(
byte_length: Int,
max_byte_length max: Int,
) -> Result(ArrayBuffer, js_error.JsError)
Creates a resizable ArrayBuffer with the given initial byte length
and maximum byte length. Returns an error if either is negative or
max exceeds the maximum allocatable size.
pub fn resize(
array_buffer: ArrayBuffer,
to byte_length: Int,
) -> Result(Nil, js_error.JsError)
Resizes the ArrayBuffer to the specified byte length. The buffer must
have been created with new_resizable. Returns an error if the new length
exceeds the maximum byte length.
pub fn slice(array_buffer: ArrayBuffer) -> ArrayBuffer
pub fn slice_from(
array_buffer: ArrayBuffer,
start: Int,
) -> ArrayBuffer
pub fn slice_range(
array_buffer: ArrayBuffer,
from start: Int,
to end: Int,
) -> ArrayBuffer
pub fn transfer(
array_buffer: ArrayBuffer,
) -> Result(ArrayBuffer, js_error.JsError)
Transfers the buffer’s contents to a new ArrayBuffer, detaching the
original. Returns an error if the buffer is already detached.