Derive Macro mesh::MeshPayload
#[derive(MeshPayload)]
{
// Attributes available to this derive:
#[mesh]
}
Expand description
The derive macro for MeshPayload
.
This allows you to automatically generate serialization and deserialization code for sending objects via a mesh channel.
MeshPayload
can be derived for any struct or enum where all the fields’
types implement MeshPayload
.
Note that currently there is no way to specify the field numbers used in the message encoding, and there is no way to mark a field as non-optional. This means that inserting or removing a field in a struct will break any existing binaries using that struct. Similar problems exist with updating an enum. For now, the best advice is to not use this encoding for messages that must be durable.
§Attributes
The #[mesh]
attribute can be used to customize the generated code:
#[mesh(bound = "T: MyTrait")]
allows replacing the default trait
bounds with a custom where clause. That is, normally the type:
#[derive(MeshPayload)]
struct Foo<T: Trait>(T::Bar);
would have a T: MeshPayload
constraint on the generated MeshPayload
impl. However, by adding #[mesh(bound = "T: MyTrait")]
, this can be
replaced with the specified bound (which can be empty).