Skip to main content

systemprompt_models/execution/context/
call_source.rs

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