Skip to main content

neutrino_schema/codegen/
options.rs

1use crate::types::TypeRegistry;
2
3/// Controls whether rendered output includes debug annotations.
4///
5/// Every generator interprets these modes in its own way.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7#[cfg_attr(feature = "cli", derive(serde::Serialize, serde::Deserialize))]
8#[cfg_attr(feature = "cli", serde(rename_all = "lowercase"))]
9pub enum RenderMode {
10    /// Clean output — no extra annotations.
11    Clean,
12    /// Include type annotations, nullability, or other debug information.
13    Debug,
14}
15
16/// Generic generation options shared across all generators.
17#[derive(Debug, Clone)]
18pub struct GenerateOptions {
19    pub render_mode: RenderMode,
20    pub rust: RustGeneratorConfig,
21}
22
23/// Rust-specific generator configuration.
24#[derive(Debug, Clone)]
25pub struct RustGeneratorConfig {
26    pub module_name: String,
27    pub derive_from_row: bool,
28    pub type_registry: TypeRegistry,
29}
30
31impl Default for GenerateOptions {
32    fn default() -> Self {
33        Self {
34            render_mode: RenderMode::Clean,
35            rust: RustGeneratorConfig::default(),
36        }
37    }
38}
39
40impl Default for RustGeneratorConfig {
41    fn default() -> Self {
42        Self {
43            module_name: "types".into(),
44            derive_from_row: false,
45            type_registry: TypeRegistry::default(),
46        }
47    }
48}