Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

cargo update #26

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions host/src/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use crate::{wasi_filesystem, HostResult, WasiCtx};
use std::io::{IoSlice, IoSliceMut};
use wasi_common::file::TableFileExt;

fn convert(error: wasi_common::Error) -> wasmtime::component::Error<wasi_filesystem::Errno> {
fn convert(error: wasi_common::Error) -> anyhow::Error {
if let Some(errno) = error.downcast_ref() {
use wasi_common::Errno::*;
use wasi_filesystem::Errno;

wasmtime::component::Error::new(match errno {
match errno {
Acces => Errno::Access,
Addrinuse => Errno::Addrinuse,
Addrnotavail => Errno::Addrnotavail,
Expand Down Expand Up @@ -80,11 +80,12 @@ fn convert(error: wasi_common::Error) -> wasmtime::component::Error<wasi_filesys
Xdev => Errno::Xdev,
Success | Dom | Notcapable | Notsock | Proto | Protonosupport | Prototype | TooBig
| Notconn => {
return error.into().into();
return error.into();
}
})
}
.into()
} else {
error.into().into()
error.into()
}
}

Expand Down Expand Up @@ -163,7 +164,7 @@ impl wasi_filesystem::WasiFilesystem for WasiCtx {

buffer.truncate(bytes_read.try_into().unwrap());

Ok(buffer)
Ok(Ok(buffer))
}

async fn pwrite(
Expand All @@ -179,7 +180,7 @@ impl wasi_filesystem::WasiFilesystem for WasiCtx {
.await
.map_err(convert)?;

Ok(wasi_filesystem::Size::try_from(bytes_written).unwrap())
Ok(Ok(wasi_filesystem::Size::try_from(bytes_written).unwrap()))
}

async fn readdir(
Expand Down
2 changes: 1 addition & 1 deletion host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod random;
mod tcp;
pub use wasi_common::{table::Table, WasiCtx};

type HostResult<T, E> = Result<T, wasmtime::component::Error<E>>;
type HostResult<T, E> = anyhow::Result<Result<T, E>>;

wasmtime::component::bindgen!({
path: "../wit/wasi.wit",
Expand Down