Struct spacetimedb_bindings_sys::raw::Buffer
source · pub struct Buffer { /* private fields */ }
Expand description
A handle into a buffer of bytes in the host environment.
Used for transporting bytes host <-> WASM linear memory.
Implementations§
source§impl Buffer
impl Buffer
sourcepub const fn handle(&self) -> ManuallyDrop<Self>
pub const fn handle(&self) -> ManuallyDrop<Self>
Returns a “handle” that can be passed across the FFI boundary as if it was the Buffer itself, but without consuming it.
sourcepub const INVALID: Self = _
pub const INVALID: Self = _
An invalid buffer handle.
Could happen if too many buffers exist, making the key overflow a u32
.
INVALID
is also used for parts of the protocol
that are “morally” sending a None
s in Option<Box<[u8]>>
s.
sourcepub const fn is_invalid(&self) -> bool
pub const fn is_invalid(&self) -> bool
Is the buffer handle invalid?
source§impl Buffer
impl Buffer
sourcepub fn read_into(self, buf: &mut Vec<u8>)
pub fn read_into(self, buf: &mut Vec<u8>)
Read the contents of the buffer into the provided Vec. The Vec is cleared in the process.
sourcepub fn read_array<const N: usize>(self) -> [u8; N]
pub fn read_array<const N: usize>(self) -> [u8; N]
Read the contents of the buffer into an array of fixed size N
.
If the length is wrong, the module will crash.
sourcepub fn read_uninit(self, buf: &mut [MaybeUninit<u8>])
pub fn read_uninit(self, buf: &mut [MaybeUninit<u8>])
Reads the buffer into an uninitialized byte string buf
.
The module will crash if buf
’s length doesn’t match the buffer.
Auto Trait Implementations§
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnwindSafe for Buffer
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more