[−][src]Struct ring::error::Unspecified
An error with absolutely no details.
ring uses this unit type as the error type in most of its results because (a) usually the specific reasons for a failure are obvious or are not useful to know, and/or (b) providing more details about a failure might provide a dangerous side channel, and/or (c) it greatly simplifies the error handling logic.
Result<T, ring::error::Unspecified>
is mostly equivalent to
Result<T, ()>
. However, ring::error::Unspecified
implements
std::error::Error
and users of ring can implement
From<ring::error::Unspecified>
to map this to their own error types, as
described in “Error Handling” in the Rust Book:
use ring::rand::{self, SecureRandom}; enum Error { CryptoError, IOError(std::io::Error), // [...] } impl From<ring::error::Unspecified> for Error { fn from(_: ring::error::Unspecified) -> Self { Error::CryptoError } } fn eight_random_bytes() -> Result<[u8; 8], Error> { let rng = rand::SystemRandom::new(); let mut bytes = [0; 8]; // The `From<ring::error::Unspecified>` implementation above makes this // equivalent to // `rng.fill(&mut bytes).map_err(|_| Error::CryptoError)?`. rng.fill(&mut bytes)?; Ok(bytes) }
Experience with using and implementing other crypto libraries like has shown that sophisticated error reporting facilities often cause significant bugs themselves, both within the crypto library and within users of the crypto library. This approach attempts to minimize complexity in the hopes of avoiding such problems. In some cases, this approach may be too extreme, and it may be important for an operation to provide some details about the cause of a failure. Users of ring are encouraged to report such cases so that they can be addressed individually.
Trait Implementations
impl Clone for Unspecified
[src]
fn clone(&self) -> Unspecified
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Copy for Unspecified
[src]
impl PartialEq<Unspecified> for Unspecified
[src]
fn eq(&self, other: &Unspecified) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl From<EndOfInput> for Unspecified
[src]
fn from(_: EndOfInput) -> Self
[src]
impl From<KeyRejected> for Unspecified
[src]
fn from(_: KeyRejected) -> Self
[src]
impl Debug for Unspecified
[src]
impl Display for Unspecified
[src]
impl Error for Unspecified
[src]
Auto Trait Implementations
impl Send for Unspecified
impl Sync for Unspecified
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,