use thiserror::Error;
#[derive(Debug, Error)]
pub enum ShroudError {
#[error("failed to allocate protected memory: {0}")]
AllocationFailed(String),
#[error("failed to lock memory: {0}")]
LockFailed(String),
#[error("failed to unlock memory: {0}")]
UnlockFailed(String),
#[error("failed to change memory protection: {0}")]
ProtectFailed(String),
#[error("failed to deallocate memory: {0}")]
DeallocationFailed(String),
#[error("memory region is locked and cannot be accessed")]
RegionLocked,
#[error("invalid UTF-8 sequence: {0}")]
InvalidUtf8(#[from] core::str::Utf8Error),
#[error("capacity overflow: requested {requested} bytes, maximum is {maximum}")]
CapacityOverflow { requested: usize, maximum: usize },
#[error("operation not supported: {0}")]
Unsupported(String),
#[error("system error (code {code}): {message}")]
SystemError { code: i32, message: String },
}
pub type Result<T> = core::result::Result<T, ShroudError>;