Skip to main content

Buffer

Struct Buffer 

Source
pub struct Buffer {
    pub store: Store,
    pub detached: bool,
    pub max: Option<usize>,
}
Expand description

An ArrayBuffer or SharedArrayBuffer record.

Fields§

§store: Store§detached: bool§max: Option<usize>

maxByteLength of a resizable or growable buffer.

Implementations§

Source§

impl Buffer

Source

pub fn owned(len: usize, max: Option<usize>) -> Buffer

Source

pub fn shared(len: usize, max: Option<usize>) -> Buffer

Source

pub fn is_shared(&self) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn owned_bytes(&self) -> usize

Source

pub fn read(&self, offset: usize, out: &mut [u8])

Copies out.len() bytes from offset.

Source

pub fn write(&mut self, offset: usize, data: &[u8])

Writes data at offset.

Source

pub fn copy_within(&mut self, from: usize, to: usize, len: usize)

Copies len bytes within the buffer (memmove).

Source

pub fn owned_slice(&self) -> Option<&[u8]>

The owned bytes, for bulk work (None for a shared buffer).

Source

pub fn owned_slice_mut(&mut self) -> Option<&mut Vec<u8>>

Source

pub fn to_vec(&self, offset: usize, len: usize) -> Vec<u8> ⓘ

The bytes as a copy, for any store.

Trait Implementations§

Source§

impl Debug for Buffer

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.