pub struct GgufContext { /* private fields */ }Implementations§
Source§impl GgufContext
impl GgufContext
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<Self, GgufContextError>
pub fn from_file(path: impl AsRef<Path>) -> Result<Self, GgufContextError>
§Errors
Returns GgufContextError::InitFailed if the file cannot be opened or parsed.
Returns GgufContextError::PathToStrError if the path is not valid UTF-8.
Returns GgufContextError::NulError if the path contains a null byte.
pub fn n_kv(&self) -> i64
Sourcepub fn find_key(&self, key: &str) -> Result<i64, GgufContextError>
pub fn find_key(&self, key: &str) -> Result<i64, GgufContextError>
§Errors
Returns GgufContextError::KeyNotFound if the key does not exist.
Returns GgufContextError::NulError if the key contains a null byte.
Sourcepub fn key_at(&self, key_id: i64) -> Result<&str, GgufContextError>
pub fn key_at(&self, key_id: i64) -> Result<&str, GgufContextError>
§Safety considerations
The caller must ensure key_id is in range [0, n_kv()).
§Errors
Returns GgufContextError::Utf8Error if the key name is not valid UTF-8.
Sourcepub fn kv_type(&self, key_id: i64) -> Option<GgufType>
pub fn kv_type(&self, key_id: i64) -> Option<GgufType>
§Safety considerations
The caller must ensure key_id is in range [0, n_kv()).
Sourcepub fn val_u32(&self, key_id: i64) -> u32
pub fn val_u32(&self, key_id: i64) -> u32
§Safety considerations
The caller must ensure the key at key_id has type GgufType::Uint32.
Sourcepub fn val_i32(&self, key_id: i64) -> i32
pub fn val_i32(&self, key_id: i64) -> i32
§Safety considerations
The caller must ensure the key at key_id has type GgufType::Int32.
Sourcepub fn val_u64(&self, key_id: i64) -> u64
pub fn val_u64(&self, key_id: i64) -> u64
§Safety considerations
The caller must ensure the key at key_id has type GgufType::Uint64.
Sourcepub fn val_str(&self, key_id: i64) -> Result<&str, GgufContextError>
pub fn val_str(&self, key_id: i64) -> Result<&str, GgufContextError>
§Safety considerations
The caller must ensure the key at key_id has type GgufType::String.
§Errors
Returns GgufContextError::Utf8Error if the string value is not valid UTF-8.
pub fn n_tensors(&self) -> i64
Trait Implementations§
Source§impl Debug for GgufContext
impl Debug for GgufContext
Source§impl Drop for GgufContext
impl Drop 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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more