Expand description
Procedure macro for Message formatting in ractor_cluster
. This implements
the ractor::Message
trait for non-serializable and serializable messages automatically.
note: rampant use of cargo expand
was used in the making of this macro. E.g.
cargo expand -p ractor_playground 2>&1 > expand.tmp.rs
Caveats:
- Non-serializable macros are simply getting
impl ractor::Message for MyStructOrEnum
added onto their struct - Serializable messages have to have a few formatting requirements.
a. All variants of the enum will be numbered based on their lexicographical ordering, which is sent over-the-wire in order to decode which
variant was called. This is the
index
field on any variant ofractor::message::SerializedMessage
b. All properties of the message MUST implement theractor::BytesConvertable
trait which means they supply ato_bytes
andfrom_bytes
method. Many types are pre-done for you inractor
’s definition of the trait c. For RPCs, the LAST argument must be the reply channel. Additionally the type of message the channel is expecting back must also implementractor::BytesConvertable
d. Lastly, for RPCs, they should additionally be decorated with#[rpc]
on each variant’s definition. This helps the macro identify that it is an RPC and will need port handler
Derive Macros§
- Derive
ractor::Message
for messages that can be sent over the network - Derive
ractor::Message
for messages that are local-only