Description
Hi,
Newbie here so apologize in advance if this is a stupid question 😅
I'm trying to use the SDK, specifically the grant_token, with axum on multithread runtime environment.
I run into the problem calling following example.
pubnub
.grant_token(usize)
.resources(Option<[Box<permissions::Permission>]>)
.patterns(Option<[Box<permissions::Permission>]>)
.authorized_user_id(Option<String>)
.meta(Option<HashMap<String, MetaValue>>)
.execute()
The error I get is
error[E0277]:
(dyn Permission + 'static)
cannot be shared between threads safely
--> src/routes/player_route.rs:88:1
|
88 | #[debug_handler]
| ^^^^^^^^^^^^^^^^(dyn Permission + 'static)
cannot be shared between threads safely
|
= help: the traitSync
is not implemented for(dyn Permission + 'static)
= note: required forstd::ptr::Unique<(dyn Permission + 'static)>
to implementSync
note: required because it appears within the typeBox<(dyn Permission + 'static)>
Per my understanding, the cause is that .resources
takes trait object Option<[Box<dyn Permission + 'static>]
as a parameter whereas axum require Send
for trait paremeter (tokio-rs/axum#2522) to ensure thread safety.
Anyone has successfully run the SDK on axum please enlighten me.
Thank you! 🙏