Use wiggle "trappable error" to implement wasi-common (#5279)
* convert wasi-common from defining its own error to using wiggle trappable error * wasi-common impl crates: switch error strategy * wasmtime-wasi: error is trappable, and no longer requires UserErrorConversion * docs * typo * readdir: windows fixes * fix windows scheduler errors fun fact! the Send and Recv errors here that just had a `.context` on them were previously not being captured in the downcasting either. They need to be traps, and would have ended up that way by ommission, but you'd never actually know that by reading the code!
This commit is contained in:
@@ -6,7 +6,7 @@ use wasi_common::{
|
||||
subscription::{RwEventFlags, Subscription},
|
||||
Poll,
|
||||
},
|
||||
Context as _, Error,
|
||||
Error,
|
||||
};
|
||||
|
||||
struct FirstReady<'a, T>(Vec<Pin<Box<dyn Future<Output = T> + Send + 'a>>>);
|
||||
@@ -56,12 +56,15 @@ pub async fn poll_oneoff<'a>(poll: &mut Poll<'a>) -> Result<(), Error> {
|
||||
match s {
|
||||
Subscription::Read(f) => {
|
||||
futures.push(async move {
|
||||
f.file.readable().await.context("readable future")?;
|
||||
f.file
|
||||
.readable()
|
||||
.await
|
||||
.map_err(|e| e.context("readable future"))?;
|
||||
f.complete(
|
||||
f.file
|
||||
.num_ready_bytes()
|
||||
.await
|
||||
.context("read num_ready_bytes")?,
|
||||
.map_err(|e| e.context("read num_ready_bytes"))?,
|
||||
RwEventFlags::empty(),
|
||||
);
|
||||
Ok::<(), Error>(())
|
||||
@@ -70,7 +73,10 @@ pub async fn poll_oneoff<'a>(poll: &mut Poll<'a>) -> Result<(), Error> {
|
||||
|
||||
Subscription::Write(f) => {
|
||||
futures.push(async move {
|
||||
f.file.writable().await.context("writable future")?;
|
||||
f.file
|
||||
.writable()
|
||||
.await
|
||||
.map_err(|e| e.context("writable future"))?;
|
||||
f.complete(0, RwEventFlags::empty());
|
||||
Ok(())
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user