macro_rules! plugin_output {
(
$(#[$meta:meta])*
$vis:vis fn $name:ident,
input: $Input:ty,
output: $Output:ty,
model: $ModelType:ty,
context: $ContextType:ty $(,)?
) => { ... };
(
$(#[$meta:meta])*
$vis:vis fn $name:ident,
input: mut $Input:ty,
output: $Output:ty,
model: $ModelType:ty,
context: $ContextType:ty $(,)?
) => { ... };
(
$(#[$meta:meta])*
$vis:vis fn $name:ident,
input: $Input:ty,
output: $Output:ty,
$(borrow: [$($borrow_lt:lifetime)* $(,)?],)?
root: $Root:ident,
family: $Family:ty,
child: $Child:ident,
context: $ContextType:ty $(,)?
) => { ... };
(
$(#[$meta:meta])*
$vis:vis fn $name:ident,
input: mut $Input:ty,
output: $Output:ty,
$(borrow: [$($borrow_lt:lifetime)* $(,)?],)?
root: $Root:ident,
family: $Family:ty,
child: $Child:ident,
context: $ContextType:ty $(,)?
) => { ... };
}Expand description
Generates a strongly-typed associated function that executes a plugin model and returns its computed output.
The macro expands to a function which:
- Instantiates the plugin model using
Default - Constructs the execution context via
ModelContext::context - Wraps the input, model, and context into the appropriate execution source
- Executes the model and returns the resulting output
This removes boilerplate wiring of model construction, context resolution, and execution, while preserving full compile-time type safety.
Exactly one of the following must be specified:
model-> directly executes a concrete plugin modelroot+family+child-> resolves a model from a plugin family
Exactly one of:
input:-> immutable execution contract (PurePluginModel)input: mut-> mutable execution contract (MutablePluginModel)
Optional:
borrowdeclares function-level generic parameters for input and output specialization in family models.
§Syntax
§Immutable Concrete Model
ⓘ
plugin_output! {
pub fn run_model, // Required: function visibility and name to generate
input: MyInput, // Required: immutable input type
output: MyOutput, // Required: output type produced by the model
model: MyModel, // Required: concrete immutable plugin model type
context: MyContext, // Required: context provider implementing ModelContext
}Expands to:
pub fn run_model(input: MyInput) -> MyOutput { ... }
§Mutable Concrete Model
ⓘ
plugin_output! {
pub fn run_model_mut, // Required: function visibility and name to generate
input: mut MyInput, // Required: mutable input type
output: MyOutput, // Required: output type produced by the model
model: MyModel, // Required: concrete mutable plugin model type
context: MyContext, // Required: context provider implementing ModelContext
}§Immutable Family-Selected Model
ⓘ
plugin_output! {
pub fn run_family, // Required: function visibility and name to generate
input: MyInput<'a>, // Required: immutable input type
output: MyOutput, // Required: output type produced by the model
borrow: ['a], // Optional: function-level liftimes over input/output
root: MyFamilyRoot, // Required: plugin family root trait
family: MyFamily, // Required: concrete plugin family type
child: MyChildMarker, // Required: child model identifier within the family
context: MyContext, // Required: context provider implementing ModelContext
}§Mutable Family-Selected Model
ⓘ
plugin_output! {
pub fn run_family_mut, // Required: function visibility and name to generate
input: mut MyInput, // Required: mutable input type
output: MyOutput<'a>, // Required: output type produced by the model
borrow: ['a], // Optional: function-level liftimes over input/output
root: MyFamilyRoot, // Required: plugin family root trait
family: MyFamily, // Required: concrete plugin family type
child: MyChildMarker, // Required: child model identifier within the family
context: MyContext, // Required: context provider implementing ModelContext
}§Semantics
modelform executes a fixed concrete plugin model.root+family+childform defers model selection to the plugin family, where the concrete model is resolved at compile time using the(Input, Context, Output, Family)signature.Contextacts as the nominal discriminator within a family, whileInputandOutputare validated once concretely resolved at the call site.- Mutable variants may mutate the input in-place, but resolution remains entirely static through trait bounds.
- All resolution is performed at compile time; no dynamic dispatch is used.
§Input / Output Constraints
-
Plugin models (immutable & mutable) use non-GAT types only
- No generics
- No lifetime-based types (no GATs)
-
Plugin families may use lifetimes only
- Enabled via
borrow: ['a] - Type generics are not supported
- Enabled via
Model -> concrete types only
Family -> supports lifetimes only