MCPcopy Index your code
hub / github.com/explodingcamera/tinywasm / write

Method write

crates/tinywasm/src/store/memory/paged.rs:174–188  ·  view source on GitHub ↗
(&mut self, addr: usize, src: &[u8])

Source from the content-addressed store, hash-verified

172
173 #[inline(always)]
174 fn write(&mut self, addr: usize, src: &[u8]) -> usize {
175 if addr >= self.len || src.is_empty() {
176 return 0;
177 }
178
179 let chunk_idx = addr >> self.chunk_shift;
180 let chunk_offset = addr & self.chunk_mask;
181 let write_len = min(min(self.chunk_size - chunk_offset, self.len - addr), src.len());
182
183 let Ok(chunk) = self.chunk_mut(chunk_idx) else {
184 return 0;
185 };
186 chunk[chunk_offset..chunk_offset + write_len].copy_from_slice(&src[..write_len]);
187 write_len
188 }
189
190 #[inline(always)]
191 fn write_all(&mut self, addr: usize, src: &[u8]) -> Option<()> {

Callers

nothing calls this directly

Calls 4

chunk_mutMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45
copy_from_sliceMethod · 0.45

Tested by

no test coverage detected