pub struct HFRepository<T: RepoType> { /* private fields */ }Expand description
A handle for a single repository on the Hugging Face Hub, parameterized by the
repo kind via the type-level marker T.
HFRepository<T> is created via the typed factories on HFClient —
HFClient::model, HFClient::dataset, HFClient::space, or
HFClient::kernel — and binds together the client, owner, and repo name. The
repo kind lives in the type system rather than in a runtime field, so methods
that differ per repo kind (such as info) are dispatched
at compile time and mismatches are impossible by construction.
Cheap to clone — the inner HFClient is Arc-backed.
§Example
let client = HFClient::builder().build()?;
let repo = client.model("openai-community", "gpt2");
let info = repo.info().send().await?;Implementations§
Source§impl<T: RepoType> HFRepository<T>
impl<T: RepoType> HFRepository<T>
Sourcepub fn list_commits<'f1>(&'f1 self) -> HFRepositoryListCommitsBuilder<'f1, T>
pub fn list_commits<'f1>(&'f1 self) -> HFRepositoryListCommitsBuilder<'f1, T>
Stream commit history for the repository at a given revision.
Returns HFResult<impl Stream<Item = HFResult<GitCommitInfo>>>. Pagination is automatic.
§Parameters
revision: Git revision (branch, tag, or commit SHA). Defaults to the main branch.limit: maximum number of commits yielded.
Sourcepub fn list_refs<'f1>(&'f1 self) -> HFRepositoryListRefsBuilder<'f1, T>
pub fn list_refs<'f1>(&'f1 self) -> HFRepositoryListRefsBuilder<'f1, T>
Fetch all branches, tags, and optionally pull-request refs for the repository.
Endpoint: GET /api/{repo_type}s/{repo_id}/refs.
§Parameters
include_pull_requests(defaultfalse): include pull-request refs in the listing.
Sourcepub fn get_commit_diff<'f1, 'f2>(
&'f1 self,
) -> HFRepositoryGetCommitDiffBuilder<'f1, 'f2, T>
pub fn get_commit_diff<'f1, 'f2>( &'f1 self, ) -> HFRepositoryGetCommitDiffBuilder<'f1, 'f2, T>
Fetch the Hub’s non-raw compare payload as text.
This returns the response body from the standard /compare/{compare} endpoint. Use
HFRepository::get_raw_diff for raw git-style diff text or
HFRepository::get_raw_diff_stream for parsed HFFileDiff entries.
Endpoint: GET /api/{repo_type}s/{repo_id}/compare/{compare}.
§Parameters
compare(required): revision spec describing what to compare. Either:- A single revision (branch name, tag, or commit SHA), compared against its parent (e.g.,
"main","v1.0","abc123…"), or - Two revisions in
<base>..<head>form (two dots), comparingbasetohead(e.g.,"main..feature","<sha1>..<sha2>").
- A single revision (branch name, tag, or commit SHA), compared against its parent (e.g.,
Sourcepub fn get_raw_diff<'f1, 'f2>(
&'f1 self,
) -> HFRepositoryGetRawDiffBuilder<'f1, 'f2, T>
pub fn get_raw_diff<'f1, 'f2>( &'f1 self, ) -> HFRepositoryGetRawDiffBuilder<'f1, 'f2, T>
Fetch the raw diff payload between two revisions as a string.
Prefer HFRepository::get_raw_diff_stream when you want file-level metadata without
buffering the entire diff response in memory.
Endpoint: GET /api/{repo_type}s/{repo_id}/compare/{compare}?raw=true.
§Parameters
compare(required): revision spec describing what to compare. Either:- A single revision (branch name, tag, or commit SHA), compared against its parent (e.g.,
"main","v1.0","abc123…"), or - Two revisions in
<base>..<head>form (two dots), comparingbasetohead(e.g.,"main..feature","<sha1>..<sha2>").
- A single revision (branch name, tag, or commit SHA), compared against its parent (e.g.,
Sourcepub fn get_raw_diff_stream<'f1>(
&'f1 self,
) -> HFRepositoryGetRawDiffStreamBuilder<'f1, T>
pub fn get_raw_diff_stream<'f1>( &'f1 self, ) -> HFRepositoryGetRawDiffStreamBuilder<'f1, T>
Fetch the raw diff between two revisions as a parsed stream of HFFileDiff entries.
Each Ok item is one parsed diff entry; malformed lines are Err items.
Endpoint: GET /api/{repo_type}s/{repo_id}/compare/{compare}?raw=true.
§Parameters
compare(required): revision spec describing what to compare. Either:- A single revision (branch name, tag, or commit SHA), compared against its parent (e.g.,
"main","v1.0","abc123…"), or - Two revisions in
<base>..<head>form (two dots), comparingbasetohead(e.g.,"main..feature","<sha1>..<sha2>").
- A single revision (branch name, tag, or commit SHA), compared against its parent (e.g.,
Sourcepub fn create_branch<'f1, 'f2>(
&'f1 self,
) -> HFRepositoryCreateBranchBuilder<'f1, 'f2, T>
pub fn create_branch<'f1, 'f2>( &'f1 self, ) -> HFRepositoryCreateBranchBuilder<'f1, 'f2, T>
Create a new branch, optionally starting from a specific revision.
Endpoint: POST /api/{repo_type}s/{repo_id}/branch/{branch}.
§Parameters
branch(required): name of the branch to create.revision: revision to branch from. Defaults to the current main branch head.
Sourcepub fn delete_branch<'f1, 'f2>(
&'f1 self,
) -> HFRepositoryDeleteBranchBuilder<'f1, 'f2, T>
pub fn delete_branch<'f1, 'f2>( &'f1 self, ) -> HFRepositoryDeleteBranchBuilder<'f1, 'f2, T>
Delete a branch from the repository.
Endpoint: DELETE /api/{repo_type}s/{repo_id}/branch/{branch}.
§Parameters
branch(required): name of the branch to delete.
Sourcepub fn create_tag<'f1, 'f2, 'f3>(
&'f1 self,
) -> HFRepositoryCreateTagBuilder<'f1, 'f2, 'f3, T>
pub fn create_tag<'f1, 'f2, 'f3>( &'f1 self, ) -> HFRepositoryCreateTagBuilder<'f1, 'f2, 'f3, T>
Create a lightweight or annotated tag, optionally at a specific revision.
Endpoint: POST /api/{repo_type}s/{repo_id}/tag/{revision}.
§Parameters
tag(required): name of the tag to create.revision: revision to tag. Defaults to the current main branch head.message: annotation message for the tag.
Sourcepub fn delete_tag<'f1, 'f2>(
&'f1 self,
) -> HFRepositoryDeleteTagBuilder<'f1, 'f2, T>
pub fn delete_tag<'f1, 'f2>( &'f1 self, ) -> HFRepositoryDeleteTagBuilder<'f1, 'f2, T>
Delete a tag from the repository.
Endpoint: DELETE /api/{repo_type}s/{repo_id}/tag/{tag}.
§Parameters
tag(required): name of the tag to delete.
Source§impl<T: RepoType> HFRepository<T>
impl<T: RepoType> HFRepository<T>
Sourcepub fn download_file<'f1>(&'f1 self) -> HFRepositoryDownloadFileBuilder<'f1, T>
pub fn download_file<'f1>(&'f1 self) -> HFRepositoryDownloadFileBuilder<'f1, T>
Download a single file from a repository.
When local_dir is Some, the file is downloaded directly to that directory
(no caching). When local_dir is None, the HF cache system is used:
blobs are stored by etag and symlinked from snapshots/{commit}/{filename}.
Returns the local filesystem path of the downloaded or cached file. Use
HFRepository::download_file_stream or
HFRepository::download_file_to_bytes when you do not want to write to
disk.
§Offline / cache-only lookups
Set .local_files_only(true) to resolve strictly from the local cache
without any network request — this is the replacement for the 0.x
Cache::get API. A cache miss returns
HFError::LocalEntryNotFound, which is distinct from a real failure:
match it to tell “not cached” apart from a genuinely missing file
(HFError::EntryNotFound) or any transport error.
use hf_hub::HFError;
let repo = hf_hub::HFClient::new()?.model("openai-community", "gpt2");
match repo.download_file().filename("config.json").local_files_only(true).send().await {
Ok(path) => println!("cached at {}", path.display()),
Err(HFError::LocalEntryNotFound { .. }) => println!("not in cache"),
Err(e) => return Err(e),
}Endpoint: GET {endpoint}/{prefix}{repo_id}/resolve/{revision}/{filename}.
§Parameters
filename(required): path of the file to download within the repository.local_dir: local directory to download the file into. When set, the file is saved with its repo path structure.revision: Git revision. Defaults to the main branch.force_download(defaultfalse): re-download the file even if a cached copy exists.local_files_only(defaultfalse): only return the file if cached locally; never make a network request.progress: optional progress handler.
Sourcepub fn download_file_stream<'f1>(
&'f1 self,
) -> HFRepositoryDownloadFileStreamBuilder<'f1, T>
pub fn download_file_stream<'f1>( &'f1 self, ) -> HFRepositoryDownloadFileStreamBuilder<'f1, T>
Download a file and return a byte stream instead of writing to disk.
Returns a (content_length, stream) tuple. content_length is Some
when the server provides a Content-Length header.
When range is set, only the specified byte range is fetched.
§Parameters
filename(required): path of the file to stream within the repository.revision: Git revision. Defaults to the main branch.range: byte range to request, as a Ruststd::ops::Range<u64>. The range follows standard Rust semantics —startis inclusive,endis exclusive — so0..1024fetches the first 1024 bytes (offsets0..=1023). Internally, this is converted to the HTTPRange: bytes=<start>-<end-1>header.startmust be strictly less thanend; an empty or inverted range returnsHFError::InvalidParameter.progress: optional progress handler.Startis emitted before the stream is returned;Progressis emitted as the caller polls each chunk;Completeis emitted when the stream is exhausted.
Sourcepub fn download_file_to_bytes<'f1>(
&'f1 self,
) -> HFRepositoryDownloadFileToBytesBuilder<'f1, T>
pub fn download_file_to_bytes<'f1>( &'f1 self, ) -> HFRepositoryDownloadFileToBytesBuilder<'f1, T>
Download a file (or byte range) into memory and return the contents as bytes::Bytes.
This is a convenience wrapper around
download_file_stream that collects the entire stream into
a single buffer. When range is set, only the specified byte range is fetched.
§Parameters
filename(required): path of the file to download within the repository.revision: Git revision. Defaults to the main branch.range: byte range to request, as a Ruststd::ops::Range<u64>. The range follows standard Rust semantics —startis inclusive,endis exclusive — so0..1024fetches the first 1024 bytes (offsets0..=1023). Internally, this is converted to the HTTPRange: bytes=<start>-<end-1>header.startmust be strictly less thanend; an empty or inverted range returnsHFError::InvalidParameter.progress: optional progress handler. EmitsStart/Progress/Completeas the underlying stream is drained, identically todownload_file_stream.
Sourcepub fn snapshot_download<'f1>(
&'f1 self,
) -> HFRepositorySnapshotDownloadBuilder<'f1, T>
pub fn snapshot_download<'f1>( &'f1 self, ) -> HFRepositorySnapshotDownloadBuilder<'f1, T>
Download all selected files for a resolved revision.
When local_dir is None, files are stored in the HF cache, and the returned path is the
cache snapshot directory for the resolved commit. When local_dir is Some, files are
written directly under that directory.
allow_patterns and ignore_patterns use globset syntax
(*, ?, **, character classes, etc.). Both are matched against each candidate file’s
repository path — forward-slash-joined and relative to the repo root, e.g.,
tokenizer.json or weights/model-00001-of-00003.safetensors.
§Parameters
revision: Git revision. Defaults to the main branch.allow_patterns: globs selecting which repository files to download. When set, only files whose repo path matches at least one pattern are downloaded.ignore_patterns: globs of repository files to skip. Matched against the same repo paths asallow_patterns.local_dir: local directory to download into.force_download(defaultfalse): re-download all files even if cached.local_files_only(defaultfalse): resolve only from the local cache.max_workers: maximum concurrent file downloads (default 8).progress: optional progress handler.
Source§impl<T: RepoType> HFRepository<T>
impl<T: RepoType> HFRepository<T>
Sourcepub fn list_tree<'f1>(&'f1 self) -> HFRepositoryListTreeBuilder<'f1, T>
pub fn list_tree<'f1>(&'f1 self) -> HFRepositoryListTreeBuilder<'f1, T>
Stream file and directory entries in the repository tree.
Returns HFResult<impl Stream<Item = HFResult<RepoTreeEntry>>>.
Use HFRepository::get_paths_info when you already know the exact paths
you want to inspect.
§Parameters
revision: Git revision to list. Defaults to the main branch.path_in_repo: repository-relative subdirectory to list. Defaults to the repo root. Leading, trailing, and consecutive/separators are ignored; path segments are URL-encoded automatically.recursive(defaultfalse): traverse subdirectories.expand(defaultfalse): include per-file metadata such as size, LFS info, and last-commit summaries.limit: cap the total number of entries yielded.
Sourcepub fn get_paths_info<'f1>(&'f1 self) -> HFRepositoryGetPathsInfoBuilder<'f1, T>
pub fn get_paths_info<'f1>(&'f1 self) -> HFRepositoryGetPathsInfoBuilder<'f1, T>
Get info about specific paths in a repository.
Prefer this over HFRepository::list_tree when you already know the
small set of paths you want to inspect.
Endpoint: POST /api/{repo_type}s/{repo_id}/paths-info/{revision}.
§Parameters
paths(required): paths in the repository to fetch info for.revision: Git revision. Defaults to the main branch.
Sourcepub fn get_file_metadata<'f1, 'f2>(
&'f1 self,
) -> HFRepositoryGetFileMetadataBuilder<'f1, 'f2, T>
pub fn get_file_metadata<'f1, 'f2>( &'f1 self, ) -> HFRepositoryGetFileMetadataBuilder<'f1, 'f2, T>
Fetch metadata for a single file via a HEAD request on its resolve URL.
Returns the resolved commit hash, ETag, file size, and (if the file is Xet-backed) the Xet content hash — without downloading the file contents.
Endpoint: HEAD {endpoint}/{prefix}{repo_id}/resolve/{revision}/{filepath}.
§Parameters
filepath(required): path of the file to inspect within the repository.revision: Git revision. Defaults to the main branch.
Source§impl<T: RepoType> HFRepository<T>
impl<T: RepoType> HFRepository<T>
Sourcepub fn create_commit<'f1>(&'f1 self) -> HFRepositoryCreateCommitBuilder<'f1, T>
pub fn create_commit<'f1>(&'f1 self) -> HFRepositoryCreateCommitBuilder<'f1, T>
Create a commit with multiple operations.
This is the lowest-level public mutation API in the files’ module. Use it when you need an
explicit mix of add and delete operations in one commit. For one-shot workflows, prefer
HFRepository::upload_file, HFRepository::upload_folder,
HFRepository::delete_file, or HFRepository::delete_folder.
Endpoint: POST /api/{repo_type}s/{repo_id}/commit/{revision}.
§Parameters
operations(required): list of file operations to include in the commit.commit_message(required): commit message.commit_description: extended description for the commit.revision: branch to commit to. Defaults to the main branch.create_pr(defaultfalse): create a pull request instead of committing directly.parent_commit: expected parent commit SHA. Fails if the branch head moved past it.progress: optional progress handler.
Sourcepub fn upload_file<'f1>(&'f1 self) -> HFRepositoryUploadFileBuilder<'f1, T>
pub fn upload_file<'f1>(&'f1 self) -> HFRepositoryUploadFileBuilder<'f1, T>
Upload a single file to a repository.
Convenience wrapper around HFRepository::create_commit. If commit_message is
omitted, a default "Upload {path}" message is used.
§Parameters
source(required): file content source (bytes or local file path).path_in_repo(required): destination path within the repository.revision: branch to upload to. Defaults to the main branch.commit_message,commit_description,create_pr,parent_commit,progress: same asHFRepository::create_commit.create_prdefaults tofalse.
Sourcepub fn upload_folder<'f1>(&'f1 self) -> HFRepositoryUploadFolderBuilder<'f1, T>
pub fn upload_folder<'f1>(&'f1 self) -> HFRepositoryUploadFolderBuilder<'f1, T>
Upload a local folder to a repository.
The folder is walked recursively and converted into add operations. When delete_patterns
is set, matching remote files are also deleted in the same commit.
All pattern arguments use globset syntax (*, ?, **,
character classes, etc.). Path strings are forward-slash-joined regardless of platform.
§Parameters
folder_path(required): local folder path to upload.path_in_repo: destination directory within the repository (default: repo root).revision: branch to upload to. Defaults to the main branch.commit_message,commit_description: commit metadata.create_pr(defaultfalse): create a pull request instead of committing directly.allow_patterns: globs selecting which local files to include. Matched against each discovered file’s path relative tofolder_path(e.g.,data/train.bin, not the absolute path and not prefixed withpath_in_repo). When set, only files matching at least one pattern are uploaded.ignore_patterns: globs of local files to skip. Matched against the samefolder_path-relative paths asallow_patterns.delete_patterns: globs of remote files to delete in the same commit. Matched against each existing file’s full repository path (relative to repo root, not relative topath_in_repo) — e.g.,old/*.binto remove every.bindirectly underold/at the repo root.progress: optional progress handler.
Sourcepub fn delete_file<'f1>(&'f1 self) -> HFRepositoryDeleteFileBuilder<'f1, T>
pub fn delete_file<'f1>(&'f1 self) -> HFRepositoryDeleteFileBuilder<'f1, T>
Delete a file from a repository.
Convenience wrapper around HFRepository::create_commit. If commit_message is
omitted, a default "Delete {path}" message is used.
§Parameters
path_in_repo(required): path of the file to delete.revision: branch to delete from. Defaults to the main branch.commit_message: commit message.create_pr(defaultfalse): create a pull request instead of committing directly.
Sourcepub fn delete_folder<'f1>(&'f1 self) -> HFRepositoryDeleteFolderBuilder<'f1, T>
pub fn delete_folder<'f1>(&'f1 self) -> HFRepositoryDeleteFolderBuilder<'f1, T>
Delete all files under a repository path.
The current tree is listed recursively and every file at or below path_in_repo is turned
into a delete operation. Directories disappear as a consequence of deleting their contents.
§Parameters
path_in_repo(required): folder path within the repository.revision: branch to delete from. Defaults to the main branch.commit_message: commit message.create_pr(defaultfalse): create a pull request instead of committing directly.
Source§impl<T: RepoType> HFRepository<T>
impl<T: RepoType> HFRepository<T>
Sourcepub fn new(
client: HFClient,
repo_type: T,
owner: impl Into<String>,
name: impl Into<String>,
) -> Self
pub fn new( client: HFClient, repo_type: T, owner: impl Into<String>, name: impl Into<String>, ) -> Self
Construct a new repository handle. Prefer the factory methods on HFClient instead.
Sourcepub fn repo_path(&self) -> String
pub fn repo_path(&self) -> String
The full "owner/name" identifier used in Hub API calls.
If no owner is set, returns just the name (for repos using short-form IDs like "gpt2").
Sourcepub fn repo_type(&self) -> &T
pub fn repo_type(&self) -> &T
The marker for this handle’s repo kind.
Returns a reference to the stored marker value. Call
singular, plural, or
url_prefix on it to get the corresponding string.
For T = RepoTypeAny, the returned value reflects the runtime variant the
handle was constructed with.
Source§impl<T: RepoType> HFRepository<T>
impl<T: RepoType> HFRepository<T>
Sourcepub fn exists<'f1>(&'f1 self) -> HFRepositoryExistsBuilder<'f1, T>
pub fn exists<'f1>(&'f1 self) -> HFRepositoryExistsBuilder<'f1, T>
Return true if the repository exists.
Returns Ok(false) only when the Hub responds with 404. If the repo exists but the current
credentials don’t have access (private/gated), this returns an error
(HFError::AuthRequired or HFError::Forbidden), not Ok(false).
Sourcepub fn revision_exists<'f1, 'f2>(
&'f1 self,
) -> HFRepositoryRevisionExistsBuilder<'f1, 'f2, T>
pub fn revision_exists<'f1, 'f2>( &'f1 self, ) -> HFRepositoryRevisionExistsBuilder<'f1, 'f2, T>
Return true if the given revision (branch, tag, or commit SHA) exists.
Returns Ok(false) only when the Hub responds with 404. If the repo exists but the current
credentials don’t have access (private/gated), this returns an error
(HFError::AuthRequired or HFError::Forbidden), not Ok(false).
§Parameters
revision(required): Git revision to check for existence.
Sourcepub fn file_exists<'f1, 'f2, 'f3>(
&'f1 self,
) -> HFRepositoryFileExistsBuilder<'f1, 'f2, 'f3, T>
pub fn file_exists<'f1, 'f2, 'f3>( &'f1 self, ) -> HFRepositoryFileExistsBuilder<'f1, 'f2, 'f3, T>
Return true if the given file exists in the repository at the specified revision.
§Parameters
filename(required): path of the file to check within the repository.revision: Git revision to check. Defaults to the main branch.
Sourcepub fn update_settings<'f1>(
&'f1 self,
) -> HFRepositoryUpdateSettingsBuilder<'f1, T>
pub fn update_settings<'f1>( &'f1 self, ) -> HFRepositoryUpdateSettingsBuilder<'f1, T>
Update repository settings such as visibility, gating policy, description, discussion settings, and gated notification preferences.
Endpoint: PUT /api/{plural}/{repo_id}/settings.
§Parameters
private: whether the repository should be private.gated: access-gating mode for the repository (e.g.,auto,manual, disabled).description: repository description shown on the Hub page.discussions_disabled: whether discussions are disabled on this repository.gated_notifications: notification cadence (and optional email override) for gated-access requests. The cadence is required when this is set; passGatedNotifications::with_emailto override the recipient too.
Source§impl HFRepository<RepoTypeModel>
impl HFRepository<RepoTypeModel>
Sourcepub fn info<'f1>(&'f1 self) -> HFModelInfoBuilder<'f1>
pub fn info<'f1>(&'f1 self) -> HFModelInfoBuilder<'f1>
Fetch ModelInfo for this model repository.
Fetch repository metadata for this repo kind, returning the concrete info struct.
§Parameters
revision: Git revision (branch, tag, or commit SHA). Defaults to the main branch.expand: list of properties to expand in the response (e.g.,"trendingScore","cardData"). When set, only the listed properties (plus_idandid) are returned. Kernel info ignores this.
Source§impl HFRepository<RepoTypeDataset>
impl HFRepository<RepoTypeDataset>
Sourcepub fn info<'f1>(&'f1 self) -> HFDatasetInfoBuilder<'f1>
pub fn info<'f1>(&'f1 self) -> HFDatasetInfoBuilder<'f1>
Fetch DatasetInfo for this dataset repository.
Fetch repository metadata for this repo kind, returning the concrete info struct.
§Parameters
revision: Git revision (branch, tag, or commit SHA). Defaults to the main branch.expand: list of properties to expand in the response (e.g.,"trendingScore","cardData"). When set, only the listed properties (plus_idandid) are returned. Kernel info ignores this.
Source§impl HFRepository<RepoTypeSpace>
impl HFRepository<RepoTypeSpace>
Sourcepub fn info<'f1>(&'f1 self) -> HFSpaceInfoBuilder<'f1>
pub fn info<'f1>(&'f1 self) -> HFSpaceInfoBuilder<'f1>
Fetch SpaceInfo for this Space repository.
Fetch repository metadata for this repo kind, returning the concrete info struct.
§Parameters
revision: Git revision (branch, tag, or commit SHA). Defaults to the main branch.expand: list of properties to expand in the response (e.g.,"trendingScore","cardData"). When set, only the listed properties (plus_idandid) are returned. Kernel info ignores this.
Source§impl HFRepository<RepoTypeKernel>
impl HFRepository<RepoTypeKernel>
Sourcepub fn info<'f1>(&'f1 self) -> HFKernelInfoBuilder<'f1>
pub fn info<'f1>(&'f1 self) -> HFKernelInfoBuilder<'f1>
Fetch KernelInfo for this kernel repository.
Note: the Hub’s /api/kernels/{repo_id} endpoint returns a slim shape (no tags,
cardData, or siblings) and silently ignores expand. To get the full
model-style metadata for a kernel, build a model handle for the same repo id
(client.model(owner, name)) and call info() on it.
Fetch repository metadata for this repo kind, returning the concrete info struct.
§Parameters
revision: Git revision (branch, tag, or commit SHA). Defaults to the main branch.expand: list of properties to expand in the response (e.g.,"trendingScore","cardData"). When set, only the listed properties (plus_idandid) are returned. Kernel info ignores this.
Source§impl HFRepository<RepoTypeSpace>
impl HFRepository<RepoTypeSpace>
Sourcepub fn runtime<'f1>(&'f1 self) -> HFRepositoryRuntimeBuilder<'f1>
pub fn runtime<'f1>(&'f1 self) -> HFRepositoryRuntimeBuilder<'f1>
Fetch the current runtime state of the Space (hardware, stage, URL, etc.).
Endpoint: GET /api/spaces/{repo_id}/runtime.
§Example
let client = HFClient::builder().build()?;
let runtime = client.space("owner", "name").runtime().send().await?;Sourcepub fn request_hardware<'f1, 'f2>(
&'f1 self,
) -> HFRepositoryRequestHardwareBuilder<'f1, 'f2>
pub fn request_hardware<'f1, 'f2>( &'f1 self, ) -> HFRepositoryRequestHardwareBuilder<'f1, 'f2>
Request an upgrade or downgrade of the Space’s hardware tier.
Endpoint: POST /api/spaces/{repo_id}/hardware.
§Parameters
hardware(required): hardware flavor to request (e.g.,"cpu-basic","t4-small","a10g-small").sleep_time: seconds of inactivity before the Space is put to sleep.0means never sleep.
Sourcepub fn set_sleep_time<'f1>(&'f1 self) -> HFRepositorySetSleepTimeBuilder<'f1>
pub fn set_sleep_time<'f1>(&'f1 self) -> HFRepositorySetSleepTimeBuilder<'f1>
Configure the number of seconds of inactivity before the Space is put to sleep.
Endpoint: POST /api/spaces/{repo_id}/sleeptime.
§Parameters
sleep_time(required): seconds of inactivity before the Space is put to sleep.0means never sleep.
Sourcepub fn pause<'f1>(&'f1 self) -> HFRepositoryPauseBuilder<'f1>
pub fn pause<'f1>(&'f1 self) -> HFRepositoryPauseBuilder<'f1>
Pause the Space, stopping it from consuming compute resources.
Endpoint: POST /api/spaces/{repo_id}/pause.
Sourcepub fn restart<'f1>(&'f1 self) -> HFRepositoryRestartBuilder<'f1>
pub fn restart<'f1>(&'f1 self) -> HFRepositoryRestartBuilder<'f1>
Restart a paused or errored Space.
Endpoint: POST /api/spaces/{repo_id}/restart.
Sourcepub fn add_secret<'f1, 'f2, 'f3, 'f4>(
&'f1 self,
) -> HFRepositoryAddSecretBuilder<'f1, 'f2, 'f3, 'f4>
pub fn add_secret<'f1, 'f2, 'f3, 'f4>( &'f1 self, ) -> HFRepositoryAddSecretBuilder<'f1, 'f2, 'f3, 'f4>
Add or update a secret (encrypted environment variable) on the Space.
Endpoint: POST /api/spaces/{repo_id}/secrets.
§Parameters
key(required): secret key name.value(required): secret value.description: human-readable description of the secret.
Sourcepub fn delete_secret<'f1, 'f2>(
&'f1 self,
) -> HFRepositoryDeleteSecretBuilder<'f1, 'f2>
pub fn delete_secret<'f1, 'f2>( &'f1 self, ) -> HFRepositoryDeleteSecretBuilder<'f1, 'f2>
Delete a secret from the Space by key.
Endpoint: DELETE /api/spaces/{repo_id}/secrets.
§Parameters
key(required): secret key name to delete.
Sourcepub fn add_variable<'f1, 'f2, 'f3, 'f4>(
&'f1 self,
) -> HFRepositoryAddVariableBuilder<'f1, 'f2, 'f3, 'f4>
pub fn add_variable<'f1, 'f2, 'f3, 'f4>( &'f1 self, ) -> HFRepositoryAddVariableBuilder<'f1, 'f2, 'f3, 'f4>
Add or update a public environment variable on the Space.
Endpoint: POST /api/spaces/{repo_id}/variables.
§Parameters
key(required): variable key name.value(required): variable value.description: human-readable description of the variable.
Sourcepub fn delete_variable<'f1, 'f2>(
&'f1 self,
) -> HFRepositoryDeleteVariableBuilder<'f1, 'f2>
pub fn delete_variable<'f1, 'f2>( &'f1 self, ) -> HFRepositoryDeleteVariableBuilder<'f1, 'f2>
Delete a public environment variable from the Space by key.
Endpoint: DELETE /api/spaces/{repo_id}/variables.
§Parameters
key(required): variable key name to delete.
Sourcepub fn duplicate<'f1, 'f2, 'f3, 'f4>(
&'f1 self,
) -> HFRepositoryDuplicateBuilder<'f1, 'f2, 'f3, 'f4>
pub fn duplicate<'f1, 'f2, 'f3, 'f4>( &'f1 self, ) -> HFRepositoryDuplicateBuilder<'f1, 'f2, 'f3, 'f4>
Duplicate this Space to a new repository.
Endpoint: POST /api/spaces/{repo_id}/duplicate.
§Parameters
to_id: destination repository ID in"owner/name"format. Defaults to the authenticated user’s namespace with the same name.private: whether the duplicated Space should be private.hardware: hardware flavor identifier the duplicated Space should run on (seeHardware valuesbelow). When omitted, the Hub picks a default (typically"cpu-basic") — pass a value explicitly to mirror the source Space’s hardware.storage: persistent storage tier identifier. One of"small","medium", or"large". Omit to duplicate without persistent storage. See the Spaces storage docs for current sizes.sleep_time: seconds of inactivity before the Space is put to sleep.0means never sleep.secrets: encrypted environment variables to set on the duplicated Space (seeSecret/variable shapebelow).variables: public (non-secret) environment variables to set on the duplicated Space (seeSecret/variable shapebelow).
§Hardware values
The Hub uses lowercase, hyphenated identifiers. Common values include "cpu-basic", "cpu-upgrade",
"t4-small", "t4-medium", "l4x1", "l4x4", "a10g-small", "a10g-large", "a10g-largex2",
"a10g-largex4", "a100-large", "h100", "h100x8", and "zero-a10g". The authoritative, current list lives
in the Spaces GPU hardware docs.
§Secret/variable shape
Each entry in secrets or variables is a JSON object with the following keys:
key(string, required): variable/secret name.value(string, required): variable/secret value.description(string, optional): human-readable description.
use serde_json::json;
let secrets = vec![
json!({ "key": "HF_TOKEN", "value": "hf_...", "description": "API token" }),
json!({ "key": "DB_PASSWORD", "value": "s3cret" }),
];
let variables = vec![json!({ "key": "MODEL_NAME", "value": "bert-base-uncased" })];Trait Implementations§
Source§impl<T: RepoType> Clone for HFRepository<T>
impl<T: RepoType> Clone for HFRepository<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for HFRepository<T>
impl<T> !UnwindSafe for HFRepository<T>
impl<T> Freeze for HFRepository<T>where
T: Freeze,
impl<T> Send for HFRepository<T>
impl<T> Sync for HFRepository<T>
impl<T> Unpin for HFRepository<T>where
T: Unpin,
impl<T> UnsafeUnpin for HFRepository<T>where
T: UnsafeUnpin,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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