Skip to main content

Crate ractor_cluster_derive

Crate ractor_cluster_derive 

Source
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:

  1. Non-serializable macros are simply getting impl ractor::Message for MyStructOrEnum added onto their struct
  2. 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 of ractor::message::SerializedMessage b. All properties of the message MUST implement the ractor::BytesConvertable trait which means they supply a to_bytes and from_bytes method. Many types are pre-done for you in ractor’s definition of the trait c. For RPCs, exactly one field must be an RpcReplyPort<T> (at any position). Additionally the type of message the channel is expecting back must also implement ractor::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 e. Both tuple-style (Variant(A, B)) and struct-style (Variant { a: A, b: B }) fields are supported

Derive Macros§

RactorClusterMessage
Derive ractor::Message for messages that can be sent over the network
RactorMessage
Derive ractor::Message for messages that are local-only