#cyberfabric-modkit #proc-macro #cyberfabric

macro cf-modkit-db-macros

Proc-macro derives for modkit-db secure ORM layer

36 releases (5 breaking)

Uses new Rust 2024

0.6.2 Mar 30, 2026
0.6.1 Mar 26, 2026
0.5.11 Mar 23, 2026
0.4.1 Mar 9, 2026
0.1.5 Jan 28, 2026

#15 in #cyberfabric-modkit

Download history 51/week @ 2026-01-21 38/week @ 2026-01-28 95/week @ 2026-02-04 82/week @ 2026-02-11 98/week @ 2026-02-18 94/week @ 2026-02-25 252/week @ 2026-03-04 155/week @ 2026-03-11 180/week @ 2026-03-18 49/week @ 2026-03-25 54/week @ 2026-04-01 110/week @ 2026-04-08

407 downloads per month
Used in 3 crates (2 directly)

Apache-2.0

36KB
588 lines

ModKit DB Macros

Procedural macros used by modkit-db.

Cargo package name: cf-modkit-db-macros Crate name (Rust import): modkit_db_macros

Macros

#[derive(Scopable)]

Implements modkit_db::secure::ScopableEntity for a SeaORM entity.

Put the derive on the DeriveEntityModel Model struct, together with a #[secure(...)] attribute.

use modkit_db_macros::Scopable;
use sea_orm::entity::prelude::*;
use uuid::Uuid;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Scopable)]
#[sea_orm(table_name = "users")]
#[secure(tenant_col = "tenant_id", resource_col = "id", no_owner, no_type)]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: Uuid,
    pub tenant_id: Uuid,
    pub email: String,
}

#[secure(...)] rules

Either:

  • Global entity

    • #[secure(unrestricted)]
    • Must not be combined with any other secure settings.

Or: specify all scope dimensions explicitly (no defaults):

  • Tenant

    • tenant_col = "..." or no_tenant
  • Resource

    • resource_col = "..." or no_resource
  • Owner

    • owner_col = "..." or no_owner
  • Type

    • type_col = "..." or no_type

*_col values are column names. The macro maps snake_case to the SeaORM column variant using UpperCamelCase (e.g. tenant_id -> TenantId).

Notes

OData derive macros (e.g. ODataFilterable) are not exported from this crate.

License

Licensed under Apache-2.0.

Dependencies

~175–540KB
~12K SLoC