diff options
Diffstat (limited to 'src/to_clt/inv.rs')
-rw-r--r-- | src/to_clt/inv.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/to_clt/inv.rs b/src/to_clt/inv.rs index 2ada0a1..01eaa75 100644 --- a/src/to_clt/inv.rs +++ b/src/to_clt/inv.rs @@ -1,18 +1,20 @@ use super::*; -use mt_ser::{DeserializeError, SerializeError}; -use std::io::{Read, Write}; #[mt_derive(to = "clt", custom)] pub struct Inventory; // TODO #[cfg(feature = "server")] impl MtSerialize for Inventory { - fn mt_serialize<C: MtCfg>(&self, writer: &mut impl Write) -> Result<(), SerializeError> { + fn mt_serialize<C: MtCfg>( + &self, + writer: &mut impl std::io::Write, + ) -> Result<(), mt_ser::SerializeError> { "EndInventory\n".mt_serialize::<()>(writer) } } -fn read_line(reader: &mut impl Read) -> Result<String, DeserializeError> { +#[cfg(feature = "client")] +fn read_line(reader: &mut impl std::io::Read) -> Result<String, mt_ser::DeserializeError> { let utf8 = mt_ser::mt_deserialize_seq::<(), u8>(reader)? .map_while(|x| match x { Ok(0x0A) => None, @@ -21,12 +23,14 @@ fn read_line(reader: &mut impl Read) -> Result<String, DeserializeError> { .try_collect::<Vec<_>>()?; String::from_utf8(utf8) - .map_err(|e| DeserializeError::Other(format!("Invalid UTF-8: {e}").into())) + .map_err(|e| mt_ser::DeserializeError::Other(format!("Invalid UTF-8: {e}").into())) } #[cfg(feature = "client")] impl MtDeserialize for Inventory { - fn mt_deserialize<C: MtCfg>(reader: &mut impl Read) -> Result<Self, DeserializeError> { + fn mt_deserialize<C: MtCfg>( + reader: &mut impl std::io::Read, + ) -> Result<Self, mt_ser::DeserializeError> { loop { match read_line(reader)?.as_str() { "EndInventory" => return Ok(Self), |