Function shadow_rs::host::syscall::io::write_partial

source ยท
pub fn write_partial<T: Pod>(
    mem: &mut MemoryManager,
    val: &T,
    val_ptr: ForeignPtr<T>,
    val_len_bytes: usize,
) -> Result<usize, Errno>
Expand description

Writes val to val_ptr, but will only write a partial value if val_len_bytes is smaller than the size of val. Returns the number of bytes written.

let ptr: ForeignPtr<u32> = todo!();
let val: u32 = 0xAABBCCDD;
// write a single byte of `val` (0xDD on little-endian) to `ptr`
let bytes_written = write_partial(memory_manager, &val, ptr, 1)?;
assert_eq!(bytes_written, 1);