pub struct HostShimBuffer { /* private fields */ }Expand description
Implementor of DeviceBuffer for compatibility tests and explicit
host-resident fixtures - stores raw bytes on the host, identifies as
the requesting backend.
This is not a production substitute for real device allocation. Real
device backends override crate::backend::VyreBackend::allocate_device_buffer
to return their own concrete buffer type wrapped in Box<dyn DeviceBuffer>.
Implementations§
Source§impl HostShimBuffer
impl HostShimBuffer
Sourcepub fn allocate(
backend_id: &'static str,
byte_len: usize,
) -> Box<dyn DeviceBuffer>
pub fn allocate( backend_id: &'static str, byte_len: usize, ) -> Box<dyn DeviceBuffer>
Allocate a zero-filled host-resident buffer. The bytes live in process memory; backends that use this still pay the upload cost on every dispatch but the consumer-side API is the same as for true device buffers.
Sourcepub fn from_bytes(
backend_id: &'static str,
bytes: Vec<u8>,
) -> Box<dyn DeviceBuffer>
pub fn from_bytes( backend_id: &'static str, bytes: Vec<u8>, ) -> Box<dyn DeviceBuffer>
Allocate from existing bytes. The buffer takes ownership.
Sourcepub fn as_slice(&self) -> &[u8] ⓘ
pub fn as_slice(&self) -> &[u8] ⓘ
Borrow the underlying bytes. Only HostShimBuffer exposes this -
real device buffers cannot be byte-borrowed without a download.
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Mutably borrow the underlying bytes. Only valid on host-shim buffers; real device buffers panic.
Trait Implementations§
Source§impl Debug for HostShimBuffer
impl Debug for HostShimBuffer
Source§impl DeviceBuffer for HostShimBuffer
impl DeviceBuffer for HostShimBuffer
Source§fn backend_id(&self) -> &'static str
fn backend_id(&self) -> &'static str
crate::backend::VyreBackend::id of the allocating backend.Source§fn byte_len(&self) -> usize
fn byte_len(&self) -> usize
BufferDecl::count * element_size.Source§fn debug_label(&self) -> Option<&str>
fn debug_label(&self) -> Option<&str>
None when no label was set.Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
&dyn Any so callers can downcast without naming the
concrete buffer type. Implementors return self.Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Self::as_any. Implementors return self.