-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patherror.rs
More file actions
27 lines (24 loc) · 816 Bytes
/
error.rs
File metadata and controls
27 lines (24 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use thiserror::Error;
use crate::BufType;
/// The error type for interactions with this library.
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum Error {
/// The number of allocated buffers was less than the amount requested.
#[error("failed to allocate {required_count} buffers (driver only allocated {actual_count})")]
BufferAllocationFailed {
required_count: u32,
actual_count: u32,
},
/// The requested buffer type is not supported.
#[error("unsupported buffer type {0:?}")]
UnsupportedBufferType(BufType),
/// An underlying I/O error has occurred.
#[error(transparent)]
Io(#[from] std::io::Error),
}
impl From<nix::Error> for Error {
fn from(error: nix::Error) -> Self {
Error::Io(std::io::Error::from_raw_os_error(error as i32))
}
}