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}
24
25impl std::fmt::Display for Language {
26 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27 match self {
28 Self::Python => write!(f, "python"),
29 Self::Node => write!(f, "node"),
30 Self::Ruby => write!(f, "ruby"),
31 Self::Php => write!(f, "php"),
32 Self::Elixir => write!(f, "elixir"),
33 Self::Wasm => write!(f, "wasm"),
34 Self::Ffi => write!(f, "ffi"),
35 Self::Go => write!(f, "go"),
36 Self::Java => write!(f, "java"),
37 Self::Csharp => write!(f, "csharp"),
38 Self::R => write!(f, "r"),
39 Self::Rust => write!(f, "rust"),
40 Self::Kotlin => write!(f, "kotlin"),
41 Self::Swift => write!(f, "swift"),
42 Self::Dart => write!(f, "dart"),
43 Self::Gleam => write!(f, "gleam"),
44 Self::Zig => write!(f, "zig"),
45 }
46 }
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize)]
51pub struct AdapterParam {
52 pub name: String,
53 #[serde(rename = "type")]
54 pub ty: String,
55 #[serde(default)]
56 pub optional: bool,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(rename_all = "snake_case")]
62pub enum AdapterPattern {
63 SyncFunction,
64 AsyncMethod,
65 CallbackBridge,
66 Streaming,
67 ServerLifecycle,
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize)]
72pub struct AdapterConfig {
73 pub name: String,
74 pub pattern: AdapterPattern,
75 pub core_path: String,
77 #[serde(default)]
79 pub params: Vec<AdapterParam>,
80 pub returns: Option<String>,
82 pub error_type: Option<String>,
84 pub owner_type: Option<String>,
86 pub item_type: Option<String>,
88 #[serde(default)]
90 pub gil_release: bool,
91 #[serde(default)]
93 pub trait_name: Option<String>,
94 #[serde(default)]
96 pub trait_method: Option<String>,
97 #[serde(default)]
99 pub detect_async: bool,
100}