use { tinystr::{ TinyStr4, TinyStr8, TinyStr16, }, crate::{ Context, Readable, Reader, Writable, Writer, }, }; impl<'a, C> Readable<'a, C> for TinyStr4 where C: Context { #[inline] fn read_from>(reader: &mut R) -> Result { Ok(unsafe { TinyStr4::new_unchecked(reader.read_u32()?) }) } #[inline] fn minimum_bytes_needed() -> usize { 4 } } impl Writable for TinyStr4 where C: Context { #[inline] fn write_to>(&self, writer: &mut T) -> Result<(), C::Error> { writer.write_u32(self.as_unsigned()) } #[inline] fn bytes_needed(&self) -> Result { Ok(4) } } impl<'a, C> Readable<'a, C> for TinyStr8 where C: Context { #[inline] fn read_from>(reader: &mut R) -> Result { Ok(unsafe { TinyStr8::new_unchecked(reader.read_u64()?) }) } #[inline] fn minimum_bytes_needed() -> usize { 8 } } impl Writable for TinyStr8 where C: Context { #[inline] fn write_to>(&self, writer: &mut T) -> Result<(), C::Error> { writer.write_u64(self.as_unsigned()) } #[inline] fn bytes_needed(&self) -> Result { Ok(8) } } impl<'a, C> Readable<'a, C> for TinyStr16 where C: Context { #[inline] fn read_from>(reader: &mut R) -> Result { Ok(unsafe { TinyStr16::new_unchecked(reader.read_u128()?) }) } #[inline] fn minimum_bytes_needed() -> usize { 16 } } impl Writable for TinyStr16 where C: Context { #[inline] fn write_to>(&self, writer: &mut T) -> Result<(), C::Error> { writer.write_u128(self.as_unsigned()) } #[inline] fn bytes_needed(&self) -> Result { Ok(16) } }