Skip to main content

Module parse

Module parse 

Source
Expand description

syn-based parsing of #[derive(Table)] structs and #[derive(DbEnum)] enums into the schema model. This is the only place #[orm(...)] attribute semantics are defined — the derive macro and the CLI both call into here, so they can never drift apart.

Functions§

enum_from_item
Parse one #[derive(DbEnum)] enum. Variants must be unit variants; the stored value is the snake_case variant name.
has_derive
Does #[derive(...)] on this item mention name (by last path segment, so fse_orm::Table matches too)?
native_sql_type
Map a Rust type to its native SQLite storage type. Anything not listed here needs #[orm(json)] or a DbEnum.
parse_sources
Parse a whole tables folder: sources is (file name, file content), where the file name is only used in error messages. Two passes — enums first so struct fields can resolve them — then foreign keys are resolved from struct names to table names.
pluralize
Naive English pluralization for default table names — struct Category becomes table categories. Wrong for irregular nouns; override with #[orm(table = "...")].
table_from_struct
Parse one #[derive(Table)] struct.
to_snake_case