raisfast-derive 0.1.0

Procedural macros for raisfast — CRUD, Where DSL, and schema generation
Documentation
  • Coverage
  • 100%
    22 out of 22 items documented0 out of 21 items with examples
  • Size
  • Source code size: 144.8 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 807.03 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • RaisFast/raisfast
    12 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • snkzhong

raisfast-derive

Proc-macro crate for the raisfast blog/CMS system.

Provides two categories of macros:

1. Derive macros

  • #[derive(EventMeta)] — auto-generates name(), display_name(), table() methods on event enums, with per-variant #[event(table = "...", name = "...", dynamic)] attributes.

2. Attribute macros

  • #[aspect_service(entity = "...", model = Type)] — generates a service struct with before/after hooks that delegate to the aspect engine, and auto-emits domain events.

3. Bang macros (SQL CRUD helpers)

All macros use optional tenant: expr named section for tenant filtering. When provided, the SQL includes AND tenant_id = ? at runtime.

Macro SQL operation
crud_delete! DELETE FROM ... WHERE WhereExpr
crud_insert! INSERT INTO ... (...) VALUES (...)
crud_scalar! SELECT scalar ...
crud_query! SELECT ... via query_as
crud_find! SELECT cols FROM ... WHERE WhereExprfetch_optional
crud_find_one! same → fetch_one
crud_find_all! same → fetch_all
crud_list! SELECT cols FROM ...fetch_all (no WHERE)
crud_update! UPDATE ... SET ... WHERE WhereExpr
crud_count! SELECT COUNT(*) FROM ... WHERE WhereExpr
crud_exists! SELECT EXISTS(SELECT 1 ... WHERE WhereExpr)
crud_query_paged! paginated data + COUNT
crud_join_paged! paginated JOIN + COUNT
crud_resolve_id! SELECT id FROM table WHERE id = ?Option<i64>
crud_resolve_ids! SELECT id FROM table WHERE id IN (...)Vec<i64> (validates all exist)

Schema validation

  • check_schema!("table", "col1", "col2", ...) — compile-time validation only; expands to nothing. Emits a compile error if the table or any column is missing.

Architecture notes

  • schema.rs — parses schema.sqlite.sql + tenantable.sqlite.sql at compile time into a Schema struct. Used for table/column validation and for generating explicit column lists (replacing SELECT *).
  • crud.rs — all CRUD macro implementations + input parsing structs.
  • event_meta.rs#[derive(EventMeta)].
  • aspect_service.rs#[aspect_service].