rewrite wasi-tokio as just an task::block_in_place wrapper on cap-std-sync

This commit is contained in:
Pat Hickey
2021-05-04 11:29:02 -07:00
parent 686d8c22f9
commit f76fe8b764
13 changed files with 319 additions and 870 deletions

View File

@@ -7,7 +7,7 @@ use std::ops::Deref;
use std::path::PathBuf;
#[wiggle::async_trait]
pub trait WasiDir {
pub trait WasiDir: Send + Sync {
fn as_any(&self) -> &dyn Any;
async fn open_file(
&self,
@@ -24,7 +24,7 @@ pub trait WasiDir {
async fn readdir(
&self,
cursor: ReaddirCursor,
) -> Result<Box<dyn Iterator<Item = Result<ReaddirEntity, Error>>>, Error>;
) -> Result<Box<dyn Iterator<Item = Result<ReaddirEntity, Error>> + Send>, Error>;
async fn symlink(&self, old_path: &str, new_path: &str) -> Result<(), Error>;
async fn remove_dir(&self, path: &str) -> Result<(), Error>;
async fn unlink_file(&self, path: &str) -> Result<(), Error>;

View File

@@ -5,7 +5,7 @@ use std::cell::{Ref, RefMut};
use std::ops::{Deref, DerefMut};
#[wiggle::async_trait]
pub trait WasiFile {
pub trait WasiFile: Send {
fn as_any(&self) -> &dyn Any;
async fn datasync(&self) -> Result<(), Error>; // write op
async fn sync(&self) -> Result<(), Error>; // file op

View File

@@ -106,7 +106,7 @@ impl From<&str> for ReadPipe<io::Cursor<String>> {
}
#[wiggle::async_trait]
impl<R: Read + Any> WasiFile for ReadPipe<R> {
impl<R: Read + Any + Send + Sync> WasiFile for ReadPipe<R> {
fn as_any(&self) -> &dyn Any {
self
}
@@ -265,7 +265,7 @@ impl WritePipe<io::Cursor<Vec<u8>>> {
}
#[wiggle::async_trait]
impl<W: Write + Any> WasiFile for WritePipe<W> {
impl<W: Write + Any + Send + Sync> WasiFile for WritePipe<W> {
fn as_any(&self) -> &dyn Any {
self
}