alef_core/config/
extras.rs1use 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}
18
19impl std::fmt::Display for Language {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 match self {
22 Self::Python => write!(f, "python"),
23 Self::Node => write!(f, "node"),
24 Self::Ruby => write!(f, "ruby"),
25 Self::Php => write!(f, "php"),
26 Self::Elixir => write!(f, "elixir"),
27 Self::Wasm => write!(f, "wasm"),
28 Self::Ffi => write!(f, "ffi"),
29 Self::Go => write!(f, "go"),
30 Self::Java => write!(f, "java"),
31 Self::Csharp => write!(f, "csharp"),
32 Self::R => write!(f, "r"),
33 }
34 }
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct AdapterParam {
40 pub name: String,
41 #[serde(rename = "type")]
42 pub ty: String,
43 #[serde(default)]
44 pub optional: bool,
45}
46
47#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(rename_all = "snake_case")]
50pub enum AdapterPattern {
51 SyncFunction,
52 AsyncMethod,
53 CallbackBridge,
54 Streaming,
55 ServerLifecycle,
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct AdapterConfig {
61 pub name: String,
62 pub pattern: AdapterPattern,
63 pub core_path: String,
65 #[serde(default)]
67 pub params: Vec<AdapterParam>,
68 pub returns: Option<String>,
70 pub error_type: Option<String>,
72 pub owner_type: Option<String>,
74 pub item_type: Option<String>,
76 #[serde(default)]
78 pub gil_release: bool,
79 #[serde(default)]
81 pub trait_name: Option<String>,
82 #[serde(default)]
84 pub trait_method: Option<String>,
85 #[serde(default)]
87 pub detect_async: bool,
88}