Skip to content

Commit 4faf73f

Browse files
committed
Use SendWrapper
1 parent e68f15f commit 4faf73f

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

core/Cargo.lock

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

core/services/opfs/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ js-sys = "0.3.77"
3535
opendal-core = { path = "../../core", version = "0.55.0", default-features = false }
3636
serde = { workspace = true, features = ["derive"] }
3737
wasm-bindgen = "0.2.100"
38+
send_wrapper = "0.6"
3839
wasm-bindgen-futures = "0.4.50"
3940
web-sys = { version = "0.3.77", features = [
4041
"Blob",

core/services/opfs/src/reader.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
use send_wrapper::SendWrapper;
1819
use wasm_bindgen::JsCast;
1920
use wasm_bindgen_futures::JsFuture;
2021
use web_sys::FileSystemFileHandle;
@@ -24,20 +25,15 @@ use opendal_core::raw::*;
2425
use opendal_core::*;
2526

2627
pub struct OpfsReader {
27-
handle: FileSystemFileHandle,
28+
handle: SendWrapper<FileSystemFileHandle>,
2829
range: BytesRange,
2930
done: bool,
3031
}
3132

32-
/// Safety: wasm32 is single-threaded, `Send` and `Sync` are meaningless.
33-
unsafe impl Send for OpfsReader {}
34-
/// Safety: wasm32 is single-threaded, `Send` and `Sync` are meaningless.
35-
unsafe impl Sync for OpfsReader {}
36-
3733
impl OpfsReader {
3834
pub fn new(handle: FileSystemFileHandle, range: BytesRange) -> Self {
3935
Self {
40-
handle,
36+
handle: SendWrapper::new(handle),
4137
range,
4238
done: false,
4339
}

core/services/opfs/src/writer.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
use send_wrapper::SendWrapper;
1819
use wasm_bindgen_futures::JsFuture;
1920
use web_sys::FileSystemWritableFileStream;
2021

@@ -24,19 +25,14 @@ use opendal_core::*;
2425
use super::error::*;
2526

2627
pub struct OpfsWriter {
27-
stream: FileSystemWritableFileStream,
28+
stream: SendWrapper<FileSystemWritableFileStream>,
2829
bytes_written: u64,
2930
}
3031

31-
/// Safety: wasm32 is single-threaded, `Send` and `Sync` are meaningless.
32-
unsafe impl Send for OpfsWriter {}
33-
/// Safety: wasm32 is single-threaded, `Send` and `Sync` are meaningless.
34-
unsafe impl Sync for OpfsWriter {}
35-
3632
impl OpfsWriter {
3733
pub fn new(stream: FileSystemWritableFileStream) -> Self {
3834
Self {
39-
stream,
35+
stream: SendWrapper::new(stream),
4036
bytes_written: 0,
4137
}
4238
}

0 commit comments

Comments
 (0)