use std::fmt::Display;
use serde::{de, ser};
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("{0}")]
Message(String),
#[error("io::Error: {0}")]
Io(#[from] std::io::Error),
#[error("CDR is not self-describing format, cannot deserialize \'Any\' type: {0}")]
NotSelfDescribingFormat(String),
#[error("CDR serialization requires sequence length to be specified at the start.")]
SequenceLengthUnknown,
#[error("unexpected end of input")]
Eof,
#[error("Expected 0 or 1 as Boolean, got: {0}")]
BadBoolean(u8),
#[error("Bad Unicode character code: {0}")]
BadChar(u32), #[error("Option value must have discriminant 0 or 1, read: {0}")]
BadOption(u32), #[error("UTF-8 error: {0}")]
BadUTF8(std::str::Utf8Error),
}
impl ser::Error for Error {
fn custom<T: Display>(msg: T) -> Self {
Self::Message(msg.to_string())
}
}
impl de::Error for Error {
fn custom<T: Display>(msg: T) -> Self {
Self::Message(msg.to_string())
}
}