MCPcopy Create free account
hub / github.com/explodingcamera/tinywasm / read_16

Method read_16

crates/tinywasm/src/store/memory/mod.rs:171–179  ·  view source on GitHub ↗

Reads exactly 2 bytes at the effective address `base + offset`.

(&self, base: u64, offset: u64)

Source from the content-addressed store, hash-verified

169
170 /// Reads exactly 2 bytes at the effective address `base + offset`.
171 fn read_16(&self, base: u64, offset: u64) -> core::result::Result<[u8; 2], crate::Trap> {
172 let addr = checked_effective_addr::<2>(self.len(), base, offset)?;
173 let mut bytes = [0; 2];
174 self.read_exact(addr, &mut bytes).ok_or_else(|| {
175 cold_path();
176 memory_oob(addr, 2, self.len())
177 })?;
178 Ok(bytes)
179 }
180
181 /// Reads exactly 4 bytes at the effective address `base + offset`.
182 fn read_32(&self, base: u64, offset: u64) -> core::result::Result<[u8; 4], crate::Trap> {

Callers

nothing calls this directly

Implementers 3

vec.rscrates/tinywasm/src/store/memory/vec.r
paged.rscrates/tinywasm/src/store/memory/paged
lazy.rscrates/tinywasm/src/store/memory/lazy.

Calls 3

memory_oobFunction · 0.85
lenMethod · 0.45
read_exactMethod · 0.45

Tested by

no test coverage detected