Skip to main content

systemprompt_agent/
state.rs

1use std::sync::Arc;
2use systemprompt_database::DbPool;
3use systemprompt_models::Config;
4use systemprompt_traits::DynJwtValidationProvider;
5
6#[derive(Clone)]
7pub struct AgentState {
8    db_pool: DbPool,
9    config: Arc<Config>,
10    jwt_provider: DynJwtValidationProvider,
11}
12
13impl AgentState {
14    #[must_use]
15    pub fn new(
16        db_pool: DbPool,
17        config: Arc<Config>,
18        jwt_provider: DynJwtValidationProvider,
19    ) -> Self {
20        Self {
21            db_pool,
22            config,
23            jwt_provider,
24        }
25    }
26
27    #[must_use]
28    pub const fn db_pool(&self) -> &DbPool {
29        &self.db_pool
30    }
31
32    #[must_use]
33    pub fn config(&self) -> &Config {
34        &self.config
35    }
36
37    #[must_use]
38    pub fn jwt_provider(&self) -> &DynJwtValidationProvider {
39        &self.jwt_provider
40    }
41}
42
43impl std::fmt::Debug for AgentState {
44    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
45        f.debug_struct("AgentState")
46            .field("db_pool", &"<DbPool>")
47            .field("config", &"<Arc<Config>>")
48            .field("jwt_provider", &"<DynJwtValidationProvider>")
49            .finish()
50    }
51}