cadi_core/rehydration/
config.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct ViewConfig {
8 #[serde(default = "default_max_tokens")]
10 pub max_tokens: usize,
11
12 #[serde(default = "default_expansion_depth")]
14 pub expansion_depth: usize,
15
16 #[serde(default = "default_true")]
18 pub include_docs: bool,
19
20 #[serde(default = "default_true")]
22 pub include_types: bool,
23
24 #[serde(default)]
26 pub format: ViewFormat,
27
28 #[serde(default = "default_true")]
30 pub add_separators: bool,
31
32 #[serde(default = "default_true")]
34 pub sort_by_type: bool,
35
36 #[serde(default = "default_true")]
38 pub deduplicate: bool,
39}
40
41fn default_max_tokens() -> usize { 8000 }
42fn default_expansion_depth() -> usize { 1 }
43fn default_true() -> bool { true }
44
45impl Default for ViewConfig {
46 fn default() -> Self {
47 Self {
48 max_tokens: default_max_tokens(),
49 expansion_depth: default_expansion_depth(),
50 include_docs: true,
51 include_types: true,
52 format: ViewFormat::Source,
53 add_separators: true,
54 sort_by_type: true,
55 deduplicate: true,
56 }
57 }
58}
59
60impl ViewConfig {
61 pub fn minimal() -> Self {
63 Self {
64 max_tokens: 2000,
65 expansion_depth: 0,
66 include_docs: false,
67 include_types: false,
68 format: ViewFormat::Minimal,
69 add_separators: false,
70 sort_by_type: false,
71 deduplicate: true,
72 }
73 }
74
75 pub fn documented() -> Self {
77 Self {
78 max_tokens: 16000,
79 expansion_depth: 2,
80 include_docs: true,
81 include_types: true,
82 format: ViewFormat::Documented,
83 add_separators: true,
84 sort_by_type: true,
85 deduplicate: true,
86 }
87 }
88
89 pub fn with_max_tokens(mut self, tokens: usize) -> Self {
91 self.max_tokens = tokens;
92 self
93 }
94
95 pub fn with_expansion(mut self, depth: usize) -> Self {
97 self.expansion_depth = depth;
98 self
99 }
100
101 pub fn no_expansion(mut self) -> Self {
103 self.expansion_depth = 0;
104 self
105 }
106}
107
108#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
110#[serde(rename_all = "snake_case")]
111pub enum ViewFormat {
112 #[default]
114 Source,
115 Minimal,
117 Documented,
119 Signatures,
121 Json,
123}