add readable and writable futures to WasiFile trait

This commit is contained in:
Pat Hickey
2021-04-26 14:43:16 -07:00
parent fa44ec2da2
commit b307dce2ab
5 changed files with 39 additions and 0 deletions

View File

@@ -36,6 +36,9 @@ pub trait WasiFile {
async fn seek(&self, pos: std::io::SeekFrom) -> Result<u64, Error>; // file op that generates a new stream from a file will supercede this
async fn peek(&self, buf: &mut [u8]) -> Result<u64, Error>; // read op
async fn num_ready_bytes(&self) -> Result<u64, Error>; // read op
async fn readable(&mut self) -> Result<(), Error>;
async fn writable(&mut self) -> Result<(), Error>;
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]

View File

@@ -183,6 +183,12 @@ impl<R: Read + Any> WasiFile for ReadPipe<R> {
async fn num_ready_bytes(&self) -> Result<u64, Error> {
Ok(0)
}
async fn readable(&mut self) -> Result<(), Error> {
Err(Error::badf())
}
async fn writable(&mut self) -> Result<(), Error> {
Err(Error::badf())
}
}
/// A virtual pipe write end.
@@ -336,4 +342,10 @@ impl<W: Write + Any> WasiFile for WritePipe<W> {
async fn num_ready_bytes(&self) -> Result<u64, Error> {
Ok(0)
}
async fn readable(&mut self) -> Result<(), Error> {
Err(Error::badf())
}
async fn writable(&mut self) -> Result<(), Error> {
Err(Error::badf())
}
}