Skip to main content

systemprompt_models/execution/context/
call_source.rs

1//! Call source classification.
2
3use anyhow::anyhow;
4use serde::{Deserialize, Serialize};
5use std::str::FromStr;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
8#[serde(rename_all = "lowercase")]
9pub enum CallSource {
10    Agentic,
11    Direct,
12    Ephemeral,
13}
14
15impl FromStr for CallSource {
16    type Err = anyhow::Error;
17
18    fn from_str(s: &str) -> Result<Self, Self::Err> {
19        match s.to_lowercase().as_str() {
20            "agentic" => Ok(Self::Agentic),
21            "direct" => Ok(Self::Direct),
22            "ephemeral" => Ok(Self::Ephemeral),
23            _ => Err(anyhow!("Invalid CallSource: {s}")),
24        }
25    }
26}
27
28impl CallSource {
29    pub const fn as_str(&self) -> &'static str {
30        match self {
31            Self::Agentic => "agentic",
32            Self::Direct => "direct",
33            Self::Ephemeral => "ephemeral",
34        }
35    }
36}