Skip to main content

Crate siderite_macros

Crate siderite_macros 

Source
Expand description

Procedural macros for siderite.

These macros are re-exported by the siderite facade crate; generated code only refers to ::siderite::... paths, so depend on siderite, not on this crate directly.

  • #[get("/path", ...)], #[post(..)], #[put(..)], #[patch(..)], #[delete(..)], #[head(..)], #[options(..)], #[ws(..)]: attach a route (and its OpenAPI metadata) to an async fn handler.
  • routes![a, module::b]: collect the routes generated by those attributes.
  • #[derive(Schema)]: JSON Schema / OpenAPI schema generation compatible with the common serde attributes, plus the matching Dump.
  • #[derive(Validate)]: request validation (coercion, constraints, aliases, string transforms) generated from the same attributes.
  • #[derive(Model)]: ORM model metadata, typed field handles, the Model implementation and relation accessors.
  • #[model_hooks]: field/model validators, computed fields and serializers on an inherent impl block.

Macros§

routes
Collect the routes of handlers annotated with the route attributes.

Attribute Macros§

delete
Route DELETE requests to the annotated async fn. See get.
get
Route GET requests to the annotated async fn.
head
Route HEAD requests to the annotated async fn. See get.
model_hooks
Turn an inherent impl block into a ModelHooks implementation.
options
Route OPTIONS requests to the annotated async fn. See get.
patch
Route PATCH requests to the annotated async fn. See get.
post
Route POST requests to the annotated async fn. See get.
put
Route PUT requests to the annotated async fn. See get.
receiver
Turn an async fn into an ORM signal receiver: #[receiver(post_save, model = User)].
ws
Route a WebSocket upgrade (a GET request) to the annotated async fn. See get.

Derive Macros§

Model
Derive siderite::orm::Model: static column metadata, one typed Field<Self, T> constant per field (User::name), to_values / from_row, and the relation accessors.
Schema
Derive siderite::validation::Schema (JSON Schema / OpenAPI 3.1) and the matching siderite::validation::Dump.
Validate
Derive siderite::validation::Validate.