pub fn from_bytes(bytes: &'a [u8], api_version: ApiVersion) -> Result<Self> {
        match api_version {
            ApiVersion::V1 => Ok(RawValue {
                user_value: bytes,
                expire_ts: None,
            }),
            ApiVersion::V1ttl => {
                let rest_len = bytes
                    .len()
                    .checked_sub(number::U64_SIZE)
                    .ok_or(Error::Codec(codec::Error::ValueLength))?;
                let mut expire_ts_slice = &bytes[rest_len..];
                let expire_ts = number::decode_u64(&mut expire_ts_slice)?;
                let expire_ts = if expire_ts == 0 {
                    None
                } else {
                    Some(expire_ts)
                };
                Ok(RawValue {
                    user_value: &bytes[..rest_len],
                    expire_ts,
                })
            }
            ApiVersion::V2 => {
                let mut rest_len = bytes
                    .len()
                    .checked_sub(1)
                    .ok_or(Error::Codec(codec::Error::ValueLength))?;
                let flags = ValueMeta::from_bits(bytes[rest_len])
                    .ok_or(Error::Codec(codec::Error::ValueMeta))?;
                let expire_ts = if flags.contains(ValueMeta::EXPIRE_TS) {
                    rest_len = rest_len
                        .checked_sub(number::U64_SIZE)
                        .ok_or(Error::Codec(codec::Error::ValueLength))?;
                    let mut expire_ts_slice = &bytes[rest_len..rest_len + number::U64_SIZE];
                    Some(number::decode_u64(&mut expire_ts_slice)?)
                } else {
                    None
                };
                Ok(RawValue {
                    user_value: &bytes[..rest_len],
                    expire_ts,
                })
            }
        }
    }
/// Parse from the bytes from storage.
Parse from the bytes from storage.
Parse from the bytes from storage .
pub fn from_bytes(bytes: &'a [u8], api_version: ApiVersion) -> Result<Self> {
        match api_version {
            ApiVersion::V1 => Ok(RawValue {
                user_value: bytes,
                expire_ts: None,
            }),
            ApiVersion::V1ttl => {
                let rest_len = bytes
                    .len()
                    .checked_sub(number::U64_SIZE)
                    .ok_or(Error::Codec(codec::Error::ValueLength))?;
                let mut expire_ts_slice = &bytes[rest_len..];
                let expire_ts = number::decode_u64(&mut expire_ts_slice)?;
                let expire_ts = if expire_ts == 0 {
                    None
                } else {
                    Some(expire_ts)
                };
                Ok(RawValue {
                    user_value: &bytes[..rest_len],
                    expire_ts,
                })
            }
            ApiVersion::V2 => {
                let mut rest_len = bytes
                    .len()
                    .checked_sub(1)
                    .ok_or(Error::Codec(codec::Error::ValueLength))?;
                let flags = ValueMeta::from_bits(bytes[rest_len])
                    .ok_or(Error::Codec(codec::Error::ValueMeta))?;
                let expire_ts = if flags.contains(ValueMeta::EXPIRE_TS) {
                    rest_len = rest_len
                        .checked_sub(number::U64_SIZE)
                        .ok_or(Error::Codec(codec::Error::ValueLength))?;
                    let mut expire_ts_slice = &bytes[rest_len..rest_len + number::U64_SIZE];
                    Some(number::decode_u64(&mut expire_ts_slice)?)
                } else {
                    None
                };
                Ok(RawValue {
                    user_value: &bytes[..rest_len],
                    expire_ts,
                })
            }
        }
    }
pub fn from_bytes ( bytes : & ' a [ u8 ] , api_version : ApiVersion ) -> Result < Self > { match api_version { ApiVersion :: V1 => Ok ( RawValue { user_value : bytes , expire_ts : None , } ) , ApiVersion :: V1ttl => { let rest_len = bytes . len ( ) . checked_sub ( number :: U64_SIZE ) . ok_or ( Error :: Codec ( codec :: Error :: ValueLength ) ) ? ; let mut expire_ts_slice = & bytes [ rest_len .. ] ; let expire_ts = number :: decode_u64 ( & mut expire_ts_slice ) ? ; let expire_ts = if expire_ts == 0 { None } else { Some ( expire_ts ) } ; Ok ( RawValue { user_value : & bytes [ .. rest_len ] , expire_ts , } ) } ApiVersion :: V2 => { let mut rest_len = bytes . len ( ) . checked_sub ( 1 ) . ok_or ( Error :: Codec ( codec :: Error :: ValueLength ) ) ? ; let flags = ValueMeta :: from_bits ( bytes [ rest_len ] ) . ok_or ( Error :: Codec ( codec :: Error :: ValueMeta ) ) ? ; let expire_ts = if flags . contains ( ValueMeta :: EXPIRE_TS ) { rest_len = rest_len . checked_sub ( number :: U64_SIZE ) . ok_or ( Error :: Codec ( codec :: Error :: ValueLength ) ) ? ; let mut expire_ts_slice = & bytes [ rest_len .. rest_len + number :: U64_SIZE ] ; Some ( number :: decode_u64 ( & mut expire_ts_slice ) ? ) } else { None } ; Ok ( RawValue { user_value : & bytes [ .. rest_len ] , expire_ts , } ) } } }
Parse from the bytes from storage.
Parse from the bytes from storage .
bytes
&'a [u8]
api_version
ApiVersion