Byron / trash-rs

A Rust library for moving files to the Recycle Bin
MIT License
171 stars 28 forks source link

`derive` `serde::{Serialize, Deserialize}` for `Error` #117

Closed bicarlsen closed 1 month ago

bicarlsen commented 1 month ago

Could we derive serde::{Serialize, Deserialize} for Error? Perhaps placing it behind a feature flag.

bicarlsen commented 1 month ago

Some of the fields aren't Serialize or Deserialize so a straight derive won't work, unless they are skipped, or we implement them manually. I'm happy to do a PR for this if it's something you would want.

Byron commented 1 month ago

Somehow I feel that it would go beyond the scope of this crate. For instance, an std::io::Error also doesn't implement serde, so one would have to do that here in a way that won't be canonical. Maybe I am missing something, but it seems like it's easier to convert the error into an own type that implements serde natively, and do so downstream. Does that make sense?