Skip to main content

sal_virt/buildah/
mod.rs

1mod builder;
2mod cmd;
3mod containers;
4#[cfg(test)]
5mod containers_test;
6mod content;
7mod images;
8
9use std::error::Error;
10use std::fmt;
11use std::io;
12
13/// Error type for buildah operations
14#[derive(Debug)]
15pub enum BuildahError {
16    /// The buildah command failed to execute
17    CommandExecutionFailed(io::Error),
18    /// The buildah command executed but returned an error
19    CommandFailed(String),
20    /// Failed to parse JSON output
21    JsonParseError(String),
22    /// Failed to convert data
23    ConversionError(String),
24    /// Generic error
25    Other(String),
26}
27
28impl fmt::Display for BuildahError {
29    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30        match self {
31            BuildahError::CommandExecutionFailed(e) => {
32                write!(f, "Failed to execute buildah command: {}", e)
33            }
34            BuildahError::CommandFailed(e) => write!(f, "Buildah command failed: {}", e),
35            BuildahError::JsonParseError(e) => write!(f, "Failed to parse JSON: {}", e),
36            BuildahError::ConversionError(e) => write!(f, "Conversion error: {}", e),
37            BuildahError::Other(e) => write!(f, "{}", e),
38        }
39    }
40}
41
42impl Error for BuildahError {
43    fn source(&self) -> Option<&(dyn Error + 'static)> {
44        match self {
45            BuildahError::CommandExecutionFailed(e) => Some(e),
46            _ => None,
47        }
48    }
49}
50// Re-export the Builder
51pub use builder::Builder;
52
53// Re-export existing functions for backward compatibility
54pub use cmd::*;
55#[deprecated(since = "0.2.0", note = "Use Builder::new() instead")]
56pub use containers::*;
57pub use content::ContentOperations;
58#[deprecated(since = "0.2.0", note = "Use Builder methods instead")]
59pub use images::*;