Struct HostArgs

Source
pub struct HostArgs {
    pub function_id: u16,
    /* private fields */
}

Fields§

§function_id: u16

Implementations§

Source§

impl HostArgs

Source

pub unsafe fn new( function_id: u16, all_memory: *mut u8, all_memory_len: usize, stack_offset: usize, registers: *mut u32, register_count: usize, ) -> Self

Source

pub fn ptr(&mut self, register: u8) -> *mut u8

Get a raw pointer from a register value

Source

pub fn print_bytes(label: &str, bytes: &[u8])

Source

pub unsafe fn ptr_to_slice<'a>(ptr: *const u8, len: usize) -> &'a [u8]

Source

pub unsafe fn ptr_to_slice_mut<'a>(ptr: *mut u8, len: usize) -> &'a mut [u8]

Source

pub fn ptr_as<T>(&mut self, register_id: u8) -> *const T

Get a typed pointer from a register

Source

pub fn get<T>(&self, register_id: u8) -> &T

Get a safe reference to T from a register with bounds and alignment checks

Source

pub unsafe fn get_unchecked<T>(&mut self, register_id: u8) -> &T

Get a reference to T from a register without safety checks (for performance)

Source

pub fn get_mut<T>(&mut self, register_id: u8) -> &mut T

Get a mutable reference to T from a register with bounds and alignment checks

Source

pub unsafe fn get_mut_unchecked<T>(&mut self, register_id: u8) -> &mut T

Get a mutable reference to T from a register without safety checks (for performance)

Source

pub fn register(&self, register_id: u8) -> u32

Get the raw register value as u32

Source

pub fn register_i32(&self, register_id: u8) -> i32

Get the register value as i32

Source

pub fn set_register(&mut self, register_id: u8, data: u32)

Set a register to a u32 value

Source

pub fn write<T>(&mut self, register_id: u8, data: &T)

Write data to the memory location pointed to by a register

Source

pub fn string(&self, register_id: u8) -> &str

Get a string from a register

Source

pub fn any(&self, register_id: u8) -> AnyValue

Source

pub fn any_mut(&self, register_id: u8) -> AnyValueMut

Source

pub fn write_to_vector_bulk<T>(&mut self, vec_register: u8, data_slice: &[T])
where T: Copy,

Write multiple elements to the end of a vector (bulk append)

§Arguments
  • vec_register - Register containing the vector header address, usually r0
  • data_slice - Slice of data to append to the vector
§Panics
  • If the vector header is invalid or corrupted
  • If there’s insufficient capacity for all elements
  • If the element size doesn’t match the vector’s element size
Source

pub fn write_to_vector_at_index<T>( &mut self, vec_register: u8, index: u16, data: &T, )
where T: Copy,

Write a single element to a specific index in a vector

§Arguments
  • vec_register - Register containing the vector header address, usually r0
  • index - Index where to write the element (must be < element_count)
  • data - Data to write at the specified index
§Panics
  • If the vector header is invalid or corrupted
  • If the index is out of bounds
  • If the element size doesn’t match the vector’s element size
Source

pub fn push_to_vector<T>(&mut self, vec_register: u8, data: &T)
where T: Copy,

Append a single element to the end of a vector

§Arguments
  • vec_register - Register containing the vector header address, usually r0
  • data - Data to append to the vector
§Panics
  • If the vector header is invalid or corrupted
  • If there’s insufficient capacity for the new element
  • If the element size doesn’t match the vector’s element size
Source

pub fn read_from_vector_at_index<T>(&self, vec_register: u8, index: u16) -> &T
where T: Copy,

Read an element from a vector at a specific index

§Arguments
  • vec_register - Register containing the vector header address, usually r0
  • index - Index of the element to read
§Returns

A reference to the element at the specified index

§Panics
  • If the vector header is invalid or corrupted
  • If the index is out of bounds
  • If the element size doesn’t match the requested type size
Source

pub fn vector_len(&self, vec_register: u8) -> u16

Get the current length (element count) of a vector

§Arguments
  • vec_register - Register containing the vector header address
§Returns

The number of elements currently in the vector

§Panics
  • If the vector header is invalid or corrupted
Source

pub fn vector_capacity(&self, vec_register: u8) -> u16

Get the capacity of a vector

§Arguments
  • vec_register - Register containing the vector header address
§Returns

The maximum number of elements the vector can hold

§Panics
  • If the vector header is invalid or corrupted
Source

pub fn vector_is_empty(&self, vec_register: u8) -> bool

Check if a vector is empty

§Arguments
  • vec_register - Register containing the vector header address
§Returns

True if the vector has no elements, false otherwise

Source

pub fn vector_is_full(&self, vec_register: u8) -> bool

Check if a vector is full (at capacity)

§Arguments
  • vec_register - Register containing the vector header address
§Returns

True if the vector is at capacity, false otherwise

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 = 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.