# Struct ring::error::Unspecified [−] [src]

    pub struct 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:

    extern crate ring;
    use ring::rand;
    use ring::rand::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`

Returns a copy of the value. Read more

#### `fn clone_from(&mut self, source: &Self)`
1.0.0

Performs copy-assignment from `source`. Read more

### `impl Copy for Unspecified`
[src]

### `impl Debug for Unspecified`
[src]

#### `fn fmt(&self, __arg_0: &mut Formatter) -> Result`

Formats the value using the given formatter.

### `impl PartialEq for Unspecified`
[src]

#### `fn eq(&self, __arg_0: &Unspecified) -> bool`

This method tests for `self` and `other` values to be equal, and is used by `==`. Read more

#### `fn ne(&self, other: &Rhs) -> bool`
1.0.0

This method tests for `!=`.

### `impl Display for Unspecified`
[src]

#### `fn fmt(&self, f: &mut Formatter) -> Result`

Formats the value using the given formatter. Read more

### `impl Error for Unspecified`
[src]

#### `fn cause(&self) -> Option<&Error>`

The lower-level cause of this error, if any. Read more

#### `fn description(&self) -> &str`

A short description of the error. Read more

### `impl From<EndOfInput> for Unspecified`
[src]

#### `fn from(_: EndOfInput) -> Self`

Performs the conversion.

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)