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
here is the code:
main function :
rocket::build()
.attach(AdHoc::try_on_ignite("NACOSREGISTER", run_regist))
.attach(AdHoc::try_on_ignite("DBREGISTER", init_db))
the second fairing function:
pub async fn init_db(rocket: Rocket)->fairing::Result {
let sm=rocket.state::().unwrap();
///...
}
the error info:
error[E0277]: (dyn ConfigService + 'static) cannot be shared between threads safely
--> src\db\db_fairings.rs:41:27
|
41 | let sm=rocket.state::().unwrap();
| ^^^^^^^^^^^^^^ (dyn ConfigService + 'static) cannot be shared between threads safely
|
= help: the trait Sync is not implemented for (dyn ConfigService + 'static)
= note: required for Arc<(dyn ConfigService + 'static)> to implement std::marker::Send
= note: 1 redundant requirement hidden
= note: required for std::sync::Mutex<Arc<(dyn ConfigService + 'static)>> to implement std::marker::Send
note: required because it appears within the type ServiceManager
--> src\db\sm_fairings.rs:14:12
|
14 | pub struct ServiceManager {
| ^^^^^^^^^^^^^^
note: required by a bound in Rocket::<P>::state
|
821 | pub fn state<T: Send + Sync + 'static>(&self) -> Option<&T> {
| ^^^^ required by this bound in Rocket::<P>::state
i don't know how to resolve that. i need some help.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
here is the code:
main function :
rocket::build()
.attach(AdHoc::try_on_ignite("NACOSREGISTER", run_regist))
.attach(AdHoc::try_on_ignite("DBREGISTER", init_db))
the first fairing function:
pub struct ServiceManager {
pub(super) config_service: Mutex<Arc>,
}
pub async fn run_regist(rocket: Rocket) -> fairing::Result {
/// ...
Ok(rocket.manage(ServiceManager {
config_service: Mutex::new(Arc::new(config_service)),
}))
///...
}
the second fairing function:
pub async fn init_db(rocket: Rocket)->fairing::Result {
let sm=rocket.state::().unwrap();
///...
}
the error info:
error[E0277]:
(dyn ConfigService + 'static)
cannot be shared between threads safely--> src\db\db_fairings.rs:41:27
|
41 | let sm=rocket.state::().unwrap();
| ^^^^^^^^^^^^^^
(dyn ConfigService + 'static)
cannot be shared between threads safely|
= help: the trait
Sync
is not implemented for(dyn ConfigService + 'static)
= note: required for
Arc<(dyn ConfigService + 'static)>
to implementstd::marker::Send
= note: 1 redundant requirement hidden
= note: required for
std::sync::Mutex<Arc<(dyn ConfigService + 'static)>>
to implementstd::marker::Send
note: required because it appears within the type
ServiceManager
--> src\db\sm_fairings.rs:14:12
|
14 | pub struct ServiceManager {
| ^^^^^^^^^^^^^^
note: required by a bound in
Rocket::<P>::state
821 | pub fn state<T: Send + Sync + 'static>(&self) -> Option<&T> {
| ^^^^ required by this bound in
Rocket::<P>::state
i don't know how to resolve that. i need some help.
Beta Was this translation helpful? Give feedback.
All reactions