use crate::coding::{Decode, DecodeError, Encode, EncodeError, VarInt}; use bytes::{Buf, BufMut}; use std::time::Duration; impl Encode for Duration { fn encode(&self, w: &mut W) -> Result<(), EncodeError> { let ms = self.as_millis(); let ms = VarInt::try_from(ms)?; ms.encode(w) } } impl Decode for Duration { fn decode(r: &mut R) -> Result { let ms = VarInt::decode(r)?; Ok(Self::from_millis(ms.into())) } }