Derive Macro Communicator
#[derive(Communicator)]
{
// Attributes available to this derive:
#[CommunicatorCorePath]
#[Comm]
}
Available on crate feature
chili
only.Expand description
Derives the Communicator trait.
This macro supports the build_communicator! macro. It is useful when a complex communicator struct should automatically be generated at compile time. By deriving existing functionality from fields, we can make sure to avoid code duplication. Furthermore, this macro can be used in the future to manually construct communicators for new backends.
We use the ChannelComm struct which has a working implementation of the Communicator trait.
use cellular_raza_core::{
backend::chili::{ChannelComm, Communicator},
};
// Define a new struct from which we want
// to derive the Communicator functionality
// and use the #[derive(Communicator)] macro.
#[derive(Communicator)]
#[CommunicatorCorePath(cellular_raza_core)]
struct NewCommunicator {
// The #[Comm(I, T)] field symbolizes that this field
// as an implementation of the Communicator<I, T> trait
// which should be derived.
#[Comm(usize, String)]
old_comm: ChannelComm<usize, String>,
}
Note that when importing from the cellular_raza
crate, every cellular_raza_core
needs to be replaced by cellular_raza::core
.