pub trait TypeMapper {
// Required methods
fn map_primitive(&self, ty: PrimitiveType) -> String;
fn map_optional(&self, inner: &str) -> String;
fn map_array(&self, inner: &str) -> String;
fn map_result(&self, ok: &str, err: &str) -> String;
fn map_unit(&self) -> String;
// Provided methods
fn map_ref(&self, inner: &str) -> String { ... }
fn map_ref_mut(&self, inner: &str) -> String { ... }
fn map_generic(&self, base: &str, args: &[String]) -> String { ... }
fn render_type(&self, ty: &TypeRef) -> String { ... }
}Expand description
Trait for mapping types to language-specific representations.
Implement this trait to support a new target language’s type system.
Required Methods§
Sourcefn map_primitive(&self, ty: PrimitiveType) -> String
fn map_primitive(&self, ty: PrimitiveType) -> String
Map a primitive type to the target language.
Sourcefn map_optional(&self, inner: &str) -> String
fn map_optional(&self, inner: &str) -> String
Map an optional type (e.g., Option<T>, T | undefined).
Sourcefn map_result(&self, ok: &str, err: &str) -> String
fn map_result(&self, ok: &str, err: &str) -> String
Map a Result type (Rust: Result<T, E>, TS: T, Go: (T, error)).
Provided Methods§
Sourcefn map_ref(&self, inner: &str) -> String
fn map_ref(&self, inner: &str) -> String
Map a reference type (Rust: &T, others usually no-op).
Sourcefn map_ref_mut(&self, inner: &str) -> String
fn map_ref_mut(&self, inner: &str) -> String
Map a mutable reference type (Rust: &mut T).
Sourcefn map_generic(&self, base: &str, args: &[String]) -> String
fn map_generic(&self, base: &str, args: &[String]) -> String
Map a generic type with arguments.
Sourcefn render_type(&self, ty: &TypeRef) -> String
fn render_type(&self, ty: &TypeRef) -> String
Render a complete TypeRef to a string.