Skip to main content

hub_codegen/generator/
mod.rs

1//! Code generation from IR
2
3#[cfg(feature = "typescript")]
4pub mod typescript;
5
6#[cfg(feature = "rust")]
7pub mod rust;
8
9use std::collections::HashMap;
10
11/// A warning emitted during code generation
12#[derive(Debug, Clone)]
13pub struct Warning {
14    pub location: String,
15    pub message: String,
16}
17
18impl std::fmt::Display for Warning {
19    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20        write!(f, "{}: {}", self.location, self.message)
21    }
22}
23
24/// Result of code generation
25pub struct GenerationResult {
26    /// Map of relative path -> file content
27    pub files: HashMap<String, String>,
28    /// Warnings encountered during generation
29    pub warnings: Vec<Warning>,
30    /// Map of relative path -> content hash (for cache invalidation)
31    pub file_hashes: HashMap<String, String>,
32}
33
34/// Options for code generation
35#[derive(Debug, Clone)]
36pub struct GenerationOptions {
37    /// Whether to bundle transport code (for TypeScript)
38    /// If false, assumes external @plexus/rpc-client package
39    pub bundle_transport: bool,
40}
41
42impl Default for GenerationOptions {
43    fn default() -> Self {
44        Self {
45            bundle_transport: true,
46        }
47    }
48}
49