pubhubs/misc/error.rs
1/// An opaque error. Useful for crypto operations that do not wish to leak
2/// any information via error details.
3///
4/// Deliberately does NOT implement [`std::error::Error`]: the blanket [`From`] below
5/// would otherwise collide with std's `impl<T> From<T> for T`. Same trick as
6/// [`anyhow::Error`](https://docs.rs/anyhow/latest/anyhow/struct.Error.html).
7#[derive(Debug)]
8pub enum Opaque {
9 Error,
10}
11
12/// An opaque error
13pub const OPAQUE: Opaque = Opaque::Error;
14
15impl<E> From<E> for Opaque
16where
17 E: std::error::Error,
18{
19 fn from(_: E) -> Self {
20 OPAQUE
21 }
22}