#[derive(Protocol)]Expand description
Generate all the necessary RPC code for a protocol from an enum describing it.
This macro will generate various enums and structs to enable communication between a server and a client. The following items will be generated, where {} is the name of the protocol enum:
{}ServerHandler- A trait that the server must implement to handle queries{}Server- A struct that the server uses to communicate with clients{}Client- A struct that the client uses to communicate with a server
Each variant of the passed enum represents a query that the client can send to the
server. The first field of each variant is the question (serverbound), the second field
is the answer (clientbound). You may use tuples to represent sending multiple arguments and
you may use the unit type () to represent no arguments. Only data types which implement
Clone, [serde::Serialize], and [serde::Deserialize] can be used.
For more information on how to use the generated code, see the crate-level documentation.
ยงExample
use eagle::Protocol;
#[derive(Protocol)]
pub enum Example {
Add((i32, i32), i32),
Length(String, usize),
}