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