Created
August 21, 2024 03:38
-
-
Save matthewjberger/7ec7cfd002f1b8134ad3e86eaeedc2f7 to your computer and use it in GitHub Desktop.
serde_json error impl From<> in rust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl From<serde_json::Error> for Error { | |
fn from(value: serde_json::Error) -> Self { | |
let class = match value.classify() { | |
serde_json::error::Category::Io => "io", | |
serde_json::error::Category::Syntax => "syntax", | |
serde_json::error::Category::Data => "data", | |
serde_json::error::Category::Eof => "eof", | |
}; | |
Error::Deser { | |
class: class.to_string(), | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment