feat(wasi)!: make most WasiFile methods take &mut self (#3901)
1. This makes it easier for implementors to deal with internal APIs. 2. This matches the signatures of the WASI Snapshot traits. Although it is likely true that these methods would have to become immutable in order to implement threading efficiently, threading will impact a large number of existing traits. So this change is practical for now with an already-unavoidable change required for threading. Signed-off-by: Nathaniel McCallum <nathaniel@profian.com>
This commit is contained in:
committed by
GitHub
parent
44a435a43a
commit
8b48ce7fb7
@@ -105,10 +105,10 @@ impl<R: Read + Any + Send + Sync> WasiFile for ReadPipe<R> {
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
async fn get_filetype(&self) -> Result<FileType, Error> {
|
||||
async fn get_filetype(&mut self) -> Result<FileType, Error> {
|
||||
Ok(FileType::Pipe)
|
||||
}
|
||||
async fn read_vectored<'a>(&self, bufs: &mut [io::IoSliceMut<'a>]) -> Result<u64, Error> {
|
||||
async fn read_vectored<'a>(&mut self, bufs: &mut [io::IoSliceMut<'a>]) -> Result<u64, Error> {
|
||||
let n = self.borrow().read_vectored(bufs)?;
|
||||
Ok(n.try_into()?)
|
||||
}
|
||||
@@ -189,13 +189,13 @@ impl<W: Write + Any + Send + Sync> WasiFile for WritePipe<W> {
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
async fn get_filetype(&self) -> Result<FileType, Error> {
|
||||
async fn get_filetype(&mut self) -> Result<FileType, Error> {
|
||||
Ok(FileType::Pipe)
|
||||
}
|
||||
async fn get_fdflags(&self) -> Result<FdFlags, Error> {
|
||||
async fn get_fdflags(&mut self) -> Result<FdFlags, Error> {
|
||||
Ok(FdFlags::APPEND)
|
||||
}
|
||||
async fn write_vectored<'a>(&self, bufs: &[io::IoSlice<'a>]) -> Result<u64, Error> {
|
||||
async fn write_vectored<'a>(&mut self, bufs: &[io::IoSlice<'a>]) -> Result<u64, Error> {
|
||||
let n = self.borrow().write_vectored(bufs)?;
|
||||
Ok(n.try_into()?)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user