Coverage Report

Created: 2025-07-01 06:04

/rust/registry/src/index.crates.io-6f17d22bba15001f/arbitrary-0.4.7/src/error.rs
Line
Count
Source (jump to first uncovered line)
1
use std::{error, fmt};
2
3
/// An enumeration of buffer creation errors
4
#[derive(Debug, Clone, Copy)]
5
#[non_exhaustive]
6
pub enum Error {
7
    /// There was not enough underlying data to fulfill some request for raw
8
    /// bytes.
9
    NotEnoughData,
10
    /// The input bytes were not of the right format
11
    IncorrectFormat,
12
}
13
14
impl fmt::Display for Error {
15
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16
0
        match self {
17
0
            Error::NotEnoughData => write!(
18
0
                f,
19
0
                "There is not enough underlying raw data to construct an `Arbitrary` instance"
20
0
            ),
21
0
            Error::IncorrectFormat => write!(
22
0
                f,
23
0
                "The raw data is not of the correct format to construct this type"
24
0
            ),
25
        }
26
0
    }
27
}
28
29
impl error::Error for Error {}
30
31
/// A `Result` with the error type fixed as `arbitrary::Error`.
32
///
33
/// Either an `Ok(T)` or `Err(arbitrary::Error)`.
34
pub type Result<T> = std::result::Result<T, Error>;