Skip to main content

Hub

Struct Hub 

Source
pub struct Hub { /* private fields */ }
Expand description

A Hub client: the base URL and this node’s token.

Implementations§

Source§

impl Hub

Source

pub fn new(url: impl Into<String>) -> Self

The Hub at url (such as HUB or a mirror), without a token.

Source

pub fn with_token(self, token: Option<HfToken>) -> Self

Sends token with requests (gated and private repos).

Source

pub fn url(&self) -> &str

Source

pub fn has_token(&self) -> bool

Source

pub fn search(&self, search: &Search) -> Result<Vec<SearchHit>>

Repos matching the search, most downloaded first.

Source

pub fn repo_files(&self, repo: &str) -> Result<Vec<RepoFile>>

The GGUF model files of repo (see repo_files). Adapters are still in this list; Hub::models leaves them out.

Source

pub fn models(&self, repo: &str) -> Result<Vec<RepoModel>>

The downloadable models of repo, split files grouped (group_files). Adapters are left out: a file whose name hints at one (adapter_hint) has its header read, and is dropped when the header says general.type = adapter.

Source

pub fn gguf_info(&self, repo: &str, file: &str) -> Result<GgufInfo>

The header of file in repo (its first gguf::HEADER_LIMIT bytes at most, through a Range request), for KV sizing. For a split model pass its first part. Fails on adapters; see Hub::gguf_header.

Source

pub fn gguf_header(&self, repo: &str, file: &str) -> Result<GgufHeader>

The header of file in repo, of any kind (gguf::read_header): whether it is a model or an adapter, its architecture and base model.

Source

pub fn adapters(&self, repo: &str) -> Result<Vec<RepoAdapter>>

The LoRA adapters in repo: GGUF files whose header says general.type = adapter and adapter.type = lora (files with an adapter_hint in the name, or every GGUF when the repo’s tags mark it as an adapter), and PEFT directories (an adapter_config.json with peft_type LORA next to adapter_model.safetensors or adapter_model.bin). Sorted by id.

Trait Implementations§

Source§

impl Clone for Hub

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Hub

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Hub

Source§

impl PartialEq for Hub

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Hub

Auto Trait Implementations§

§

impl Forget for Hub

§

impl Freeze for Hub

§

impl Move for Hub

§

impl RefUnwindSafe for Hub

§

impl Send for Hub

§

impl Sync for Hub

§

impl Unpin for Hub

§

impl UnsafeUnpin for Hub

§

impl UnwindSafe for Hub

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.