stately-derive 0.3.0

Procedural macros for stately state management
Documentation

🏰 Stately Derive

Crates.io Documentation License

Procedural macros for the Stately state management framework

This crate provides the procedural macros used by stately. You typically don't need to depend on this crate directly - it's re-exported by the main stately crate.

Macros

#[stately::entity]

Derives the StateEntity trait for a struct, enabling it to be managed by Stately.

#[stately::entity]
#[derive(Clone, serde::Serialize, serde::Deserialize)]
pub struct Pipeline {
    pub name: String,
}

Attributes:

  • #[stately(singleton)] - Mark as singleton entity
  • #[stately(name_field = "field_name")] - Use different field for name
  • #[stately(description_field = "field_name")] - Use field for description
  • #[stately(description = "text")] - Static description

#[stately::state]

Generates application state with entity collections and CRUD operations.

#[stately::state]
pub struct AppState {
    pipelines: Pipeline,
    sources: SourceConfig,
}

API Generation:

#[stately::state(api = ["axum"])]
pub struct AppState {
    pipelines: Pipeline,
}

Generates:

  • REST API handlers
  • OpenAPI documentation
  • Type-safe request/response types
  • Router and state wrappers

Documentation

For complete documentation and examples, see the stately crate.

License

Licensed under the Apache License, Version 2.0. See LICENSE for details.