Skip to main content

Module type_utils

Module type_utils 

Source

Functions§

collection_method_name
Convert a collection name to a snake_case method name. e.g. “users” -> “users”, “post_feed” -> “post_feed”
collection_struct_name
Convert a collection name to its singular PascalCase struct name. e.g. “users” -> “User”, “posts” -> “Post”, “comments” -> “Comment”
enum_type_name
Generate an enum name from collection singular + field name. e.g. (“users”, “role”) -> “UserRole”
enum_variant_ident
Convert a string to a valid Rust identifier, preserving original casing for enum variants.
field_base_type
Get the base Rust type (without Option wrapping) for a field.
field_to_rust_type
Map a schema field to its Rust type as a TokenStream. collection_name is used for naming generated enums. known_types is the set of reusable type names from the schema.
partial_struct_name
Generate a partial struct name. e.g. “User” -> “UserPartial”
ref_enum_name
Generate a polymorphic ref enum name from field name. e.g. “parent” -> “ParentRef”
safe_field_ident
Check if a field name is a Rust keyword and needs raw identifier syntax.
singularize
Naive singularization of English words.
view_params_name
Generate a view params struct name. e.g. “post_comments” -> “PostCommentsParams”
view_row_name
Generate a view row struct name. e.g. “post_feed” -> “PostFeedRow”