use num::bigint::BigInt; use crate::value::{PlainValue, Domain}; #[derive(Debug)] pub enum Error { Message(String), InvalidUnicodeScalar(u32), NumberTooLarge(BigInt), CannotDeserializeAny, Expected(ExpectedKind, PlainValue), } #[derive(Debug)] pub enum ExpectedKind { Boolean, Float, Double, SignedInteger, String, ByteString, Symbol, Record(Option), SimpleRecord(&'static str, Option), Option, Sequence, Dictionary, } pub type Result = std::result::Result>; impl serde::ser::Error for Error { fn custom(msg: T) -> Self { Self::Message(msg.to_string()) } } impl serde::de::Error for Error { fn custom(msg: T) -> Self { Self::Message(msg.to_string()) } } impl std::error::Error for Error {} impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{:?}", self) } }