Skip to main content

Crate reef_macros

Crate reef_macros 

Source
Expand description

Proc-macro impls for the reef crate.

#[reef::table] is an outer attribute macro applied to a struct. It does two jobs:

  1. Strips our marker sub-attributes before re-emitting the struct, so the compiler doesn’t choke on attributes it doesn’t know about. The sub-attributes are: #[column(...)] on fields, and #[index(...)], #[primary_key(...)], #[foreign_key(...)], #[check(...)] on the struct.
  2. Validates that those sub-attributes (and the macro’s own args) use known keys, failing fast with a clear error pointing at the bad span.

It does NOT generate any code today. The struct is re-emitted essentially unchanged. cargo reef db:push parses the original schema.rs source file with syn separately and reads the (still-present) attributes there.

Users don’t depend on this crate directly — it’s re-exported by reef.

Attribute Macros§

table
Mark a struct as a SQL table.