Module :: mod_interface
Protocol of modularity unifying interface of a module and introducing layers.
Basic use-case.
Library file with code inner.rs
:
pub
//
mod_interface!
Main file that generates modules and namespaces main.rs
:
use mod_interface;
//
//
mod_interface!
It generates code :
use mod_interface;
//
//
/// Inner.
/// Protected namespace of the module.
pub use *;
/// Orphan namespace of the module.
/// Exposed namespace of the module.
/// Prelude to use essentials: `use my_module::prelude::*`.
To debug module interface use directive #![ debug ]
in macro mod_interface
. Let's update the main file of the example :
!
mod_interface
The directive adds stdout output with module structure. For the case above output looks :
= original :
#! [debug] /// Inner.
layer inner ;
= result :
#[doc = " Inner."]
pub mod inner ;
#[doc(inline)]
pub use protected :: * ;
#[doc = r" Protected namespace of the module."]
pub mod protected
{
#[doc(inline)]
pub use super :: orphan :: * ;
#[doc(inline)]
#[doc = " Inner."]
pub use super :: inner :: orphan :: * ;
}
#[doc = r" Orphan namespace of the module."]
pub mod orphan
{
#[doc(inline)]
pub use super :: exposed :: * ;
}
#[doc = r" Exposed namespace of the module."]
pub mod exposed
{
#[doc(inline)]
pub use super :: prelude :: * ;
#[doc(inline)]
#[doc = " Inner."]
pub use super :: inner :: exposed :: * ;
}
#[doc = r" Prelude to use essentials: `use my_module::prelude::*`."]
pub mod prelude
{
#[doc(inline)]
#[doc = " Inner."]
pub use super :: inner :: prelude :: * ;
}
Full sample see at sample directory.
To add to your project
Try out from the repository