use serde::ser::Error as SerError;
use std::fmt::Display;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Debug)]
pub enum Error {
#[error("cannot write an empty identifier")]
EmptyIdentifier,
#[error("error writing to buffer")]
WriteError {
#[from]
source: std::io::Error,
},
#[error("error from Serialize implementation: {msg}")]
SerializeError { msg: String },
}
impl SerError for Error {
fn custom<T>(msg: T) -> Self
where
T: Display,
{
Error::SerializeError {
msg: msg.to_string(),
}
}
}