This is an automated email from the ASF dual-hosted git repository. xuanwo pushed a commit to branch file-tokio-support-wasm in repository https://gitbox.apache.org/repos/asf/opendal-reqsign.git
commit 2bdbbfc4cdc0c43831b7b2ba0db59a69f5a62635 Author: Xuanwo <[email protected]> AuthorDate: Mon Oct 13 14:43:33 2025 +0800 feat(context-file-read-tokio): Allow file read token been built on wasm Signed-off-by: Xuanwo <[email protected]> --- context/file-read-tokio/Cargo.toml | 2 ++ context/file-read-tokio/src/lib.rs | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/context/file-read-tokio/Cargo.toml b/context/file-read-tokio/Cargo.toml index b8599c4..8248096 100644 --- a/context/file-read-tokio/Cargo.toml +++ b/context/file-read-tokio/Cargo.toml @@ -32,6 +32,8 @@ rust-version.workspace = true anyhow = { workspace = true } async-trait = { workspace = true } reqsign-core = { workspace = true } + +[target.'cfg(not(target_family = "wasm"))'.dependencies] tokio = { version = "1", features = ["fs"] } [dev-dependencies] diff --git a/context/file-read-tokio/src/lib.rs b/context/file-read-tokio/src/lib.rs index 05a155d..565c1c1 100644 --- a/context/file-read-tokio/src/lib.rs +++ b/context/file-read-tokio/src/lib.rs @@ -74,6 +74,7 @@ use reqsign_core::{Error, FileRead, Result}; #[derive(Debug, Clone, Copy, Default)] pub struct TokioFileRead; +#[cfg(not(target_family = "wasm"))] #[async_trait] impl FileRead for TokioFileRead { async fn file_read(&self, path: &str) -> Result<Vec<u8>> { @@ -82,3 +83,13 @@ impl FileRead for TokioFileRead { .map_err(|e| Error::unexpected("failed to read file").with_source(e)) } } + +#[cfg(target_family = "wasm")] +#[async_trait] +impl FileRead for TokioFileRead { + async fn file_read(&self, _path: &str) -> Result<Vec<u8>> { + Err(Error::unexpected( + "TokioFileRead is unsupported on wasm targets", + )) + } +}
