Define the message type
In most cases, when using message passing, the task receiving the messages responds to more than one command. In our case, the task will respond to GET
and SET
commands. To model this, we first define a Command
enum and include a variant for each command type.
use bytes::Bytes;
#[derive(Debug)]
enum Command {
Get {
key: String,
},
Set {
key: String,
val: Bytes,
}
}