pub struct Index { /* private fields */ }Expand description
A representation of a crates registry, backed by both a directory and a git repository on the filesystem.
This struct is essentially a thin wrapper around both an index Tree and
a git Repository.
It functions exactly the same way as a Tree, except that all changes to
the crates index are also committed to the git repository, which allows this
to be synced to a remote.
Implementations§
Source§impl Index
impl Index
Sourcepub fn initialise<'a>(
root: impl Into<PathBuf>,
download: impl Into<String>,
) -> Builder<'a>
pub fn initialise<'a>( root: impl Into<PathBuf>, download: impl Into<String>, ) -> Builder<'a>
Create a new index.
The root path, and the URL for downloading .crate files is required.
Additional options can be set using the builder API (see
Builder for options).
§Example
§Basic Config
use crate_index::Index;
let root = "/index";
let download = "https://my-crates-server.com/api/v1/crates/{crate}/{version}/download";
let index = Index::initialise(root, download).build().await?;§More Options
use crate_index::{Index, Url};
let root = "/index";
let download = "https://my-crates-server.com/api/v1/crates/{crate}/{version}/download";
let origin = Url::parse("https://github.com/crates/index.git").unwrap();
let index = Index::initialise(root, download)
.api(Url::parse("https://my-crates-server.com/").unwrap())
.allowed_registry(Url::parse("https://my-intranet:8080/index").unwrap())
.allow_crates_io()
.origin(origin)
.build()
.await?;Sourcepub async fn open(root: impl Into<PathBuf>) -> Result<Self>
pub async fn open(root: impl Into<PathBuf>) -> Result<Self>
Open an existing index at the given root path.
§Example
use crate_index::Index;
let root = "/index";
let index = Index::open("/index").await?;Sourcepub async fn insert(&mut self, crate_metadata: Metadata) -> Result<()>
pub async fn insert(&mut self, crate_metadata: Metadata) -> Result<()>
Insert crate [‘Metadata’] into the index.
§Errors
This method can fail if the metadata is deemed to be invalid, or if the filesystem cannot be written to.
Sourcepub fn allowed_registries(&self) -> &Vec<Url>
pub fn allowed_registries(&self) -> &Vec<Url>
The list of registries which crates in this index are allowed to have dependencies on
Sourcepub fn into_parts(self) -> (Tree, Repository)
pub fn into_parts(self) -> (Tree, Repository)
Split this Index into its constituent parts
Auto Trait Implementations§
impl Freeze for Index
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> 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> 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