Struct tame_index::index::AsyncRemoteSparseIndex
source · pub struct AsyncRemoteSparseIndex {
pub index: SparseIndex,
pub client: AsyncClient,
}
sparse
only.Expand description
Allows async access to a remote HTTP sparse registry index
Fields§
§index: SparseIndex
The local index this remote is wrapping
client: AsyncClient
The client used to make requests to the remote index
Implementations§
source§impl AsyncRemoteSparseIndex
impl AsyncRemoteSparseIndex
sourcepub fn new(index: SparseIndex, client: AsyncClient) -> Self
pub fn new(index: SparseIndex, client: AsyncClient) -> Self
Creates a new Self
that can access and write local cache entries,
and contact the remote index to retrieve the latest index information
sourcepub async fn krate_async(
&self,
name: KrateName<'_>,
write_cache_entry: bool,
lock: &FileLock,
) -> Result<Option<IndexKrate>, Error>
pub async fn krate_async( &self, name: KrateName<'_>, write_cache_entry: bool, lock: &FileLock, ) -> Result<Option<IndexKrate>, Error>
Async version of RemoteSparseIndex::krate
sourcepub fn cached_krate(
&self,
name: KrateName<'_>,
lock: &FileLock,
) -> Result<Option<IndexKrate>, Error>
pub fn cached_krate( &self, name: KrateName<'_>, lock: &FileLock, ) -> Result<Option<IndexKrate>, Error>
Attempts to read the locally cached crate information
This method does no network I/O unlike Self::krate_async
, but does not
guarantee that the cache information is up to date with the latest in
the remote index
sourcepub async fn krates(
&self,
krates: BTreeSet<String>,
write_cache_entries: bool,
individual_timeout: Option<Duration>,
lock: &FileLock,
) -> BTreeMap<String, Result<Option<IndexKrate>, Error>>
pub async fn krates( &self, krates: BTreeSet<String>, write_cache_entries: bool, individual_timeout: Option<Duration>, lock: &FileLock, ) -> BTreeMap<String, Result<Option<IndexKrate>, Error>>
Helper method for downloading multiples crates concurrently
This method will generally perform better than RemoteSparseIndex::krates
One notable difference with this method is that you can specify a maximum duration that each individual krate request can take before it is timed out. This is because certain errors can occur when making many concurrent requests, which we detect and retry automatically, but with (by default) no upper bound in number of retries/time.
You can also run this entire operation with a single timeout if you wish,
via something like tokio::time::timeout
sourcepub fn krates_blocking(
&self,
krates: BTreeSet<String>,
write_cache_entries: bool,
individual_timeout: Option<Duration>,
lock: &FileLock,
) -> Result<BTreeMap<String, Result<Option<IndexKrate>, Error>>, TryCurrentError>
pub fn krates_blocking( &self, krates: BTreeSet<String>, write_cache_entries: bool, individual_timeout: Option<Duration>, lock: &FileLock, ) -> Result<BTreeMap<String, Result<Option<IndexKrate>, Error>>, TryCurrentError>
A non-async version of Self::krates
Using this method requires that there is an active tokio runtime as described here
Auto Trait Implementations§
impl Freeze for AsyncRemoteSparseIndex
impl !RefUnwindSafe for AsyncRemoteSparseIndex
impl Send for AsyncRemoteSparseIndex
impl Sync for AsyncRemoteSparseIndex
impl Unpin for AsyncRemoteSparseIndex
impl !UnwindSafe for AsyncRemoteSparseIndex
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> 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