embedded_command_macros/lib.rs
1use proc_macro::TokenStream;
2
3mod dispatch_bundle;
4mod serac;
5
6/// Transform attached enum into a "bundle".
7///
8/// *What is a bundle?*
9///
10/// Bundles are used to accomplish dynamic dispatch in resource constrained systems (no_std).
11/// A bundle can hold a finite number of types that implement a common trait.
12/// The size of the bundle is known at compile time and equal to the size of the largest type in the bundle.
13/// Bundles are useful for type-erasure when transporting multiple types pseudo-heterogeneously.
14#[proc_macro_attribute]
15pub fn bundle(attr: TokenStream, item: TokenStream) -> TokenStream {
16 dispatch_bundle::bundle(attr, item)
17}
18
19/// Generates the implementation block for conforming to `SerializeIter` of the "vanilla" flavor.
20///
21/// # Note
22///
23/// Requires `serac` to be in scope with that name.
24#[proc_macro_derive(SerializeIter)]
25pub fn impl_serialize_iter_vanilla(item: TokenStream) -> TokenStream {
26 serac::vanilla::serialize_iter(item)
27}
28
29/// Generates the implementation block for conforming to `SerializeBuf` of the "vanilla" flavor.
30///
31/// As of now, generic types *cannot* implement `SerializeBuf` on stable.
32///
33/// # Note
34///
35/// Requires `serac` to be in scope with that name.
36#[proc_macro_derive(SerializeBuf)]
37pub fn impl_serialize_buf_vanilla(item: TokenStream) -> TokenStream {
38 serac::vanilla::impl_serialize_buf(item)
39}