Skip to content

Commit 189cc0b

Browse files
authored
Migrate wasi-tls to wasmtime::error (#12274)
1 parent 8646e3b commit 189cc0b

File tree

6 files changed

+7
-9
lines changed

6 files changed

+7
-9
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/wasi-tls/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ description = "Wasmtime implementation of the wasi-tls API"
1212
workspace = true
1313

1414
[dependencies]
15-
anyhow = { workspace = true }
1615
bytes = { workspace = true }
1716
tokio = { workspace = true, features = [
1817
"net",

crates/wasi-tls/src/host.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::Result;
1+
use wasmtime::Result;
22
use wasmtime::component::Resource;
33
use wasmtime_wasi::async_trait;
44
use wasmtime_wasi::p2::Pollable;

crates/wasi-tls/src/io.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
//! Utility types for converting Rust & Tokio I/O types into WASI I/O types,
22
//! and vice versa.
33
4-
use anyhow::Result;
54
use bytes::Bytes;
65
use std::io;
76
use std::sync::Arc;
87
use std::task::{Poll, ready};
98
use std::{future::Future, mem, pin::Pin};
109
use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt};
1110
use tokio::sync::Mutex;
11+
use wasmtime::Result;
1212
use wasmtime_wasi::async_trait;
1313
use wasmtime_wasi::p2::{
1414
DynInputStream, DynOutputStream, OutputStream, Pollable, StreamError, StreamResult,
@@ -281,7 +281,7 @@ where
281281

282282
fn write(&mut self, mut bytes: bytes::Bytes) -> StreamResult<()> {
283283
let WriteState::Ready(_) = self else {
284-
return Err(StreamError::Trap(anyhow::anyhow!(
284+
return Err(StreamError::Trap(wasmtime::format_err!(
285285
"unpermitted: must call check_write first"
286286
)));
287287
};

crates/wasi-tls/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub fn add_to_linker<T: Send + 'static>(
100100
l: &mut wasmtime::component::Linker<T>,
101101
opts: &mut LinkOptions,
102102
f: fn(&mut T) -> WasiTls<'_>,
103-
) -> anyhow::Result<()> {
103+
) -> wasmtime::Result<()> {
104104
bindings::types::add_to_linker::<_, HasWasiTls>(l, &opts, f)?;
105105
Ok(())
106106
}

crates/wasi-tls/tests/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use anyhow::{Result, anyhow};
21
use wasmtime::{
3-
Store,
2+
Result, Store,
43
component::{Component, Linker, ResourceTable},
4+
format_err,
55
};
66
use wasmtime_wasi::{WasiCtx, WasiCtxView, WasiView, p2::bindings::Command};
77
use wasmtime_wasi_tls::{LinkOptions, WasiTls, WasiTlsCtx, WasiTlsCtxBuilder};
@@ -52,7 +52,7 @@ async fn run_test(path: &str) -> Result<()> {
5252
.wasi_cli_run()
5353
.call_run(&mut store)
5454
.await?
55-
.map_err(|()| anyhow!("command returned with failing exit status"))
55+
.map_err(|()| format_err!("command returned with failing exit status"))
5656
}
5757

5858
macro_rules! assert_test_exists {

0 commit comments

Comments
 (0)