pub trait Serializer {
    type Error;

    fn write_str(&mut self, data: &str) -> Result<(), Self::Error>;
    fn write_bytes(&mut self, bytes: &[u8]) -> Result<(), Self::Error>;

    fn write_bool(&mut self, value: bool) -> Result<(), Self::Error>;

    fn write_i8(&mut self, value: i8) -> Result<(), Self::Error>;
    fn write_i16(&mut self, value: i16) -> Result<(), Self::Error>;
    fn write_i32(&mut self, value: i32) -> Result<(), Self::Error>;
    fn write_i64(&mut self, value: i64) -> Result<(), Self::Error>;
    fn write_isize(&mut self, value: isize) -> Result<(), Self::Error>;

    fn write_u8(&mut self, value: u8) -> Result<(), Self::Error>;
    fn write_u16(&mut self, value: u16) -> Result<(), Self::Error>;
    fn write_u32(&mut self, value: u32) -> Result<(), Self::Error>;
    fn write_u64(&mut self, value: u64) -> Result<(), Self::Error>;
    fn write_usize(&mut self, value: usize) -> Result<(), Self::Error>;

    fn write_enum_variant(&mut self, index: u32) -> Result<(), Self::Error>;
}

pub trait Serialize {
    fn serialize<S: Serializer>(&self, serializer: &mut S) -> Result<(), S::Error>;
}
