Procedural macro implementation for module interface organization.
mod_interface_meta is the proc-macro companion crate for mod_interface. It provides the mod_interface! macro that generates standardized module structures with namespace layers (own, orphan, exposed, prelude).
Important: This crate should not be used directly. Use the mod_interface crate which re-exports this functionality with documentation and utilities.
mod_interface_meta is responsible for providing the procedural macro implementation that generates module organization code from the mod_interface! DSL.
mod_interface!macro: Parse and expand module interface definitions- Namespace generation: Create own/orphan/exposed/prelude modules
- Layer handling: Process
layerdirectives for submodules - Re-export generation: Generate
pub usestatements
- Runtime behavior: Pure compile-time code generation
- User-facing API: Use
mod_interfacecrate instead - Module content: Only organizes structure, doesn't generate logic
- Upstream: Uses
macro_toolsfor syntax parsing - Downstream: Re-exported by
mod_interfacecrate - Compile-time only: No runtime dependencies
mod_interface_meta/
├── src/
│ └── lib.rs # Proc-macro entry point
├── Cargo.toml
├── readme.md
└── spec.md
// Input
mod_interface!
{
own use my_type;
layer submodule;
}
// Generates (conceptual):
mod own { pub use super::my_type; }
mod orphan { pub use super::own::*; }
mod exposed { pub use super::orphan::*; }
mod prelude { }
pub use exposed::*;
// Plus submodule integrationDefine module interface with namespace layers.
use mod_interface::mod_interface;
mod private
{
pub struct MyType;
pub fn my_function() {}
}
mod_interface!
{
// Export to own namespace
own use private::MyType;
// Export to exposed namespace (broader visibility)
exposed use private::my_function;
// Include submodule as layer
layer submodule;
}own use: Export to own namespace (most restrictive)orphan use: Export to orphan namespaceexposed use: Export to exposed namespaceprelude use: Export to prelude namespace (broadest)layer: Include submodule with its own namespace hierarchy
| Feature | Default | Description |
|---|---|---|
enabled |
✓ | Enable the crate |
full |
- | All features |
| Dependency | Purpose |
|---|---|
macro_tools |
Syntax parsing utilities |
derive_tools |
Derive macro support |
mod_interface- Re-exports this crate's macros
The four-layer namespace system provides:
- own: Internal-only exports
- orphan: Semi-public exports
- exposed: Default public exports
- prelude: Convenience re-exports
This enables fine-grained control over API visibility.
The layer directive allows hierarchical module composition where submodules have their own namespace structure that integrates with the parent.
| Crate | Relationship |
|---|---|
mod_interface |
Parent facade crate |
macro_tools |
Upstream syntax utilities |