Macro specta::collect_types
source · macro_rules! collect_types { (type_map: $type_map:ident, $($command:path),* $(,)?) => { ... }; ($($command:path),* $(,)?) => { ... }; }
Available on crate feature
functions
only.Expand description
Collects function types into a Vec
,
and all downstream types into a TypeDefs
instance.
Specifying a type_map
argument allows a custom TypeDefs
to be used.
Examples
use specta::*;
#[specta]
fn some_function(name: String, age: i32) -> bool {
true
}
fn main() {
// `type_defs` is created internally
let (functions, type_defs) = functions::collect_types![some_function].unwrap();
let custom_type_defs = TypeDefs::default();
// `type_defs` is provided.
// This can be used when integrating multiple specta-enabled libraries.
let (functions, custom_type_defs) = functions::collect_types![
type_map: custom_type_defs,
some_function
].unwrap();
}