diff --git a/src/protocol/types.rs b/src/protocol/types.rs index 48ccc3e..fb23254 100644 --- a/src/protocol/types.rs +++ b/src/protocol/types.rs @@ -45,7 +45,7 @@ impl> Encoder<&T> for Boolean { impl> Decoder for Boolean { fn decode(&self, buf: &mut B) -> Result { - Ok((buf.try_get_u8()? != 0).into()) + Ok((ByteBuf::try_get_u8(buf)? != 0).into()) } } @@ -72,7 +72,7 @@ macro_rules! define_simple_ints { impl> Decoder for $name { fn decode(&self, buf: &mut B) -> Result { - Ok(buf.$get()?.into()) + Ok(ByteBuf::$get(buf)?.into()) } } @@ -121,7 +121,7 @@ impl> Decoder for UnsignedVarInt { fn decode(&self, buf: &mut B) -> Result { let mut value = 0; for i in 0..5 { - let b = buf.try_get_u8()? as u32; + let b = ByteBuf::try_get_u8(buf)? as u32; value |= (b & 0x7F) << (i * 7); if b < 0x80 { break; @@ -168,7 +168,7 @@ impl> Decoder for UnsignedVarLong { fn decode(&self, buf: &mut B) -> Result { let mut value = 0; for i in 0..10 { - let b = buf.try_get_u8()? as u64; + let b = ByteBuf::try_get_u8(buf)? as u64; value |= (b & 0x7F) << (i * 7); if b < 0x80 { break; @@ -252,7 +252,7 @@ impl> Encoder<&T> for Uuid { impl> Decoder for Uuid { fn decode(&self, buf: &mut B) -> Result { let mut result = [0; 16]; - buf.try_copy_to_slice(&mut result)?; + ByteBuf::try_copy_to_slice(buf, &mut result)?; Ok(uuid::Uuid::from_bytes(result).into()) } } @@ -360,7 +360,7 @@ impl Decoder> for String { -1 => Ok(None), n if n >= 0 => { let mut strbuf = vec![0; n as usize]; - buf.try_copy_to_slice(&mut strbuf)?; + ByteBuf::try_copy_to_slice(buf, &mut strbuf)?; Ok(Some(std::string::String::from_utf8(strbuf)?)) } n => { @@ -512,7 +512,7 @@ impl Decoder> for CompactString { 0 => Ok(None), n => { let mut strbuf = vec![0; (n - 1) as usize]; - buf.try_copy_to_slice(&mut strbuf)?; + ByteBuf::try_copy_to_slice(buf, &mut strbuf)?; Ok(Some(std::string::String::from_utf8(strbuf)?)) } } @@ -656,7 +656,7 @@ impl Decoder>> for Bytes { -1 => Ok(None), n if n >= 0 => { let mut data = vec![0; n as usize]; - buf.try_copy_to_slice(&mut data)?; + ByteBuf::try_copy_to_slice(buf, &mut data)?; Ok(Some(data)) } n => { @@ -805,7 +805,7 @@ impl Decoder>> for CompactBytes { 0 => Ok(None), n => { let mut data = vec![0; (n - 1) as usize]; - buf.try_copy_to_slice(&mut data)?; + ByteBuf::try_copy_to_slice(buf, &mut data)?; Ok(Some(data)) } }