Skip to content

Commit

Permalink
fix(integrations/object_store) object_store_opendal now compiles on…
Browse files Browse the repository at this point in the history
… wasm32-unknown-unknown (#5530)
  • Loading branch information
XiangpengHao authored Jan 10, 2025
1 parent fc686ed commit 0996e13
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion integrations/object_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ flagset = "0.4"
futures = "0.3"
futures-util = "0.3"
object_store = "0.11"
opendal = { version = "0.51.0", path = "../../core" }
opendal = { version = "0.51.0", path = "../../core", default-features = false }
pin-project = "1.1"
send_wrapper = { version = "0.6", features = ["futures"], optional = true }
tokio = { version = "1", default-features = false }
Expand Down
8 changes: 8 additions & 0 deletions integrations/object_store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ async fn main() {
}
```

## WASM support

To build with `wasm32-unknown-unknown` target, you need to enable the `send_wrapper` feature:

```sh
cargo build --target wasm32-unknown-unknown --features send_wrapper
```

## Branding

The first and most prominent mentions must use the full form: **Apache OpenDAL™** of the name for any individual usage (webpage, handout, slides, etc.) Depending on the context and writing style, you should use the full form of the name sufficiently often to ensure that readers clearly understand the association of both the OpenDAL project and the OpenDAL software product to the ASF as the parent organization.
Expand Down
9 changes: 5 additions & 4 deletions integrations/object_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,21 @@ pub use store::OpendalStore;
mod utils;

// Make sure `send_wrapper` works as expected
#[cfg(all(feature = "send_wrapper", target_arch = "wasm32"))]
#[cfg(all(feature = "send_wrapper", test))]
mod assert_send {
use object_store::ObjectStore;
use object_store::{ObjectStore, PutPayload};
use opendal::Operator;

#[allow(dead_code)]
fn assert_send<T: Send>(_: T) {}

#[allow(dead_code)]
fn assertion() {
let op = super::Operator::new(opendal::services::Memory::default())
let op = Operator::new(opendal::services::Memory::default())
.unwrap()
.finish();
let store = super::OpendalStore::new(op);
assert_send(store.put(&"test".into(), bytes::Bytes::new()));
assert_send(store.put(&"test".into(), PutPayload::new()));
assert_send(store.get(&"test".into()));
assert_send(store.get_range(&"test".into(), 0..1));
assert_send(store.head(&"test".into()));
Expand Down
2 changes: 2 additions & 0 deletions integrations/object_store/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ impl ObjectStore for OpendalStore {

let stream = r
.into_bytes_stream(0..meta.size as u64)
.into_send()
.await
.map_err(|err| object_store::Error::Generic {
store: "IoError",
Expand Down Expand Up @@ -400,6 +401,7 @@ impl ObjectStore for OpendalStore {
let meta = self
.inner
.stat(entry.path())
.into_send()
.await
.map_err(|err| format_object_store_error(err, entry.path()))?;
objects.push(format_object_meta(entry.path(), &meta));
Expand Down

0 comments on commit 0996e13

Please sign in to comment.