File
can no longer be used with signals since 0.7
#3619
Answered
by
benwis
anshap1719
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Have you tried using `signal_local` to create a signal that is not send/sync?
On Sat, Feb 15, 2025, at 11:34 PM, Anshul Sanghi wrote:
I have a project I'm migrating from 0.6 to 0.7, and a big hurdle is that the `File` type that comes from `web_sys` can no longer be used with a signal, since *mut u8 is not thread-safe. A SendWrapper doesn't work either because then it doesn't implement the `Track` trait that signals need.
Here's a simple example to reproduce the issue:
`let (files, set_files) = signal::<Vec<web_sys::File>>(vec![]);
`
This produces the following error:
`error[E0277]: `*mut u8` cannot be sent between threads safely
--> src/modules/awdio.rs:34:39
|
34 | let (files, set_files) = signal::<Vec<File>>(vec![]);
| ^^^^^^^^^ `*mut u8` cannot be sent between threads safely
|
= help: within `Vec<web_sys::File>`, the trait `Send` is not implemented for `*mut u8`
note: required because it appears within the type `PhantomData<*mut u8>`
--> /Users/anshulsanghi/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/marker.rs:757:12
|
757 | pub struct PhantomData<T: ?Sized>;
| ^^^^^^^^^^^
note: required because it appears within the type `JsValue`
--> /Users/anshulsanghi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/wasm-bindgen-0.2.100/src/lib.rs:135:12
|
135 | pub struct JsValue {
| ^^^^^^^
note: required because it appears within the type `wasm_bindgen_futures::js_sys::Object`
--> /Users/anshulsanghi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/js-sys-0.3.77/src/lib.rs:3445:14
|
3445 | pub type Object;
| ^^^^^^
note: required because it appears within the type `web_sys::Blob`
--> /Users/anshulsanghi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/web-sys-0.3.77/src/features/gen_Blob.rs:14:14
|
14 | pub type Blob;
| ^^^^
note: required because it appears within the type `web_sys::File`
--> /Users/anshulsanghi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/web-sys-0.3.77/src/features/gen_File.rs:14:14
|
14 | pub type File;
| ^^^^
note: required because it appears within the type `PhantomData<web_sys::File>`
--> /Users/anshulsanghi/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/marker.rs:757:12
|
757 | pub struct PhantomData<T: ?Sized>;
| ^^^^^^^^^^^
note: required because it appears within the type `wasm_bindgen::__rt::alloc::raw_vec::RawVec<web_sys::File>`
--> /Users/anshulsanghi/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/raw_vec.rs:70:19
|
70 | pub(crate) struct RawVec<T, A: Allocator = Global> {
| ^^^^^^
note: required because it appears within the type `Vec<web_sys::File>`
--> /Users/anshulsanghi/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs:397:12
|
397 | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> {
| ^^^
note: required by a bound in `leptos::prelude::signal`
--> /Users/anshulsanghi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reactive_graph-0.1.7/src/signal.rs:113:18
|
113 | pub fn signal<T: Send + Sync + 'static>(
| ^^^^ required by this bound in `signal`
`
… Can anyone please suggest what the best solution would be for this? I don't think I have the option of not using a signal for files.
—
Reply to this email directly, view it on GitHub <#3619>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABVBTCICPDLR5SRYD6JIX4D2QA5RHAVCNFSM6AAAAABXHJZWVKVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZXHE3TCMBYG4>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
anshap1719
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a project I'm migrating from 0.6 to 0.7, and a big hurdle is that the
File
type that comes fromweb_sys
can no longer be used with a signal, since *mut u8 is not thread-safe. A SendWrapper doesn't work either because then it doesn't implement theTrack
trait that signals need.Here's a simple example to reproduce the issue:
This produces the following error:
Can anyone please suggest what the best solution would be for this? I don't think I have the option of not using a signal for files.
Beta Was this translation helpful? Give feedback.
All reactions