use serde::{ser, Serialize}; use crate::Nbt; use std; use std::fmt::{self, Display}; use serde::de; pub type Result = std::result::Result; // This is a bare-bones implementation. A real library would provide additional // information in its error type, for example the line and column at which the // error occurred, the byte offset into the input, or the current key being // processed. #[derive(Debug)] pub enum Error { Message(String), } impl Display for Error { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { match self { Error::Message(msg) => formatter.write_str(msg), } } } impl ser::Error for Error { fn custom(msg: T) -> Self { Error::Message(msg.to_string()) } } impl de::Error for Error { fn custom(msg: T) -> Self { Error::Message(msg.to_string()) } } impl std::error::Error for Error {} impl<'a> ser::Serializer for &'a mut Nbt { type Ok = (); type Error = Error; type SerializeSeq = Self; type SerializeTuple = Self; type SerializeTupleStruct = Self; type SerializeTupleVariant = Self; type SerializeMap = Self; type SerializeStruct = Self; type SerializeStructVariant = Self; fn serialize_bool(self, v: bool) -> Result<()> { todo!() } fn serialize_i8(self, v: i8) -> Result<()> { todo!() } fn serialize_i16(self, v: i16) -> Result<()> { todo!() } fn serialize_i32(self, v: i32) -> Result<()> { todo!() } fn serialize_i64(self, v: i64) -> Result<()> { todo!() } fn serialize_u8(self, v: u8) -> Result<()> { todo!() } fn serialize_u16(self, v: u16) -> Result<()> { todo!() } fn serialize_u32(self, v: u32) -> Result<()> { todo!() } fn serialize_u64(self, v: u64) -> Result<()> { todo!() } fn serialize_f32(self, v: f32) -> Result<()> { todo!() } fn serialize_f64(self, v: f64) -> Result<()> { todo!() } fn serialize_char(self, v: char) -> Result<()> { todo!() } fn serialize_str(self, v: &str) -> Result<()> { todo!() } fn serialize_bytes(self, v: &[u8]) -> Result<()> { todo!() } fn serialize_none(self) -> Result<()> { todo!() } fn serialize_some(self, value: &T) -> Result<()> where T: Serialize, { todo!() } fn serialize_unit(self) -> Result<()> { todo!() } fn serialize_unit_struct(self, name: &'static str) -> Result<()> { todo!() } fn serialize_unit_variant( self, name: &'static str, variant_index: u32, variant: &'static str, ) -> Result<()> { todo!() } fn serialize_newtype_struct(self, name: &'static str, value: &T) -> Result<()> where T: Serialize, { todo!() } fn serialize_newtype_variant( self, name: &'static str, variant_index: u32, variant: &'static str, value: &T, ) -> Result<()> where T: Serialize, { todo!() } fn serialize_seq(self, len: Option) -> Result<()> { todo!() } fn serialize_tuple(self, len: usize) -> Result<()> { todo!() } fn serialize_tuple_struct(self, name: &'static str, len: usize) -> Result<()> { todo!() } fn serialize_tuple_variant( self, name: &'static str, variant_index: u32, variant: &'static str, len: usize, ) -> Result<()> { todo!() } fn serialize_map(self, len: Option) -> Result<()> { todo!() } fn serialize_struct(self, name: &'static str, len: usize) -> Result<()> { todo!() } fn serialize_struct_variant( self, name: &'static str, variant_index: u32, variant: &'static str, len: usize, ) -> Result<()> { todo!() } }