You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use std::io::Read;use firestore::{FirestoreDb,FirestoreListenerTarget};use tower_controller_rs::temp_file_token_storage::TempFileTokenStorage;#[tokio::main]asyncfnmain(){let db = FirestoreDb::new("my-project-id").await.unwrap();letmut listener = db.create_listener(TempFileTokenStorage).await.unwrap();
db.fluent().select().from("my-col").listen().add_target(FirestoreListenerTarget::new(1),&mut listener).unwrap();
listener
.start(move |r| {let db = db.clone();asyncmove{
db.fluent().select().by_id_in("mycol").one("mydoc").await.unwrap();Ok(())}}).await.unwrap();
std::io::stdin().read(&mut[1]).unwrap();
listener.shutdown().await.unwrap();}
Fails to compile with the following error:
error: future cannot be shared between threads safely
--> src\bin\error_example.rs:20:10
|
20 | .start(move |r| {
| ^^^^^ future created by async block is not `Sync`
|
= help: the trait `Sync` is not implemented for `dynFuture<Output = Result<gcloud_sdk::apis::google::firestore::v1::Document,FirestoreError>> + Send`
note: future is not `Sync` as this value is used across an await
--> D:\Repos\firestore-rs\src\fluent_api\select_builder.rs:330:17
|
322 | matchself
| ___________________-
323 | | .db
324 | | .get_doc_at::<S>(325 | | parent.as_str(),
... |
328 | | self.return_only_fields,329 | | )
| |_________________- has type `Pin<Box<dynFuture<Output = Result<gcloud_sdk::apis::google::firestore::v1::Document,FirestoreError>> + Send>>` which is not `Sync`
330 | .await
| ^^^^^^ await occurs here, with the value maybe used later
...
338 | }else{
| - the value is later dropped here
note: required by a bound in `FirestoreListener::<D,S>::start`
--> D:\Repos\firestore-rs\src\db\listen_changes.rs:231:57
|
231 | F:Future<Output = BoxedErrResult<()>> + Send + Sync + 'static,
| ^^^^ required by this bound in `FirestoreListener::<D,S>::start`
This is due to the start function requiring a Sync future and the fluent api not returning a future with Sync. It is possible to remove this requirement from the start function (and a function it calls) without it causing an error. Not guaranteed everything still works. I will open a draft pull request (#71 ).
The text was updated successfully, but these errors were encountered:
The following code:
Fails to compile with the following error:
This is due to the start function requiring a
Sync
future and the fluent api not returning a future withSync
. It is possible to remove this requirement from the start function (and a function it calls) without it causing an error. Not guaranteed everything still works. I will open a draft pull request (#71 ).The text was updated successfully, but these errors were encountered: