use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
#[serde(rename_all = "lowercase")]
pub enum Language {
Python,
Node,
Ruby,
Php,
Elixir,
Wasm,
Ffi,
Go,
Java,
Csharp,
R,
}
impl std::fmt::Display for Language {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Python => write!(f, "python"),
Self::Node => write!(f, "node"),
Self::Ruby => write!(f, "ruby"),
Self::Php => write!(f, "php"),
Self::Elixir => write!(f, "elixir"),
Self::Wasm => write!(f, "wasm"),
Self::Ffi => write!(f, "ffi"),
Self::Go => write!(f, "go"),
Self::Java => write!(f, "java"),
Self::Csharp => write!(f, "csharp"),
Self::R => write!(f, "r"),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AdapterParam {
pub name: String,
#[serde(rename = "type")]
pub ty: String,
#[serde(default)]
pub optional: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum AdapterPattern {
SyncFunction,
AsyncMethod,
CallbackBridge,
Streaming,
ServerLifecycle,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AdapterConfig {
pub name: String,
pub pattern: AdapterPattern,
pub core_path: String,
#[serde(default)]
pub params: Vec<AdapterParam>,
pub returns: Option<String>,
pub error_type: Option<String>,
pub owner_type: Option<String>,
pub item_type: Option<String>,
#[serde(default)]
pub gil_release: bool,
#[serde(default)]
pub trait_name: Option<String>,
#[serde(default)]
pub trait_method: Option<String>,
#[serde(default)]
pub detect_async: bool,
}