Skip to main content

rw_builder/
error.rs

1use thiserror::Error;
2
3/// The error type for rw-builder operations.
4#[derive(Error, Debug)]
5#[non_exhaustive]
6pub enum Error {
7    /// Standard I/O error
8    #[error("I/O error: {0}")]
9    Io(#[from] std::io::Error),
10
11    /// Missing stdout in child process
12    #[error("Missing child stdout: {0}")]
13    MissingChildStdout(&'static str),
14
15    /// Missing stdin in child process
16    #[error("Missing child stdin: {0}")]
17    MissingChildStdin(&'static str),
18
19    /// Cipher error
20    #[cfg(any(feature = "chacha20", feature = "salsa20", feature = "aes_ctr"))]
21    #[error("Cipher error: {0}")]
22    Cipher(String),
23
24    /// Other generic error
25    #[error("Other error: {0}")]
26    Other(String),
27
28    /// Error returned by wincode read operations
29    #[cfg(feature = "wincode")]
30    #[error("Wincode read error: {0}")]
31    WincodeRead(#[from] wincode::ReadError),
32
33    /// Error returned by wincode write operations
34    #[cfg(feature = "wincode")]
35    #[error("Wincode write error: {0}")]
36    WincodeWrite(#[from] wincode::WriteError),
37
38    /// Error returned by wincode IO write operations
39    #[cfg(feature = "wincode")]
40    #[error("Wincode IO write error: {0}")]
41    WincodeIoWrite(#[from] wincode::io::WriteError),
42
43    /// String from UTF-8 conversion error
44    #[error("UTF-8 decoding error: {0}")]
45    FromUtf8(#[from] std::string::FromUtf8Error),
46}
47
48/// The result type for rw-builder operations.
49pub type Result<T> = std::result::Result<T, Error>;