pub struct HostArgs {
pub function_id: u16,
/* private fields */
}Fields§
§function_id: u16Implementations§
Source§impl HostArgs
impl HostArgs
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
pub fn print_bytes(label: &str, bytes: &[u8])
pub unsafe fn ptr_to_slice<'a>(ptr: *const u8, len: usize) -> &'a [u8] ⓘ
pub unsafe fn ptr_to_slice_mut<'a>(ptr: *mut u8, len: usize) -> &'a mut [u8] ⓘ
Sourcepub fn get<T>(&self, register_id: u8) -> &T
pub fn get<T>(&self, register_id: u8) -> &T
Get a safe reference to T from a register with bounds and alignment checks
Sourcepub unsafe fn get_unchecked<T>(&mut self, register_id: u8) -> &T
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)
Sourcepub fn get_mut<T>(&mut self, register_id: u8) -> &mut T
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
Sourcepub unsafe fn get_mut_unchecked<T>(&mut self, register_id: u8) -> &mut T
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)
Sourcepub fn register_i32(&self, register_id: u8) -> i32
pub fn register_i32(&self, register_id: u8) -> i32
Get the register value as i32
Sourcepub fn set_register(&mut self, register_id: u8, data: u32)
pub fn set_register(&mut self, register_id: u8, data: u32)
Set a register to a u32 value
Sourcepub fn write<T>(&mut self, register_id: u8, data: &T)
pub fn write<T>(&mut self, register_id: u8, data: &T)
Write data to the memory location pointed to by a register
pub fn any(&self, register_id: u8) -> AnyValue
pub fn any_mut(&self, register_id: u8) -> AnyValueMut
Sourcepub fn write_to_vector_bulk<T>(&mut self, vec_register: u8, data_slice: &[T])where
T: Copy,
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 r0data_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
Sourcepub fn write_to_vector_at_index<T>(
&mut self,
vec_register: u8,
index: u16,
data: &T,
)where
T: Copy,
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 r0index- 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
Sourcepub fn push_to_vector<T>(&mut self, vec_register: u8, data: &T)where
T: Copy,
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 r0data- 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
Sourcepub fn read_from_vector_at_index<T>(&self, vec_register: u8, index: u16) -> &Twhere
T: Copy,
pub fn read_from_vector_at_index<T>(&self, vec_register: u8, index: u16) -> &Twhere
T: Copy,
Read an element from a vector at a specific index
§Arguments
vec_register- Register containing the vector header address, usually r0index- 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
Sourcepub fn vector_len(&self, vec_register: u8) -> u16
pub fn vector_len(&self, vec_register: u8) -> u16
Sourcepub fn vector_capacity(&self, vec_register: u8) -> u16
pub fn vector_capacity(&self, vec_register: u8) -> u16
Sourcepub fn vector_is_empty(&self, vec_register: u8) -> bool
pub fn vector_is_empty(&self, vec_register: u8) -> bool
Auto Trait Implementations§
impl Freeze for HostArgs
impl RefUnwindSafe for HostArgs
impl !Send for HostArgs
impl !Sync for HostArgs
impl Unpin for HostArgs
impl UnwindSafe for HostArgs
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
Mutably borrows from an owned value. Read more