pub fn to_bytes(self, api_version: ApiVersion) -> Vec<u8> {
        match api_version {
            ApiVersion::V1 => self.user_value.to_vec(),
            ApiVersion::V1ttl => {
                let mut buf = Vec::with_capacity(self.user_value.len() + number::U64_SIZE);
                buf.extend_from_slice(self.user_value);
                buf.encode_u64(self.expire_ts.unwrap_or(0)).unwrap();
                buf
            }
            ApiVersion::V2 => {
                let mut flags = ValueMeta::empty();
                let mut meta_size = 1;
                if self.expire_ts.is_some() {
                    flags.insert(ValueMeta::EXPIRE_TS);
                    meta_size += number::U64_SIZE;
                }
                let mut buf = Vec::with_capacity(self.user_value.len() + meta_size);
                buf.extend_from_slice(self.user_value);
                if let Some(expire_ts) = self.expire_ts {
                    buf.encode_u64(expire_ts).unwrap();
                }
                buf.push(flags.bits());
                buf
            }
        }
    }
/// Encode the raw value and it's metadata into bytes.
Encode the raw value and it's metadata into bytes.
Encode the raw value and it ' s metadata into bytes .
pub fn to_bytes(self, api_version: ApiVersion) -> Vec<u8> {
        match api_version {
            ApiVersion::V1 => self.user_value.to_vec(),
            ApiVersion::V1ttl => {
                let mut buf = Vec::with_capacity(self.user_value.len() + number::U64_SIZE);
                buf.extend_from_slice(self.user_value);
                buf.encode_u64(self.expire_ts.unwrap_or(0)).unwrap();
                buf
            }
            ApiVersion::V2 => {
                let mut flags = ValueMeta::empty();
                let mut meta_size = 1;
                if self.expire_ts.is_some() {
                    flags.insert(ValueMeta::EXPIRE_TS);
                    meta_size += number::U64_SIZE;
                }
                let mut buf = Vec::with_capacity(self.user_value.len() + meta_size);
                buf.extend_from_slice(self.user_value);
                if let Some(expire_ts) = self.expire_ts {
                    buf.encode_u64(expire_ts).unwrap();
                }
                buf.push(flags.bits());
                buf
            }
        }
    }
pub fn to_bytes ( self , api_version : ApiVersion ) -> Vec < u8 > { match api_version { ApiVersion :: V1 => self . user_value . to_vec ( ) , ApiVersion :: V1ttl => { let mut buf = Vec :: with_capacity ( self . user_value . len ( ) + number :: U64_SIZE ) ; buf . extend_from_slice ( self . user_value ) ; buf . encode_u64 ( self . expire_ts . unwrap_or ( 0 ) ) . unwrap ( ) ; buf } ApiVersion :: V2 => { let mut flags = ValueMeta :: empty ( ) ; let mut meta_size = 1 ; if self . expire_ts . is_some ( ) { flags . insert ( ValueMeta :: EXPIRE_TS ) ; meta_size += number :: U64_SIZE ; } let mut buf = Vec :: with_capacity ( self . user_value . len ( ) + meta_size ) ; buf . extend_from_slice ( self . user_value ) ; if let Some ( expire_ts ) = self . expire_ts { buf . encode_u64 ( expire_ts ) . unwrap ( ) ; } buf . push ( flags . bits ( ) ) ; buf } } }
Encode the raw value and it's metadata into bytes.
Encode the raw value and it ' s metadata into bytes .
self
api_version
ApiVersion