Procedural macro implementation for component model patterns.
component_model_meta is the proc-macro companion crate for component_model. It provides derive macros for component-based programming patterns, enabling automatic generation of component assignment, conversion, and composition code.
Important: This crate should not be used directly. Use the component_model crate which re-exports this functionality with supporting types.
component_model_meta is responsible for providing procedural macro implementations that generate component-related trait implementations for structs.
#[derive(ComponentModel)]macro: Generate component model implementation#[derive(Components)]macro: Generate component collection#[derive(ComponentFrom)]macro: Generate component conversion#[derive(ComponentAssign)]macro: Generate component assignment#[derive(ComponentsAssign)]macro: Generate bulk component assignment#[derive(FromComponents)]macro: Generate construction from components
- Runtime types: Provided by
component_model_types - User-facing API: Use
component_modelcrate instead - Non-struct types: Focused on struct components
- Upstream: Uses
macro_toolsfor syntax parsing - Downstream: Re-exported by
component_modelcrate - Compile-time only: Macro expansion only
component_model_meta/
├── src/
│ └── lib.rs # Proc-macro entry points
├── Cargo.toml
├── readme.md
└── spec.md
Generate component model for struct.
use component_model::ComponentModel;
#[derive(ComponentModel)]
struct Config
{
host: String,
port: u16,
}Generate component assignment trait.
Generate bulk component assignment.
Generate conversion from component.
Generate construction from components.
| Feature | Default | Description |
|---|---|---|
enabled |
✓ | Enable the crate |
full |
✓ | All features |
derive_component_model |
✓ | ComponentModel derive |
derive_components |
✓ | Components derive |
derive_component_from |
✓ | ComponentFrom derive |
derive_component_assign |
✓ | ComponentAssign derive |
derive_components_assign |
✓ | ComponentsAssign derive |
derive_from_components |
✓ | FromComponents derive |
| Dependency | Purpose |
|---|---|
macro_tools |
Syntax parsing utilities |
component_model_types |
Runtime type definitions |
convert_case |
Identifier case conversion |
component_model- Re-exports this crate's macros
Component-based programming enables:
- Composition over inheritance
- Fine-grained data access
- Flexible struct construction
| Crate | Relationship |
|---|---|
component_model |
Parent facade crate |
component_model_types |
Runtime type definitions |
macro_tools |
Upstream syntax utilities |