MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / write_bytes

Function write_bytes

crates/wasi/src/p1.rs:1162–1174  ·  view source on GitHub ↗
(
    memory: &mut GuestMemory<'_>,
    ptr: GuestPtr<u8>,
    buf: &[u8],
)

Source from the content-addressed store, hash-verified

1160type Result<T, E = types::Error> = std::result::Result<T, E>;
1161
1162fn write_bytes(
1163 memory: &mut GuestMemory<'_>,
1164 ptr: GuestPtr<u8>,
1165 buf: &[u8],
1166) -> Result<GuestPtr<u8>, types::Error> {
1167 // NOTE: legacy implementation always returns Inval errno
1168
1169 let len = u32::try_from(buf.len())?;
1170
1171 memory.copy_from_slice(buf, ptr.as_array(len))?;
1172 let next = ptr.add(len)?;
1173 Ok(next)
1174}
1175
1176fn write_byte(memory: &mut GuestMemory<'_>, ptr: GuestPtr<u8>, byte: u8) -> Result<GuestPtr<u8>> {
1177 memory.write(ptr, byte)?;

Callers 15

new_zeroedMethod · 0.85
memory_zeroedFunction · 0.85
args_getMethod · 0.85
environ_getMethod · 0.85
fd_prestat_dir_nameMethod · 0.85
fd_readdirMethod · 0.85
path_readlinkMethod · 0.85
random_getMethod · 0.85
make_accessibleMethod · 0.85
expose_existing_mappingFunction · 0.85
hide_existing_mappingFunction · 0.85
erase_existing_mappingFunction · 0.85

Calls 5

OkFunction · 0.85
lenMethod · 0.45
copy_from_sliceMethod · 0.45
as_arrayMethod · 0.45
addMethod · 0.45

Tested by 1

memory_zeroedFunction · 0.68