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
@@ -70,22 +70,22 @@ impl WasiCtx {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_stdin(&mut self, f: Box<dyn WasiFile>) {
|
||||
let rights = Self::stdio_rights(&*f);
|
||||
pub fn set_stdin(&mut self, mut f: Box<dyn WasiFile>) {
|
||||
let rights = Self::stdio_rights(&mut *f);
|
||||
self.insert_file(0, f, rights);
|
||||
}
|
||||
|
||||
pub fn set_stdout(&mut self, f: Box<dyn WasiFile>) {
|
||||
let rights = Self::stdio_rights(&*f);
|
||||
pub fn set_stdout(&mut self, mut f: Box<dyn WasiFile>) {
|
||||
let rights = Self::stdio_rights(&mut *f);
|
||||
self.insert_file(1, f, rights);
|
||||
}
|
||||
|
||||
pub fn set_stderr(&mut self, f: Box<dyn WasiFile>) {
|
||||
let rights = Self::stdio_rights(&*f);
|
||||
pub fn set_stderr(&mut self, mut f: Box<dyn WasiFile>) {
|
||||
let rights = Self::stdio_rights(&mut *f);
|
||||
self.insert_file(2, f, rights);
|
||||
}
|
||||
|
||||
fn stdio_rights(f: &dyn WasiFile) -> FileCaps {
|
||||
fn stdio_rights(f: &mut dyn WasiFile) -> FileCaps {
|
||||
let mut rights = FileCaps::all();
|
||||
|
||||
// If `f` is a tty, restrict the `tell` and `seek` capabilities, so
|
||||
|
||||
Reference in New Issue
Block a user