-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl From<Arc<T>> for web::Data<T> #1300
Comments
@SOF3 would you be so kind to provide a code example of your issue: what do you have at the moment and what do you want to achieve (or how do you see it should be)? At the moment it's hard for me to advice you something or elaborate on this, because I don't feel I understand you clearly. Thanks! |
Does T implement Send and Sync? If so, you may wrap T in web::Data::new() when you add the data and it will not internally wrap it in Arc. If it does not implement Send and Sync, you can wrap it in a mutex. The doc for web::Data has an example doing exactly that. |
I'm having a similar issue right now. Basically I'm trying to use actix-web as a small piece of a larger application to handle REST calls that reflect state that's already stored as
https://docs.rs/actix-web/2.0.0/src/actix_web/data.rs.html#74 So if I call |
@jeff-at-dwelo latest Rust 1.41 that dropped today with the loosened orphaned traits rules means you should be able to fix this quick directly inline in your project and then feel free to PR your solution See https://rust-lang.github.io/rfcs/2451-re-rebalancing-coherence.html |
@thorjelly the point here is that the |
I am currently facing a similar issue. My motivation: I would be more than happy to contribute a solution as this should not be all to hard to implement if you are fine with it. |
actix-web is just part of my application. The data I am trying to store comes from the upper level, which passes the value around as an
Arc<T>
. I could only store this value asweb::Data<Arc<T>>
, but this would become double indirection.The text was updated successfully, but these errors were encountered: