Struct crates_index::Index
source · pub struct Index { /* private fields */ }
Expand description
Wrapper around managing the crates.io-index git repository
Uses a “bare” git index that fetches files directly from the repo instead of local checkout. Uses Cargo’s cache.
Implementations§
source§impl Index
impl Index
sourcepub fn new_cargo_default() -> Result<Self, Error>
pub fn new_cargo_default() -> Result<Self, Error>
Creates an index for the default crates.io registry, using the same disk location as Cargo itself.
This is the recommended way to access Cargo’s index.
Note this function takes the CARGO_HOME
environment variable into account
sourcepub fn from_url(url: &str) -> Result<Self, Error>
pub fn from_url(url: &str) -> Result<Self, Error>
Creates a bare index from a provided URL, opening the same location on disk that Cargo uses for that registry index.
It can be used to access custom registries.
source§impl Index
impl Index
sourcepub fn update(&mut self) -> Result<(), Error>
pub fn update(&mut self) -> Result<(), Error>
Fetches latest from the remote index repository. Note that using this method will mean no cache entries will be used, if a new commit is fetched from the repository, as their commit version will no longer match.
sourcepub fn crate_(&self, name: &str) -> Option<Crate>
pub fn crate_(&self, name: &str) -> Option<Crate>
Reads a crate from the index, it will attempt to use a cached entry if one is available, otherwise it will fallback to reading the crate directly from the git blob containing the crate information.
Use this only if you need to get very few crates. If you’re going
to read majority of crates, prefer the Index::crates()
iterator.
sourcepub fn crates(&self) -> Crates<'_> ⓘ
pub fn crates(&self) -> Crates<'_> ⓘ
Single-threaded iterator over all the crates in the index.
Index::crates_parallel
is typically 3 times faster.
Skips crates that can not be parsed (but there shouldn’t be any such crates in the crates-io index).
sourcepub fn crates_parallel(
&self
) -> impl ParallelIterator<Item = Result<Crate, CratesIterError>> + '_
pub fn crates_parallel( &self ) -> impl ParallelIterator<Item = Result<Crate, CratesIterError>> + '_
Iterate over all crates using rayon.
This method is available only if the “parallel” feature is enabled.
sourcepub fn index_config(&self) -> Result<IndexConfig, Error>
pub fn index_config(&self) -> Result<IndexConfig, Error>
Get the global configuration of the index.