pub struct PythonMapper {
pub file_style: FileStyle,
}Expand description
Python language mapper.
Generates Pydantic v2 BaseModel classes from Rust structs and
Python Enum / Union types from Rust enums.
Fields§
§file_style: FileStyleFile naming style (default: snake_case)
Implementations§
Source§impl PythonMapper
impl PythonMapper
pub fn new() -> Self
pub fn with_file_style(self, style: FileStyle) -> Self
Trait Implementations§
Source§impl Default for PythonMapper
impl Default for PythonMapper
Source§impl TypeMapper for PythonMapper
impl TypeMapper for PythonMapper
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 file_naming(&self, type_name: &str) -> String
fn file_naming(&self, type_name: &str) -> String
Naming convention for output files. Read more
Source§fn map_type(&self, ty: &TypeKind) -> String
fn map_type(&self, ty: &TypeKind) -> String
Map any
TypeKind to the target language string. Read moreFile footer content (if needed). Default: empty.
Source§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 PythonMapper
impl RefUnwindSafe for PythonMapper
impl Send for PythonMapper
impl Sync for PythonMapper
impl Unpin for PythonMapper
impl UnsafeUnpin for PythonMapper
impl UnwindSafe for PythonMapper
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