Skip to main content

systemprompt_extension/
context.rs

1//! Runtime context handed to extensions during router resolution.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use std::sync::Arc;
7use systemprompt_traits::{ConfigProvider, DatabaseHandle};
8
9pub trait ExtensionContext: Send + Sync {
10    fn config(&self) -> Arc<dyn ConfigProvider>;
11
12    fn database(&self) -> Arc<dyn DatabaseHandle>;
13
14    fn get_extension(&self, id: &str) -> Option<Arc<dyn crate::Extension>>;
15
16    fn has_extension(&self, id: &str) -> bool {
17        self.get_extension(id).is_some()
18    }
19}
20
21pub type DynExtensionContext = Arc<dyn ExtensionContext>;