chinedufn / psd

A Rust API for parsing and working with PSD files.
https://chinedufn.github.io/psd
Apache License 2.0
267 stars 40 forks source link

Replace `failure` with `thiserror` and `anyhow` #23

Closed kstasik-legion closed 3 years ago

kstasik-legion commented 3 years ago

Summary

This PR replaces failure crate with thiserror and anyhow crates as suggested in failure README.MD

Problem

failure crate is deprecated therefore running cargo-deny check projects using cargo-deny reports unmaintained.

Moreover it reports possible memory safety issues (reports unsound).

For more info on both issues see https://github.com/rustsec/advisory-db/tree/main/crates/failure.

kstasik-legion commented 3 years ago

Sure I can look into moving this a step further.

What would you suggest doing with all the Result<>s originating from PsdCursor - like fn read(&mut self, count: u32) -> Result<&[u8]> that don't ever return a result?

Should I remove the Result and change it to fn read(&mut self, count: u32) -> &[u8] or create a CursorError enum and add variants to all enums that it can be propagated to - such as:

pub enum ImageResourcesDescriptorError {
  // ...
  ReadError(CursorError)
kstasik-legion commented 3 years ago

And for the public API would you prefer to return a Box<Error> or have a pub enum PsdError {} returned with concrete variants.

chinedufn commented 3 years ago

that don't ever return a result?

Ah, I see.

fn read(&mut self, count: u32) -> &[u8] sounds good for now!


And for the public API would you prefer to return a Box or have a pub enum PsdError {} returned with concrete variants.

You mean on the Psd type? Yup a PsdError sounds great!


Thanks for diving into this!

chinedufn commented 3 years ago

Related to #9

chinedufn commented 3 years ago

Thanks!

kstasik-legion commented 3 years ago

Thank you!

I'm not sure what is failing on circleci as it asks for too much from me to login but it might be worth looking into running cargo clippy as part of CI to cleanup a little bit the codebase.

Keep up the good work.