pub struct Generator { /* private fields */ }Expand description
Configure code generation, then choose one explicit schema source.
Custom Rust syntax is checked before writing output. Generated structs preserve SQL names with Serde attributes. Additional derives and attributes apply to data types, not markers.
Implementations§
Source§impl Generator
impl Generator
pub fn new() -> Self
Sourcepub fn schemas(
self,
schemas: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn schemas( self, schemas: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Replace the default public selection with these schemas.
Sourcepub fn schema(self, schema: impl Into<String>) -> Self
pub fn schema(self, schema: impl Into<String>) -> Self
Select a single schema instead of the default public.
Sourcepub fn prelude(self, prelude: impl Into<String>) -> Self
pub fn prelude(self, prelude: impl Into<String>) -> Self
Add Rust items or imports before the generated schema modules.
Sourcepub fn derive(self, derive: impl Into<String>) -> Self
pub fn derive(self, derive: impl Into<String>) -> Self
Add a derive path, such as ::typed_builder::TypedBuilder.
Sourcepub fn attribute(self, attribute: impl Into<String>) -> Self
pub fn attribute(self, attribute: impl Into<String>) -> Self
Add an outer attribute, including its #[...] delimiters.
Sourcepub fn type_attribute(
self,
generated_type: impl Into<String>,
attribute: impl Into<String>,
) -> Self
pub fn type_attribute( self, generated_type: impl Into<String>, attribute: impl Into<String>, ) -> Self
Add an attribute to one generated data type.
Paths use generated Rust names, for example public.tables.messages.Insert.
Unknown paths fail generation instead of silently ignoring customization.
Sourcepub fn type_override(
self,
postgres_type: impl Into<String>,
rust_type: impl Into<String>,
) -> Self
pub fn type_override( self, postgres_type: impl Into<String>, rust_type: impl Into<String>, ) -> Self
Map a qualified SQL type to a Rust type that matches the PostgREST JSON representation.
Sourcepub fn runtime_path(self, path: impl Into<String>) -> Self
pub fn runtime_path(self, path: impl Into<String>) -> Self
Set the runtime module path when the client dependency has a Cargo alias.