partial serde deserialization
This commit is contained in:
1 parent
ebb74fdd61
commit
ecedb96ae5
6 files changed
+393
-53
No files matched your search
@@ -1,14 +1,20 @@
|
||||
use std;
|
||||
use std::fmt::{self, Display};
|
||||
use serde::{de, ser};
|
||||
use crate::bipack_source::BipackError;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
Message(String),
|
||||
BadFormat(String),
|
||||
Eof,
|
||||
ExtraBytes,
|
||||
BadEncoding,
|
||||
NotSupported,
|
||||
NotImplemented,
|
||||
NotPossible
|
||||
}
|
||||
|
||||
impl Display for Error {
|
||||
@@ -33,3 +39,13 @@ impl de::Error for Error {
|
||||
Error::Message(msg.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BipackError> for Error {
|
||||
fn from(value: BipackError) -> Self {
|
||||
match &value {
|
||||
BipackError::NoDataError => Error::Eof,
|
||||
BipackError::BadEncoding(_) => Error::BadEncoding,
|
||||
// other => Error::Message(format!("BiPack error: {}", value))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user