pub fn require_path<P>(
path: Option<P>,
component: &str,
description: &str,
) -> Result<P, OCRError>Expand description
Validates that a required path option is present and returns the path.
This is a helper for builder patterns where a path is required but stored
as an Option<PathBuf>.
§Arguments
path- Optional path to validatecomponent- Component name for error message (e.g., “text_recognition”)description- Human-readable description of what the path is for
§Returns
The path if present.
§Errors
Returns an OCRError::ConfigError if the path is None.
§Example
use oar_ocr_core::utils::require_path;
use std::path::PathBuf;
let path: Option<PathBuf> = Some(PathBuf::from("/path/to/dict.txt"));
let validated = require_path(path, "text_recognition", "character dictionary path")?;