obliterate 1.2.0

Force-remove Files and Directories on Linux Including Paths with 000 Permissions.
Documentation
//! Custom error types and result aliases for the obliteration process.
//!
//! This module defines the [`Error`] enum, which categorizes various failures
//! that can occur during unmounting or recursive file removal.

use core::fmt;
use std::path::PathBuf;

/// A specialized [`Result`] type for obliteration operations.
pub type Result<T> = std::result::Result<T, Error>;

/// Represents the possible errors encountered during resource deconstruction.
#[derive(Debug)]
pub enum Error {
    /// A nested mount-point could not be detached before obliteration.
    UnmountFailed {
        /// The absolute path of the mount-point that could not be detached.
        path: PathBuf,
        /// The specific reason or error message from the unmount attempt.
        reason: String,
    },
    /// An underlying I/O error with no additional domain context.
    Io(std::io::Error),
}

impl fmt::Display for Error {
    /// Formats the error for user-facing output.
    ///
    /// Provides clear messaging for path missing, invalid targets, I/O issues,
    /// and detailed reports when a mount-point fails to unmount.
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            Error::UnmountFailed { path, reason } => {
                write!(f, "cannot unmount '{}': {}", path.display(), reason)
            }
            Error::Io(e) => e.fmt(f),
        }
    }
}

impl std::error::Error for Error {
    /// Returns the underlying source of the error if it is an I/O failure.
    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
        match self {
            Error::Io(e) => Some(e),
            _ => None,
        }
    }
}

impl From<std::io::Error> for Error {
    /// Converts a [`std::io::Error`] into [`Error::Io`] losslessly.
    fn from(err: std::io::Error) -> Error {
        Error::Io(err)
    }
}