Skip to main content

Repo

Struct Repo 

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

The representation of a repo on the hub.

Implementations§

Source§

impl Repo

Source

pub fn new(repo_id: &str, repo_type: RepoType) -> Self

Creates a new Repo instance with the specified repo_id and repo_type.

Source

pub fn set_revision(&mut self, revision: &str)

Sets the revision of the repository.

Source

pub fn set_cache_dir(&mut self, cache_dir: impl Into<PathBuf>)

Sets the cache directory for the repository.

Source

pub fn new_model(repo_id: &str) -> Self

Shortcut for creating a new model repository.

Examples found in repository?
examples/pull.rs (line 5)
4fn main() {
5    let cat = ModelsCat::new(Repo::new_model("BAAI/bge-small-zh-v1.5"));
6    cat.download_with_progress("model.safetensors", ProgressBarWrapper::default())
7        .unwrap();
8}
Source

pub fn new_dataset(repo_id: &str) -> Self

Shortcut for creating a new dataset repository.

Source

pub fn new_space(repo_id: &str) -> Self

Shortcut for creating a new space repository.

Source

pub fn cache_home(&self) -> &PathBuf

Get the cache home directory.

Source

pub fn repo_id(&self) -> &str

Get the repository ID.

Source

pub fn repo_type(&self) -> &RepoType

Get the repository type.

Source

pub fn revision(&self) -> &str

Get the revision.

Source

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.

Source

pub fn url_path(&self) -> String

Get the URL path for this repo

Source

pub fn url_path_with_revision(&self) -> String

Get the URL path for this repo with revision

Source

pub fn url_path_with_resolve(&self) -> String

Get the URL path for this repo with resolve

Source

pub fn safe_revision_path(&self) -> String

Revision needs to be url escaped before being used in a URL

Source

pub fn ref_path(&self) -> PathBuf

Get ref path, such as

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Repo

Source§

fn clone(&self) -> Repo

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 Repo

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Repo

§

impl RefUnwindSafe for Repo

§

impl Send for Repo

§

impl Sync for Repo

§

impl Unpin for Repo

§

impl UnsafeUnpin for Repo

§

impl UnwindSafe for Repo

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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<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<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