Skip to main content

load_from_directory

Function load_from_directory 

Source
pub fn load_from_directory(path: &Path) -> Result<Vec<KnownValue>, LoadError>
Expand description

Loads all JSON registry files from a single directory.

This function scans the specified directory for files with a .json extension and attempts to parse them as known value registries.

§Arguments

  • path - The directory to scan for JSON registry files.

§Returns

Returns Ok with a vector of loaded KnownValue instances, or an empty vector if the directory doesn’t exist. Returns Err only for I/O errors that prevent directory traversal.

§Examples

use known_values::load_from_directory;
use std::path::Path;

let values = load_from_directory(Path::new("/etc/known-values"))?;
for value in values {
    println!("{}: {}", value.value(), value.name());
}