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