safename 0.1.0

Filename and path validation for security hardening
Documentation
//! Error type for path validation.

use super::SafeNameError;
use thiserror::Error;

/// Result type alias for path validation.
pub type PathResult<T> = Result<T, PathError>;

/// Error type for path validation, including the component index.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
#[error("path component {index}: {error}")]
pub struct PathError {
    /// Index of the path component that failed validation
    pub index: usize,
    /// The underlying validation error
    pub error: SafeNameError,
}

impl PathError {
    /// Create a new path error.
    pub fn new(index: usize, error: SafeNameError) -> Self {
        Self { index, error }
    }
}