pub struct TypeScriptMapper {
pub readonly: bool,
pub file_style: FileStyle,
}Expand description
TypeScript language mapper.
Generates TypeScript interfaces from Rust structs and discriminated unions from enums.
Fields§
§readonly: boolWhether all fields should be readonly
file_style: FileStyleFile naming style (default: kebab-case)
Implementations§
Source§impl TypeScriptMapper
impl TypeScriptMapper
pub fn new() -> Self
pub fn with_readonly(self, readonly: bool) -> Self
pub fn with_file_style(self, style: FileStyle) -> Self
Trait Implementations§
Source§impl Default for TypeScriptMapper
impl Default for TypeScriptMapper
Source§impl TypeMapper for TypeScriptMapper
impl TypeMapper for TypeScriptMapper
Source§fn map_primitive(&self, ty: &PrimitiveType) -> String
fn map_primitive(&self, ty: &PrimitiveType) -> String
Map a Rust primitive type to the target language’s equivalent. Read more
Source§fn map_option(&self, inner: &TypeKind) -> String
fn map_option(&self, inner: &TypeKind) -> String
Map an
Option<T> type to the target language. Read moreSource§fn map_vec(&self, inner: &TypeKind) -> String
fn map_vec(&self, inner: &TypeKind) -> String
Map a
Vec<T> type to the target language. Read moreSource§fn map_hashmap(&self, key: &TypeKind, value: &TypeKind) -> String
fn map_hashmap(&self, key: &TypeKind, value: &TypeKind) -> String
Map a
HashMap<K, V> type to the target language. Read moreSource§fn map_tuple(&self, elements: &[TypeKind]) -> String
fn map_tuple(&self, elements: &[TypeKind]) -> String
Map a tuple type
(A, B, ...) to the target language.Source§fn map_named(&self, name: &str) -> String
fn map_named(&self, name: &str) -> String
Map a named custom type (reference to another struct or enum). Read more
Source§fn emit_struct(&self, def: &StructDef) -> String
fn emit_struct(&self, def: &StructDef) -> String
Render a complete struct as target language source code.
Source§fn emit_enum(&self, def: &EnumDef) -> String
fn emit_enum(&self, def: &EnumDef) -> String
Render a complete enum as target language source code.
Source§fn file_header(&self, type_name: &str) -> String
fn file_header(&self, type_name: &str) -> String
File header content (auto-generated comment, import statements, pragmas).
Source§fn file_extension(&self) -> &str
fn file_extension(&self) -> &str
File extension for the output file (without the leading dot).
Source§fn emit_imports(&self, def: &TypeDef) -> String
fn emit_imports(&self, def: &TypeDef) -> String
Generate import statements for types referenced by this type definition. Read more
Source§fn file_naming(&self, type_name: &str) -> String
fn file_naming(&self, type_name: &str) -> String
Naming convention for output files. Read more
File footer content (if needed). Default: empty.
Source§fn map_generic(&self, name: &str, params: &[TypeKind]) -> String
fn map_generic(&self, name: &str, params: &[TypeKind]) -> String
Map a generic type
Name<A, B> to the target language. Read moreSource§fn map_type(&self, ty: &TypeKind) -> String
fn map_type(&self, ty: &TypeKind) -> String
Map any
TypeKind to the target language string. Read moreSource§fn emit_type_def(&self, def: &TypeDef) -> String
fn emit_type_def(&self, def: &TypeDef) -> String
Emit a complete
TypeDef (struct or enum) as target language source code. Read moreSource§fn output_filename(&self, type_name: &str) -> String
fn output_filename(&self, type_name: &str) -> String
Get the full output filename for a type.
Auto Trait Implementations§
impl Freeze for TypeScriptMapper
impl RefUnwindSafe for TypeScriptMapper
impl Send for TypeScriptMapper
impl Sync for TypeScriptMapper
impl Unpin for TypeScriptMapper
impl UnsafeUnpin for TypeScriptMapper
impl UnwindSafe for TypeScriptMapper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more