1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
4#[serde(rename_all = "lowercase")]
5pub enum Language {
6 Python,
7 Node,
8 Ruby,
9 Php,
10 Elixir,
11 Wasm,
12 Ffi,
13 Go,
14 Java,
15 Csharp,
16 R,
17 Rust,
18 Kotlin,
19 Swift,
20 Dart,
21 Gleam,
22 Zig,
23 C,
25}
26
27impl std::fmt::Display for Language {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 match self {
30 Self::Python => write!(f, "python"),
31 Self::Node => write!(f, "node"),
32 Self::Ruby => write!(f, "ruby"),
33 Self::Php => write!(f, "php"),
34 Self::Elixir => write!(f, "elixir"),
35 Self::Wasm => write!(f, "wasm"),
36 Self::Ffi => write!(f, "ffi"),
37 Self::Go => write!(f, "go"),
38 Self::Java => write!(f, "java"),
39 Self::Csharp => write!(f, "csharp"),
40 Self::R => write!(f, "r"),
41 Self::Rust => write!(f, "rust"),
42 Self::Kotlin => write!(f, "kotlin"),
43 Self::Swift => write!(f, "swift"),
44 Self::Dart => write!(f, "dart"),
45 Self::Gleam => write!(f, "gleam"),
46 Self::Zig => write!(f, "zig"),
47 Self::C => write!(f, "c"),
48 }
49 }
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54pub struct AdapterParam {
55 pub name: String,
56 #[serde(rename = "type")]
57 pub ty: String,
58 #[serde(default)]
59 pub optional: bool,
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(rename_all = "snake_case")]
65pub enum AdapterPattern {
66 SyncFunction,
67 AsyncMethod,
68 CallbackBridge,
69 Streaming,
70 ServerLifecycle,
71}
72
73#[derive(Debug, Clone, Serialize, Deserialize)]
75pub struct AdapterConfig {
76 pub name: String,
77 pub pattern: AdapterPattern,
78 pub core_path: String,
80 #[serde(default)]
82 pub params: Vec<AdapterParam>,
83 pub returns: Option<String>,
85 pub error_type: Option<String>,
87 pub owner_type: Option<String>,
89 pub item_type: Option<String>,
91 #[serde(default)]
93 pub gil_release: bool,
94 #[serde(default)]
96 pub trait_name: Option<String>,
97 #[serde(default)]
99 pub trait_method: Option<String>,
100 #[serde(default)]
102 pub detect_async: bool,
103 #[serde(default)]
108 pub request_type: Option<String>,
109}