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.

  1. use bytes::Bytes;
  2. #[derive(Debug)]
  3. enum Command {
  4. Get {
  5. key: String,
  6. },
  7. Set {
  8. key: String,
  9. val: Bytes,
  10. }
  11. }