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.
Sourcepub fn not_null(
self,
target: impl Into<String>,
fields: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn not_null( self, target: impl Into<String>, fields: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Assert non-null fields on a view Row, composite, or RPC Record. Unknown targets and SQL field names fail generation.
Sourcepub fn column_type(
self,
target: impl Into<String>,
rust_type: impl Into<String>,
) -> Self
pub fn column_type( self, target: impl Into<String>, rust_type: impl Into<String>, ) -> Self
Override one SQL column’s base type, preserving nullability and omission.
Accepts public.table.column or public.tables.table.column.
Sourcepub fn json_type(
self,
target: impl Into<String>,
rust_type: impl Into<String>,
) -> Self
pub fn json_type( self, target: impl Into<String>, rust_type: impl Into<String>, ) -> Self
Decode a JSON field, RPC argument or return using a custom Serde type. SQL arrays, nullability, and set-returning wrappers remain intact.
Sourcepub const fn reexport_macros(self) -> Self
pub const fn reexport_macros(self) -> Self
Export crate-local select! and key! wrappers with the runtime path filled.
Include the generated bindings at the schema crate’s root.
Sourcepub fn relationship_alias(
self,
target: impl Into<String>,
alias: impl Into<String>,
) -> Self
pub fn relationship_alias( self, target: impl Into<String>, alias: impl Into<String>, ) -> Self
Add an alias for one canonical qualified relationship marker.
For example public.tables.orders.relationships.orders_customer_fkey.
Sourcepub const fn strict_args(self) -> Self
pub const fn strict_args(self) -> Self
Require non-default RPC inputs unless explicitly marked nullable.
Sourcepub fn strict_args_for(self, target: impl Into<String>) -> Self
pub fn strict_args_for(self, target: impl Into<String>) -> Self
Apply strict RPC input contracts to one generated function module.