1use crate::config::Settings;
7
8#[derive(
9 Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Deserialize, serde::Serialize,
10)]
11#[serde(rename_all = "snake_case", deny_unknown_fields)]
12pub struct Context {
13 pub(crate) settings: Settings,
14}
15
16impl Context {
17 pub fn new() -> Self {
19 let settings = Settings::build().unwrap_or_default();
20 Self { settings }
21 }
22 pub const fn from_config(settings: Settings) -> Self {
24 Self { settings }
25 }
26 pub const fn settings(&self) -> &Settings {
28 &self.settings
29 }
30 pub fn settings_mut(&mut self) -> &mut Settings {
32 &mut self.settings
33 }
34}