RustCrypto/block-ciphers

Implement std::fmt::Display, std::error::Error for errors

yerke opened this issue · 4 comments

yerke commented

Hi. Thank you for your work on this crate.

Is it possible to implement std::fmt::Display, std::error::Error traits for errors, such as block_modes::BlockModeError, block_modes::InvalidKeyIvLength?
This way it will be straightforward for users to do impl From<BlockModeError> for MyLocalError as described in https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/wrap_error.html.

Thanks.

Those traits are already implemented, you just have to enable std feature for block-cipher-trait crate. On future minor version bump we may add enabled by default std feature to all block cipher crates which will enable block-cipher-trait/std automatically, but until then you'll have to do it manually.

yerke commented

I think there is some sort of confusion here. You have linked the implementation for InvalidKeyLength, not InvalidKeyIvLength or BlockModeError.

Ah, you've meant errors from block-modes crate. I will add impls right away.

yerke commented

Thank you for such quick turnaround!