pub struct Repo { /* private fields */ }Expand description
The representation of a repo on the hub.
Implementations§
Source§impl Repo
impl Repo
Sourcepub fn new(repo_id: &str, repo_type: RepoType) -> Self
pub fn new(repo_id: &str, repo_type: RepoType) -> Self
Creates a new Repo instance with the specified repo_id and repo_type.
Sourcepub fn set_revision(&mut self, revision: &str)
pub fn set_revision(&mut self, revision: &str)
Sets the revision of the repository.
Sourcepub fn set_cache_dir(&mut self, cache_dir: impl Into<PathBuf>)
pub fn set_cache_dir(&mut self, cache_dir: impl Into<PathBuf>)
Sets the cache directory for the repository.
Sourcepub fn new_dataset(repo_id: &str) -> Self
pub fn new_dataset(repo_id: &str) -> Self
Shortcut for creating a new dataset repository.
Sourcepub fn cache_home(&self) -> &PathBuf
pub fn cache_home(&self) -> &PathBuf
Get the cache home directory.
Sourcepub fn cache_dir(&self) -> PathBuf
pub fn cache_dir(&self) -> PathBuf
Constructs and returns the full cache directory path for the repository.
This function generates a unique cache directory path based on the repository type and ID. The path is constructed to ensure compatibility with filesystem path conventions.
Sourcepub fn url_path_with_revision(&self) -> String
pub fn url_path_with_revision(&self) -> String
Get the URL path for this repo with revision
Sourcepub fn url_path_with_resolve(&self) -> String
pub fn url_path_with_resolve(&self) -> String
Get the URL path for this repo with resolve
Sourcepub fn safe_revision_path(&self) -> String
pub fn safe_revision_path(&self) -> String
Revision needs to be url escaped before being used in a URL
Sourcepub fn create_ref(&self, commit_hash: &str) -> Result<(), Error>
pub fn create_ref(&self, commit_hash: &str) -> Result<(), Error>
Creates a reference in the cache directory that points branches to the correct commits within the blobs.
Sourcepub fn snapshot_path(&self, commit_hash: &str) -> PathBuf
pub fn snapshot_path(&self, commit_hash: &str) -> PathBuf
Returns the path to the snapshot directory for a specific commit hash.
The snapshot directory is located within the repository’s cache directory under the snapshots folder.
This function constructs the full path by appending the snapshots folder and the provided commit_hash.