configbuilder-pattern-validator 0.1.0

configbuilder-pattern: validator domain, trait contract + tech-agnostic reference implementation.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::ValidatorError;
use std::path::Path;

/// Validates a filesystem path before it is used as a config directory.
///
/// The reference implementation is [`crate::DefaultValidator`]. Import this trait
/// only when writing generic code that accepts any validator.
pub trait Validator {
    /// Returns `Ok(())` when `target` is a valid config directory path, `Err` otherwise.
    ///
    /// A non-existent path is considered valid (it will be skipped at load time).
    /// A path that exists but is not a directory returns [`ValidatorError::Io`].
    fn validate_path(&self, target: &Path) -> Result<(), ValidatorError>;
}