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