[][src]Struct crate_index::index::Index

pub struct Index { /* fields omitted */ }

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.

Methods

impl Index[src]

pub fn init<'a>(
    root: impl Into<PathBuf>,
    download: impl Into<String>
) -> IndexBuilder<'a>
[src]

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 IndexBuilder 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::init(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::init(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?;

pub async fn open(root: impl Into<PathBuf>) -> Result<Self>[src]

Open an existing index at the given root path.

Example

use crate_index::Index;
let root = "/index";

let index = Index::open("/index").await?;

pub async fn insert<'_>(&'_ mut self, crate_metadata: Metadata) -> Result<()>[src]

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.

pub fn root(&self) -> &PathBuf[src]

The location on the filesystem of the root of the index

pub fn download(&self) -> &String[src]

The Url for downloading .crate files

pub fn api(&self) -> &Option<Url>[src]

The Url of the API

pub fn allowed_registries(&self) -> &Vec<Url>[src]

The list of registries which crates in this index are allowed to have dependencies on

pub fn into_parts(self) -> (Tree, Repository)[src]

Split this Index into its constituent parts

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.