keymgr: Decide whether to allow `KeyStore` implementers to bring their own error type
We have an Error
enum in tor-keymgr
that keeps growing keystore-specific variants (for example, the variants related to OpenSSH parsing issues are only ever returned by ArtiKeyNativeStore
). If we don't allow external KeyStore
implementers to bring their own error type, they're stuck picking from the error variants we defined (which will all probably be unsuitable as they're tailored to our own KeyStore
implementations).
So should each KeyStore
impl be able to bring its own error type? That would mean returning Result<..., Box<dyn Error>>
from the KeyStore
functions (instead of Result<..., tor_keymgr::Error>
). However, using an opaque error type will make handling KeyMgr
errors difficult: when the KeyMgr
bubbles up a KeyStore
error, the caller has to downcast it to a specific type (this assumes the caller knows which keystore the error came from, and thus what error type to downcast to. To make this work, we could make the error type be Box<dyn OurErrorTrait>
and have OurErrorTrait
specify what keystore the error came from, for example via a OurErrorTrait::keystore_name()
method).