Macro pliron::decl_type_interface
source ยท macro_rules! decl_type_interface { ($(#[$docs:meta])* $intr_name:ident { $($tt:tt)* }) => { ... }; ($(#[$docs:meta])* $intr_name:ident: $($dep:path),* { $($tt:tt)* }) => { ... }; }
Expand description
Declare a Type interface, which can be implemented by any Type.
If the interface requires any other interface to be already implemented, they can be specified. The trait to which this interface is expanded will have the dependent interfaces as super-traits, in addition to the Type trait itself, which is always automatically added as a super-trait.
When a Type is verified, its interfaces are also automatically verified, with guarantee that a super-interface is verified before an interface itself is.
Example: Here Super1 and Super2 are super interfaces for the interface MyTypeIntr.
decl_type_interface!(
Super1 {
fn verify(_type: &dyn Type, _ctx: &Context) -> Result<()>
where
Self: Sized,
{
Ok(())
}
}
);
decl_type_interface!(
Super2 {
fn verify(_type: &dyn Type, _ctx: &Context) -> Result<()>
where
Self: Sized,
{
Ok(())
}
}
);
decl_type_interface!(
/// MyTypeIntr is my best type interface.
MyTypeIntr: Super1, Super2 {
fn verify(_type: &dyn Type, _ctx: &Context) -> Result<()>
where
Self: Sized,
{
Ok(())
}
}
);