use super::{ProviderItem, ProviderResult};
pub trait ContextProvider: Send + Sync {
fn id(&self) -> &'static str;
fn display_name(&self) -> &'static str;
fn supported_actions(&self) -> &[&str];
fn execute(&self, action: &str, params: &ProviderParams) -> Result<ProviderResult, String>;
fn reuse_binding(&self, _action: &str, _params: &ProviderParams) -> Option<String> {
None
}
fn reacquire_item(
&self,
_action: &str,
_params: &ProviderParams,
_item_id: &str,
) -> Result<ProviderResult, String> {
Err("provider does not support current item authorization".into())
}
fn cache_ttl_secs(&self) -> u64 {
120
}
fn requires_auth(&self) -> bool {
true
}
fn is_available(&self) -> bool;
}
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
pub struct ProviderParams {
pub project: Option<String>,
pub state: Option<String>,
pub limit: Option<usize>,
pub query: Option<String>,
pub id: Option<String>,
}
#[derive(Debug, Clone)]
pub struct ContextPacket {
pub provider_id: String,
pub action: String,
pub items: Vec<ProviderItem>,
pub token_count_raw: usize,
pub token_count_compressed: usize,
pub cache_hit: bool,
}