Skip to main content

llama_cpp_bindings/
gguf_context_error.rs

1//! Error types for GGUF context operations.
2
3use std::ffi::NulError;
4use std::path::PathBuf;
5
6/// Errors that can occur when working with GGUF contexts.
7#[derive(Debug, thiserror::Error)]
8pub enum GgufContextError {
9    /// Failed to initialize GGUF context from file
10    #[error("Failed to initialize GGUF context from file: {0}")]
11    InitFailed(PathBuf),
12
13    /// Key not found in GGUF metadata
14    #[error("Key not found in GGUF context: {key}")]
15    KeyNotFound {
16        /// The key that was not found
17        key: String,
18    },
19
20    /// Null byte in string
21    #[error("null byte in string: {0}")]
22    NulError(#[from] NulError),
23
24    /// Path cannot be converted to UTF-8
25    #[error("failed to convert path {0} to str")]
26    PathToStrError(PathBuf),
27
28    /// Value is not valid UTF-8
29    #[error("GGUF value is not valid UTF-8: {0}")]
30    Utf8Error(#[from] std::str::Utf8Error),
31}