respite/version.rs
1/// A version of the RESP protocol.
2#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
3pub enum RespVersion {
4 V2,
5 V3,
6}
7
8impl std::fmt::Display for RespVersion {
9 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10 match self {
11 RespVersion::V2 => write!(f, "2"),
12 RespVersion::V3 => write!(f, "3"),
13 }
14 }
15}
16
17impl From<RespVersion> for u8 {
18 fn from(version: RespVersion) -> u8 {
19 match version {
20 RespVersion::V2 => 2,
21 RespVersion::V3 => 3,
22 }
23 }
24}