I tried the following:
let key = PrivateKeyDer::try_from(std::fs::read(key)?)?;
And I get the error:
? couldn't convert the error: str: std::error::Error is not satisfied
the question mark operation (?) implicitly performs a conversion on the error value using the From trait
required for &str to implement std::error::Error
required for anyhow::Error to implement From<&str>
Unfortunately &str doesn't impl core::error::Error, so using it as the error return type in a try_from can cause users of the library some difficulty. It would be better to instead return a type that impls core::error::Error in the error value.