Skip to main content

HostShimBuffer

Struct HostShimBuffer 

Source
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

Source

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.

Source

pub fn from_bytes( backend_id: &'static str, bytes: Vec<u8>, ) -> Box<dyn DeviceBuffer>

Allocate from existing bytes. The buffer takes ownership.

Source

pub fn as_slice(&self) -> &[u8]

Borrow the underlying bytes. Only HostShimBuffer exposes this - real device buffers cannot be byte-borrowed without a download.

Source

pub fn as_mut_slice(&mut self) -> &mut [u8]

Mutably borrow the underlying bytes. Only valid on host-shim buffers; real device buffers panic.

Source

pub fn set_label(&mut self, label: impl Into<String>)

Attach a debug label after allocation.

Trait Implementations§

Source§

impl Debug for HostShimBuffer

Source§

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

Formats the value using the given formatter. Read more
Source§

impl DeviceBuffer for HostShimBuffer

Source§

fn backend_id(&self) -> &'static str

Stable backend identifier the buffer belongs to. Matches crate::backend::VyreBackend::id of the allocating backend.
Source§

fn byte_len(&self) -> usize

Size of the allocation in bytes. The kernel sees this as the declared BufferDecl::count * element_size.
Source§

fn debug_label(&self) -> Option<&str>

Optional human-readable label (debug surface only). Backends may return None when no label was set.
Source§

fn as_any(&self) -> &dyn Any

Erase to &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

Mutable variant of Self::as_any. Implementors return self.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more