validate_file

Function validate_file 

Source
pub fn validate_file(file_path: &str) -> Result<()>
Expand description

Validates that a file exists and has a .gguf extension.

§Arguments

  • file_path - Path to the file to validate

§Returns

  • Ok(()) if valid, Err if file doesn’t exist or has wrong extension

§Examples

use gglib_core::utils::validation::validate_file;
use std::fs::File;
use tempfile::tempdir;

// Create a temporary .gguf file
let temp_dir = tempdir().unwrap();
let file_path = temp_dir.path().join("model.gguf");
File::create(&file_path).unwrap();

// Validate the file
let result = validate_file(file_path.to_str().unwrap());
assert!(result.is_ok());
use gglib_core::utils::validation::validate_file;

// Non-existent file should fail
let result = validate_file("/nonexistent/model.gguf");
assert!(result.is_err());