Skip to main content

HFRepository

Struct HFRepository 

Source
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 HFClientHFClient::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>

Source

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.
Source

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 (default false): include pull-request refs in the listing.
Source

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), comparing base to head (e.g., "main..feature", "<sha1>..<sha2>").
Source

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), comparing base to head (e.g., "main..feature", "<sha1>..<sha2>").
Source

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), comparing base to head (e.g., "main..feature", "<sha1>..<sha2>").
Source

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.
Source

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.
Source

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.
Source

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>

Source

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 (default false): re-download the file even if a cached copy exists.
  • local_files_only (default false): only return the file if cached locally; never make a network request.
  • progress: optional progress handler.
Source

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 Rust std::ops::Range<u64>. The range follows standard Rust semantics — start is inclusive, end is exclusive — so 0..1024 fetches the first 1024 bytes (offsets 0..=1023). Internally, this is converted to the HTTP Range: bytes=<start>-<end-1> header. start must be strictly less than end; an empty or inverted range returns HFError::InvalidParameter.
  • progress: optional progress handler. Start is emitted before the stream is returned; Progress is emitted as the caller polls each chunk; Complete is emitted when the stream is exhausted.
Source

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 Rust std::ops::Range<u64>. The range follows standard Rust semantics — start is inclusive, end is exclusive — so 0..1024 fetches the first 1024 bytes (offsets 0..=1023). Internally, this is converted to the HTTP Range: bytes=<start>-<end-1> header. start must be strictly less than end; an empty or inverted range returns HFError::InvalidParameter.
  • progress: optional progress handler. Emits Start/Progress/Complete as the underlying stream is drained, identically to download_file_stream.
Source

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 as allow_patterns.
  • local_dir: local directory to download into.
  • force_download (default false): re-download all files even if cached.
  • local_files_only (default false): resolve only from the local cache.
  • max_workers: maximum concurrent file downloads (default 8).
  • progress: optional progress handler.
Source§

impl<T: RepoType> HFRepository<T>

Source

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 (default false): traverse subdirectories.
  • expand (default false): include per-file metadata such as size, LFS info, and last-commit summaries.
  • limit: cap the total number of entries yielded.
Source

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.
Source

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>

Source

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 (default false): 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.
Source

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 as HFRepository::create_commit. create_pr defaults to false.
Source

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 (default false): 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 to folder_path (e.g., data/train.bin, not the absolute path and not prefixed with path_in_repo). When set, only files matching at least one pattern are uploaded.
  • ignore_patterns: globs of local files to skip. Matched against the same folder_path-relative paths as allow_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 to path_in_repo) — e.g., old/*.bin to remove every .bin directly under old/ at the repo root.
  • progress: optional progress handler.
Source

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 (default false): create a pull request instead of committing directly.
Source

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 (default false): create a pull request instead of committing directly.
Source§

impl<T: RepoType> HFRepository<T>

Source

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.

Source

pub fn client(&self) -> &HFClient

Return a reference to the underlying HFClient.

Source

pub fn owner(&self) -> &str

The repository owner (user or organization name).

Source

pub fn name(&self) -> &str

The repository name (without owner prefix).

Source

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").

Source

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>

Source

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).

Source

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.
Source

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.
Source

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; pass GatedNotifications::with_email to override the recipient too.
Source§

impl HFRepository<RepoTypeModel>

Source

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 _id and id) are returned. Kernel info ignores this.
Source§

impl HFRepository<RepoTypeDataset>

Source

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 _id and id) are returned. Kernel info ignores this.
Source§

impl HFRepository<RepoTypeSpace>

Source

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 _id and id) are returned. Kernel info ignores this.
Source§

impl HFRepository<RepoTypeKernel>

Source

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 _id and id) are returned. Kernel info ignores this.
Source§

impl HFRepository<RepoTypeSpace>

Source

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?;
Source

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. 0 means never sleep.
Source

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. 0 means never sleep.
Source

pub fn pause<'f1>(&'f1 self) -> HFRepositoryPauseBuilder<'f1>

Pause the Space, stopping it from consuming compute resources.

Endpoint: POST /api/spaces/{repo_id}/pause.

Source

pub fn restart<'f1>(&'f1 self) -> HFRepositoryRestartBuilder<'f1>

Restart a paused or errored Space.

Endpoint: POST /api/spaces/{repo_id}/restart.

Source

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.
Source

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.
Source

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.
Source

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.
Source

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 (see Hardware values below). 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. 0 means never sleep.
  • secrets: encrypted environment variables to set on the duplicated Space (see Secret/variable shape below).
  • variables: public (non-secret) environment variables to set on the duplicated Space (see Secret/variable shape below).
§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>

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<T: RepoType> Debug for HFRepository<T>

Source§

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

Formats the value using the given formatter. Read more

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> 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> DropFlavorWrapper<T> for T

Source§

type Flavor = MayDrop

The DropFlavor that wraps T into Self
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

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

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<E> ResultError for E
where E: Send + Debug + Sync,

Source§

impl<T> ResultType for T
where T: Send + Clone + Sync + Debug,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more