pub struct HFClientSync { /* private fields */ }blocking only.Expand description
Synchronous/blocking counterpart to HFClient.
Wraps an HFClient together with a single-threaded tokio runtime on a
dedicated background thread (RuntimeThread in this module), so the async
API can be used from synchronous code — including from inside another
tokio runtime, where a caller-owned runtime would panic.
Xet uploads and downloads do not run on this runtime: hf-xet requires a
multi-threaded runtime with the IO and time drivers enabled, so the
single-threaded runtime here does not meet its requirements. When a Xet
transfer is triggered through any blocking handle, hf-xet spins up its
own multi-threaded thread pool to back the XetSession, separate from
the runtime thread owned by HFClientSync.
See HFClient for configuration and API semantics.
Implementations§
Source§impl HFClientSync
impl HFClientSync
Sourcepub fn new() -> HFResult<Self>
pub fn new() -> HFResult<Self>
Creates an HFClientSync using the default configuration from the environment.
Reads the standard environment variables used by HFClient::new.
§Errors
Returns an error if the tokio runtime cannot be created or if HFClient::new fails.
Sourcepub fn from_inner(inner: HFClient) -> HFResult<Self>
pub fn from_inner(inner: HFClient) -> HFResult<Self>
Sourcepub fn repository<T: RepoType>(
&self,
repo_type: T,
owner: impl Into<String>,
name: impl Into<String>,
) -> HFRepositorySync<T>
pub fn repository<T: RepoType>( &self, repo_type: T, owner: impl Into<String>, name: impl Into<String>, ) -> HFRepositorySync<T>
Creates a blocking handle for any repo kind via a turbofished generic.
See HFClient::repository.
Sourcepub fn model(
&self,
owner: impl Into<String>,
name: impl Into<String>,
) -> HFRepositorySync<RepoTypeModel>
pub fn model( &self, owner: impl Into<String>, name: impl Into<String>, ) -> HFRepositorySync<RepoTypeModel>
Creates a blocking handle for a model repository.
See HFClient::model.
Sourcepub fn dataset(
&self,
owner: impl Into<String>,
name: impl Into<String>,
) -> HFRepositorySync<RepoTypeDataset>
pub fn dataset( &self, owner: impl Into<String>, name: impl Into<String>, ) -> HFRepositorySync<RepoTypeDataset>
Creates a blocking handle for a dataset repository.
See HFClient::dataset.
Sourcepub fn space(
&self,
owner: impl Into<String>,
name: impl Into<String>,
) -> HFRepositorySync<RepoTypeSpace>
pub fn space( &self, owner: impl Into<String>, name: impl Into<String>, ) -> HFRepositorySync<RepoTypeSpace>
Creates a blocking handle for a Space repository.
See HFClient::space.
Sourcepub fn kernel(
&self,
owner: impl Into<String>,
name: impl Into<String>,
) -> HFRepositorySync<RepoTypeKernel>
pub fn kernel( &self, owner: impl Into<String>, name: impl Into<String>, ) -> HFRepositorySync<RepoTypeKernel>
Creates a blocking handle for a kernel repository.
See HFClient::kernel.
Sourcepub fn bucket(
&self,
owner: impl Into<String>,
name: impl Into<String>,
) -> HFBucketSync
pub fn bucket( &self, owner: impl Into<String>, name: impl Into<String>, ) -> HFBucketSync
Creates a blocking handle for a bucket.
See HFClient::bucket.
Source§impl HFClientSync
impl HFClientSync
Sourcepub fn create_bucket<'f1, 'f2, 'f3>(
&'f1 self,
) -> HFClientSyncCreateBucketBuilder<'f1, 'f2, 'f3>
pub fn create_bucket<'f1, 'f2, 'f3>( &'f1 self, ) -> HFClientSyncCreateBucketBuilder<'f1, 'f2, 'f3>
Blocking counterpart of HFClient::create_bucket. See the async method for parameters
and behavior.
Sourcepub fn delete_bucket<'f1, 'f2>(
&'f1 self,
) -> HFClientSyncDeleteBucketBuilder<'f1, 'f2>
pub fn delete_bucket<'f1, 'f2>( &'f1 self, ) -> HFClientSyncDeleteBucketBuilder<'f1, 'f2>
Blocking counterpart of HFClient::delete_bucket. See the async method for parameters
and behavior.
Sourcepub fn list_buckets<'f1>(&'f1 self) -> HFClientSyncListBucketsBuilder<'f1>
pub fn list_buckets<'f1>(&'f1 self) -> HFClientSyncListBucketsBuilder<'f1>
Blocking counterpart of HFClient::list_buckets. Collects the stream into a
Vec<BucketInfo>. See the async method for parameters and behavior.
Sourcepub fn move_bucket<'f1, 'f2, 'f3>(
&'f1 self,
) -> HFClientSyncMoveBucketBuilder<'f1, 'f2, 'f3>
pub fn move_bucket<'f1, 'f2, 'f3>( &'f1 self, ) -> HFClientSyncMoveBucketBuilder<'f1, 'f2, 'f3>
Blocking counterpart of HFClient::move_bucket. See the async method for parameters
and behavior.
Source§impl HFClientSync
impl HFClientSync
Sourcepub fn scan_cache<'f1>(&'f1 self) -> HFClientSyncScanCacheBuilder<'f1>
Available on non-target_family=wasm only.
pub fn scan_cache<'f1>(&'f1 self) -> HFClientSyncScanCacheBuilder<'f1>
target_family=wasm only.Blocking counterpart of HFClient::scan_cache.
Source§impl HFClientSync
impl HFClientSync
Sourcepub fn list_models<'f1>(&'f1 self) -> HFClientSyncListModelsBuilder<'f1>
pub fn list_models<'f1>(&'f1 self) -> HFClientSyncListModelsBuilder<'f1>
Blocking counterpart of HFClient::list_models. Returns the collected stream as a
Vec<ModelInfo>. See the async method for parameters and behavior.
Sourcepub fn list_datasets<'f1>(&'f1 self) -> HFClientSyncListDatasetsBuilder<'f1>
pub fn list_datasets<'f1>(&'f1 self) -> HFClientSyncListDatasetsBuilder<'f1>
Blocking counterpart of HFClient::list_datasets. Returns the collected stream as a
Vec<DatasetInfo>. See the async method for parameters and behavior.
Sourcepub fn list_spaces<'f1>(&'f1 self) -> HFClientSyncListSpacesBuilder<'f1>
pub fn list_spaces<'f1>(&'f1 self) -> HFClientSyncListSpacesBuilder<'f1>
Blocking counterpart of HFClient::list_spaces. Returns the collected stream as a
Vec<SpaceInfo>. See the async method for parameters and behavior.
Sourcepub fn create_repository<'f1, 'f2, I1>(
&'f1 self,
) -> HFClientSyncCreateRepositoryBuilder<'f1, 'f2, I1>where
I1: RepoType,
pub fn create_repository<'f1, 'f2, I1>(
&'f1 self,
) -> HFClientSyncCreateRepositoryBuilder<'f1, 'f2, I1>where
I1: RepoType,
Blocking counterpart of HFClient::create_repository. See the async method for parameters and
behavior.
Sourcepub fn delete_repository<'f1, 'f2, I1>(
&'f1 self,
) -> HFClientSyncDeleteRepositoryBuilder<'f1, 'f2, I1>where
I1: RepoType,
pub fn delete_repository<'f1, 'f2, I1>(
&'f1 self,
) -> HFClientSyncDeleteRepositoryBuilder<'f1, 'f2, I1>where
I1: RepoType,
Blocking counterpart of HFClient::delete_repository. See the async method for parameters and
behavior.
Sourcepub fn move_repository<'f1, 'f2, 'f3, I1>(
&'f1 self,
) -> HFClientSyncMoveRepositoryBuilder<'f1, 'f2, 'f3, I1>where
I1: RepoType,
pub fn move_repository<'f1, 'f2, 'f3, I1>(
&'f1 self,
) -> HFClientSyncMoveRepositoryBuilder<'f1, 'f2, 'f3, I1>where
I1: RepoType,
Blocking counterpart of HFClient::move_repository. See the async method for parameters and
behavior.
Source§impl HFClientSync
impl HFClientSync
Sourcepub fn whoami<'f1>(&'f1 self) -> HFClientSyncWhoamiBuilder<'f1>
pub fn whoami<'f1>(&'f1 self) -> HFClientSyncWhoamiBuilder<'f1>
Blocking counterpart of HFClient::whoami.
Sourcepub fn user_overview<'f1, 'f2>(
&'f1 self,
) -> HFClientSyncUserOverviewBuilder<'f1, 'f2>
pub fn user_overview<'f1, 'f2>( &'f1 self, ) -> HFClientSyncUserOverviewBuilder<'f1, 'f2>
Blocking counterpart of HFClient::user_overview. See the async method for parameters
and behavior.
Sourcepub fn organization_overview<'f1, 'f2>(
&'f1 self,
) -> HFClientSyncOrganizationOverviewBuilder<'f1, 'f2>
pub fn organization_overview<'f1, 'f2>( &'f1 self, ) -> HFClientSyncOrganizationOverviewBuilder<'f1, 'f2>
Blocking counterpart of HFClient::organization_overview. See the async method for
parameters and behavior.
Sourcepub fn list_user_followers<'f1>(
&'f1 self,
) -> HFClientSyncListUserFollowersBuilder<'f1>
pub fn list_user_followers<'f1>( &'f1 self, ) -> HFClientSyncListUserFollowersBuilder<'f1>
Blocking counterpart of HFClient::list_user_followers. Collects the stream into a
Vec<User>. See the async method for parameters and behavior.
Sourcepub fn list_user_following<'f1>(
&'f1 self,
) -> HFClientSyncListUserFollowingBuilder<'f1>
pub fn list_user_following<'f1>( &'f1 self, ) -> HFClientSyncListUserFollowingBuilder<'f1>
Blocking counterpart of HFClient::list_user_following. Collects the stream into a
Vec<User>. See the async method for parameters and behavior.
Sourcepub fn list_organization_members<'f1>(
&'f1 self,
) -> HFClientSyncListOrganizationMembersBuilder<'f1>
pub fn list_organization_members<'f1>( &'f1 self, ) -> HFClientSyncListOrganizationMembersBuilder<'f1>
Blocking counterpart of HFClient::list_organization_members. Collects the stream into a
Vec<User>. See the async method for parameters and behavior.
Trait Implementations§
Source§impl Clone for HFClientSync
impl Clone for HFClientSync
Source§fn clone(&self) -> HFClientSync
fn clone(&self) -> HFClientSync
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for HFClientSync
impl !UnwindSafe for HFClientSync
impl Freeze for HFClientSync
impl Send for HFClientSync
impl Sync for HFClientSync
impl Unpin for HFClientSync
impl UnsafeUnpin for HFClientSync
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