pub trait HfClientPort: Send + Sync {
// Required methods
fn search<'life0, 'life1, 'async_trait>(
&'life0 self,
options: &'life1 HfSearchOptions,
) -> Pin<Box<dyn Future<Output = HfPortResult<HfSearchResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list_quantizations<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<Vec<HfQuantInfo>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list_gguf_files<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<Vec<HfFileInfo>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_quantization_files<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
quantization: &'life2 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<Vec<HfFileInfo>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn get_commit_sha<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_model_info<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<HfRepoInfo>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn fetch_generation_config<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<Option<String>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Port trait for HuggingFace Hub operations.
This trait defines the interface that the core domain uses to interact
with HuggingFace. The implementation lives in gglib-hf.
§Design
- Uses core-owned DTOs, not
HuggingFaceAPI types - Returns
HfPortErrorfor all failures - Async methods for network operations
- No implementation details leak through this interface
Required Methods§
Sourcefn search<'life0, 'life1, 'async_trait>(
&'life0 self,
options: &'life1 HfSearchOptions,
) -> Pin<Box<dyn Future<Output = HfPortResult<HfSearchResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn search<'life0, 'life1, 'async_trait>(
&'life0 self,
options: &'life1 HfSearchOptions,
) -> Pin<Box<dyn Future<Output = HfPortResult<HfSearchResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Search for GGUF models on HuggingFace.
Sourcefn list_quantizations<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<Vec<HfQuantInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_quantizations<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<Vec<HfQuantInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
List available quantizations for a model.
§Arguments
model_id- Full model ID (e.g.,TheBloke/Llama-2-7B-GGUF)
Sourcefn list_gguf_files<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<Vec<HfFileInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_gguf_files<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<Vec<HfFileInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn get_quantization_files<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
quantization: &'life2 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<Vec<HfFileInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_quantization_files<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
quantization: &'life2 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<Vec<HfFileInfo>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Get files for a specific quantization.
Returns file information including OIDs for all files in the quantization, sorted for correct shard ordering.
§Arguments
model_id- Full model IDquantization- Quantization name (e.g.,Q4_K_M)
Sourcefn get_commit_sha<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_commit_sha<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get the current commit SHA for a model.
Used for version tracking and update detection.
Sourcefn get_model_info<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<HfRepoInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_model_info<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<HfRepoInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get detailed information about a model.
Provided Methods§
Sourcefn fetch_generation_config<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<Option<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn fetch_generation_config<'life0, 'life1, 'async_trait>(
&'life0 self,
model_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = HfPortResult<Option<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Fetch a repository’s generation_config.json, if it has one.
Ok(None) means the repo has no such file — the ordinary answer for a
GGUF quant repo, and not a fault. Err means the fetch itself failed:
gated repo, no network, rate limit.
§Why this has a default implementation
It returns Ok(None), which is semantically exact for a client that
cannot fetch one. The caller
(crate::services::fetch_published_sampling) treats every negative answer the
same way — carry on and fall back to the tag guess — so a client that
does not implement this degrades to gglib’s pre-existing behaviour
rather than failing an import.