[−][src]Trait serde_traitobject::Error
A convenience trait implemented on all (de)serializable implementors of std::error::Error
.
It can be made into a trait object which is then (de)serializable.
Example
#[macro_use] extern crate serde_derive; extern crate serde_json; extern crate serde_traitobject as s; use std::fmt; #[derive(Serialize,Deserialize,Debug)] struct MyError(String); impl fmt::Display for MyError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.0) } } impl std::error::Error for MyError {} fn fallible() -> Result<(),s::Box<dyn s::Error>> { Err(Box::new(MyError(String::from("boxed error"))) as Box<dyn s::Error>)? } let serialized = serde_json::to_string(&fallible()).unwrap(); let deserialized: Result<(),s::Box<dyn s::Error>> = serde_json::from_str(&serialized).unwrap(); println!("{:?}", deserialized); // Err(MyError("boxed error"))
Trait Implementations
impl<'a> AsRef<dyn Error + 'a + Send> for dyn Error + Send + 'a
[src]
impl<'a> AsRef<dyn Error + 'a> for dyn Error + 'a
[src]
impl Serialize for dyn Error
[src]
impl Serialize for dyn Error + Send
[src]
Implementors
impl<T: ?Sized> Error for T where
T: Error + Serialize + Deserialize,
[src]
T: Error + Serialize + Deserialize,