MCPcopy Create free account
hub / github.com/bytecodealliance/system-interface / write_all_at

Method write_all_at

src/fs/file_io_ext.rs:196–208  ·  view source on GitHub ↗

Attempts to write an entire buffer starting from a given offset. This is similar to [`std::os::unix::fs::FileExt::write_all_at`], except it takes `self` by immutable reference since the entire side effect is I/O, and it's supported on non-Unix platforms including Windows. A write past the end of the file extends the file with zero bytes until the point where the write starts. Contrary to POSIX,

(&self, mut buf: &[u8], mut offset: u64)

Source from the content-addressed store, hash-verified

194 ///
195 /// [`std::os::unix::fs::FileExt::write_all_at`]: https://doc.rust-lang.org/std/os/unix/fs/trait.FileExt.html#tymethod.write_all_at
196 fn write_all_at(&self, mut buf: &[u8], mut offset: u64) -> io::Result<()> {
197 while !buf.is_empty() {
198 match self.write_at(buf, offset) {
199 Ok(nwritten) => {
200 buf = &buf[nwritten..];
201 offset += nwritten as u64;
202 }
203 Err(ref e) if e.kind() == io::ErrorKind::Interrupted => (),
204 Err(e) => return Err(e),
205 }
206 }
207 Ok(())
208 }
209
210 /// Is to `write_vectored` what `write_at` is to `write`.
211 fn write_vectored_at(&self, bufs: &[IoSlice], offset: u64) -> io::Result<usize> {

Callers

nothing calls this directly

Implementers 1

file_io_ext.rssrc/fs/file_io_ext.rs

Calls 1

write_atMethod · 0.80

Tested by

no test coverage detected