use crate::Context; pub trait ContextUserExt { fn set_user_id(&self, user_id: impl Into) -> Context; fn set_user_id_mut(&mut self, user_id: impl Into) -> &mut Context; fn get_user_id(&self) -> Option; } const USER_ID_KEY: &str = "user_id"; impl ContextUserExt for Context { fn set_user_id(&self, user_id: impl Into) -> Context { self.with_value(USER_ID_KEY, user_id) } fn set_user_id_mut(&mut self, user_id: impl Into) -> &mut Context { self.with_value_mut(USER_ID_KEY, user_id) } fn get_user_id(&self) -> Option { self.get(USER_ID_KEY).map(|s| s.to_string()) } }