Struct Tree

Source
pub struct Tree { /* private fields */ }
Expand description

An interface to a crate index directory on the filesystem

Implementations§

Source§

impl Tree

Source

pub fn initialise( root: impl Into<PathBuf>, download: impl Into<String>, ) -> Builder

Create a new index Tree.

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::Tree;
let root = "/index";
let download = "https://my-crates-server.com/api/v1/crates/{crate}/{version}/download";

let index_tree = Tree::initialise(root, download).build().await?;
§More Options
use crate_index::{index::Tree, Url};
let root = "/index";
let download = "https://my-crates-server.com/api/v1/crates/{crate}/{version}/download";


let index_tree = Tree::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()
    .build()
    .await?;
Source

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

Open an existing index tree at the given root path.

§Errors

This method can fail if the given path does not exist, or the config file cannot be read.

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 async fn yank( &self, crate_name: impl Into<String>, version: &Version, ) -> Result<()>

Mark a selected version of a crate as ‘yanked’.

§Errors

This function will return Error::NotFound if the crate or the selected version does not exist in the index.

Source

pub async fn unyank( &self, crate_name: impl Into<String>, version: &Version, ) -> Result<()>

Mark a selected version of a crate as ‘unyanked’.

§Errors

This function will return Error::NotFound if the crate or the selected version does not exist in the index.

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 contains_crate(&self, name: impl AsRef<str>) -> bool

Test whether the index contains a particular crate name.

This method is fast, since the crate names are stored in memory.

Auto Trait Implementations§

§

impl Freeze for Tree

§

impl RefUnwindSafe for Tree

§

impl Send for Tree

§

impl Sync for Tree

§

impl Unpin for Tree

§

impl UnwindSafe for Tree

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, 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> ErasedDestructor for T
where T: 'static,