Using Arc<AppState>
with SignedCookieJar
#1556
-
Hello, I've been following some examples that were using
The example of the Any recommendations? |
Beta Was this translation helpful? Give feedback.
Answered by
davidpdrsn
Nov 20, 2022
Replies: 1 comment 4 replies
-
Since you cannot implement #[derive(Clone)]
struct AppState(Arc<InnerState>);
// deref so you can still access the inner fields easily
impl Deref for AppState {
type Target = InnerState;
fn deref(&self) -> &Self::Target {
&*self.0
}
}
struct InnerState {
key: Key
}
impl FromRef<AppState> for Key {
fn from_ref(state: &AppState) -> Self {
state.0.key.clone()
}
} |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
woile
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since you cannot implement
FromRef<Arc<AppState>> for Key
I'd recommend a newtype: