constantoine / totp-rs

RFC-compliant TOTP implementation with ease of use as a goal and additionnal QoL features.
https://crates.io/crates/totp-rs
MIT License
180 stars 22 forks source link

Implement Error trait for TotpUrlError #23

Closed sacovo closed 2 years ago

sacovo commented 2 years ago

Added dependency thiserror to implement the error trait for the TotpUrlError enum, so it can be used as a regular error, for example with anyhow. Also included the invalid value in the enums to make it clearer why there was an error.

Let me know if you want me to change anything else in the pull request, there were some minor things clippy noticed.

constantoine commented 2 years ago

Hi! Thanks for your feedback, I indeed should not forget to use clippy on my work laptop

I'm not sure how to approach this while trying to avoid a breaking change, although a breaking change isn't outright out of question

codecov-commenter commented 2 years ago

Codecov Report

Merging #23 (45c932b) into master (181d17e) will increase coverage by 0.16%. The diff coverage is 93.82%.

@@            Coverage Diff             @@
##           master      #23      +/-   ##
==========================================
+ Coverage   93.58%   93.75%   +0.16%     
==========================================
  Files           1        1              
  Lines         296      384      +88     
==========================================
+ Hits          277      360      +83     
- Misses         19       24       +5     
Impacted Files Coverage Δ
src/lib.rs 93.75% <93.82%> (+0.16%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 181d17e...45c932b. Read the comment docs.

sacovo commented 2 years ago

I think it could be done with a feature flag for now. I'll try it and change my request.

constantoine commented 2 years ago

As there has been some breaking work on several PR's, I have taken the liberty to replicate this without using an external macro. I will ping/credit you on release :)