herolib_rust/src/lib.rs

100 lines
2.2 KiB
Rust

//! # System Abstraction Layer (SAL)
//!
//! `sal` is a library that provides a unified interface for interacting with
//! operating system features across different platforms. It abstracts away the
//! platform-specific details, allowing developers to write cross-platform code
//! with ease.
//!
//! ## Features
//!
//! - File system operations
//! - Process management
//! - System information
//! - Network operations
//! - Environment variables
//! - Cryptographic operations
use std::io;
use thiserror::Error;
/// Error types for the SAL library
#[derive(Error, Debug)]
pub enum Error {
/// An error occurred during an I/O operation
#[error("I/O error: {0}")]
Io(#[from] io::Error),
/// An error specific to the SAL library
#[error("SAL error: {0}")]
Sal(String),
/// An error that occurred in a platform-specific operation
#[error("Platform-specific error: {0}")]
Platform(String),
}
/// Result type for SAL operations
pub type Result<T> = std::result::Result<T, Error>;
// Re-export modules conditionally based on features
#[cfg(feature = "git")]
pub use sal_git as git;
#[cfg(feature = "kubernetes")]
pub use sal_kubernetes as kubernetes;
#[cfg(feature = "mycelium")]
pub use sal_mycelium as mycelium;
#[cfg(feature = "hetzner")]
pub use sal_hetzner as hetzner;
#[cfg(feature = "net")]
pub use sal_net as net;
#[cfg(feature = "os")]
pub use sal_os as os;
#[cfg(feature = "postgresclient")]
pub use sal_postgresclient as postgresclient;
#[cfg(feature = "process")]
pub use sal_process as process;
#[cfg(feature = "redisclient")]
pub use sal_redisclient as redisclient;
#[cfg(feature = "rhai")]
pub use sal_rhai as rhai;
#[cfg(feature = "sal-service-manager")]
pub use sal_service_manager as service_manager;
#[cfg(feature = "text")]
pub use sal_text as text;
#[cfg(feature = "vault")]
pub use sal_vault as vault;
#[cfg(feature = "virt")]
pub use sal_virt as virt;
#[cfg(feature = "zinit_client")]
pub use sal_zinit_client as zinit_client;
// Version information
/// Returns the version of the SAL library
pub fn version() -> &'static str {
env!("CARGO_PKG_VERSION")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_version() {
assert!(!version().is_empty());
}
}