Skip to main content

systemprompt_api/routes/managed/
state.rs

1//! Router state for the managed-resource admin surface: the application
2//! context, which owns the managed repository the handlers read and write.
3//!
4//! Copyright (c) systemprompt.io — Business Source License 1.1.
5//! See <https://systemprompt.io> for licensing details.
6
7use axum::extract::FromRef;
8use systemprompt_runtime::AppContext;
9
10#[derive(Debug, Clone)]
11pub struct ManagedState {
12    ctx: AppContext,
13}
14
15impl ManagedState {
16    pub const fn new(ctx: AppContext) -> Self {
17        Self { ctx }
18    }
19
20    pub const fn ctx(&self) -> &AppContext {
21        &self.ctx
22    }
23}
24
25impl FromRef<ManagedState> for AppContext {
26    fn from_ref(state: &ManagedState) -> Self {
27        state.ctx.clone()
28    }
29}