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

source

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

source

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

pub fn with_path<P: Into<PathBuf>, S: Into<String>>( path: P, url: S ) -> Result<Self, Error>

Creates a bare index at the provided path with the specified repository URL.

source

pub fn path(&self) -> &Path

Get the index directory.

source

pub fn url(&self) -> &str

Get the index url.

source

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.

source

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.

source

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).

source

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.

source

pub fn index_config(&self) -> Result<IndexConfig, Error>

Get the global configuration of the index.

Auto Trait Implementations§

§

impl RefUnwindSafe for Index

§

impl Send for Index

§

impl !Sync for Index

§

impl Unpin for Index

§

impl UnwindSafe for Index

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.