pub struct GgufContext { /* private fields */ }Expand description
A safe wrapper around gguf_context.
Opens a GGUF file and parses only the metadata header; tensor weights are
never loaded into memory (no_alloc = true).
Implementations§
Source§impl GgufContext
impl GgufContext
Sourcepub fn from_file(path: &Path) -> Option<Self>
pub fn from_file(path: &Path) -> Option<Self>
Open a GGUF file and parse its metadata header.
Returns None if the path contains a null byte, the file does not
exist, or the file is not a valid GGUF file.
Sourcepub fn find_key(&self, key: &str) -> i64
pub fn find_key(&self, key: &str) -> i64
Find the index of a key by name. Returns -1 if not found.
Sourcepub fn key_at(&self, idx: i64) -> Option<&str>
pub fn key_at(&self, idx: i64) -> Option<&str>
Return the key name at the given index, or None if out of range.
Sourcepub fn val_u32(&self, idx: i64) -> u32
pub fn val_u32(&self, idx: i64) -> u32
Read a uint32 value. Panics (inside llama.cpp) if the stored type is
not GGUF_TYPE_UINT32 — check kv_type first if unsure.
Trait Implementations§
Source§impl Debug for GgufContext
impl Debug for GgufContext
Auto Trait Implementations§
impl Freeze for GgufContext
impl RefUnwindSafe for GgufContext
impl !Send for GgufContext
impl !Sync for GgufContext
impl Unpin for GgufContext
impl UnsafeUnpin for GgufContext
impl UnwindSafe for GgufContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more