use std::ops::Deref; use std::sync::Arc; /// Application state pub struct State(Arc); impl State { pub fn new(state: S) -> State { State(Arc::new(state)) } pub fn get_ref(&self) -> &S { self.0.as_ref() } } impl Deref for State { type Target = S; fn deref(&self) -> &S { self.0.as_ref() } } impl Clone for State { fn clone(&self) -> State { State(self.0.clone()) } }