Struct Index

Source
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

Source

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?;
Source

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?;
Source

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.

Source

pub fn root(&self) -> &PathBuf

The location on the filesystem of the root of the index

Source

pub fn download(&self) -> &String

The Url for downloading .crate files

Source

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

The Url of the API

Source

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

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

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

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

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,