Byron / google-apis-rs

A binding and CLI generator for all Google APIs
http://byron.github.io/google-apis-rs
Other
1.02k stars 136 forks source link

google_pubsub1::Error is not compatible with failure #228

Closed nagisa closed 3 years ago

nagisa commented 5 years ago

If google_pubsub1::Error is used in a failure error as follows will be reported:

error[E0277]: `(dyn std::error::Error + 'static)` cannot be shared between threads safely
  --> src/main.rs:23:17
   |
23 | #[derive(Debug, Fail)]
   |                 ^^^^ `(dyn std::error::Error + 'static)` cannot be shared between threads safely
   |
   = help: the trait `std::marker::Sync` is not implemented for `(dyn std::error::Error + 'static)`
   = note: required because of the requirements on the impl of `std::marker::Sync` for `std::ptr::Unique<(dyn std::error::Error + 'static)>`
   = note: required because it appears within the type `std::boxed::Box<(dyn std::error::Error + 'static)>`
   = note: required because it appears within the type `google_pubsub1::cmn::Error`
   = note: required because it appears within the type `Error`
Byron commented 5 years ago

I have had a look and believe this field in the Error type is responsible for the issue. When digging deeper, I noticed that it is populated by code like this self.hub.auth.borrow_mut().token(self._scopes.keys()), which goes back to the yup-oauth2 authenticator's token() method, which itself does not implement Send + Sync. This certainly is an oversight, and one which can't easily be fixed in this repository.

yup-oauth 3.0 beta seems to be migrating to futures, which also fixes this problem. Thus I believe at some point when this repository switches to async, the issue will be fixed at last.

Related to #189

nagisa commented 4 years ago

yup_oauth is now at 3.1 so upgrading it would fix this.

Byron commented 4 years ago

@nagisa I took a look and as suspected, migrating from 1.0 to 3.0 is quite some non-trivial work that is likely to affect consumers of this library as well. Probably this is already a non-issue in the next iteration of the google-apis, even though they are not quite ready for everyone just yet.

Byron commented 3 years ago

Is it compatible with anyhow? The failure crate has been deprecated I believe in favour of others.