Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error do not implement Serialize Deserialize #67

Closed
Fi3 opened this issue Feb 20, 2020 · 1 comment
Closed

Error do not implement Serialize Deserialize #67

Fi3 opened this issue Feb 20, 2020 · 1 comment

Comments

@Fi3
Copy link

Fi3 commented Feb 20, 2020

Hi, I need to put a anyhow::Result in a struct that derive the traits serde::Serialize and serde::Desrilize but anyhow::Error do not implement these traits so is impossible to derive them in my struct.

There is a way around? These traits will ever be implemented?

@dtolnay
Copy link
Owner

dtolnay commented Feb 21, 2020

For your use case, could you share how you would expect anyhow::Error to be represented from serde's perspective? For example what would be your expectation for what the following program should print?:

fn main() {
    let io_e = std::io::Error::new(std::io::ErrorKind::Other, "...");
    let any_e = anyhow::Error::from(io_e);
    println!("{}", serde_json::to_string(&any_e).unwrap());
}

@dtolnay dtolnay closed this as completed Mar 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants