pub struct Tree { /* private fields */ }Expand description
An interface to a crate index directory on the filesystem
Implementations§
Source§impl Tree
impl Tree
Sourcepub fn initialise(
root: impl Into<PathBuf>,
download: impl Into<String>,
) -> Builder
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?;Sourcepub async fn open(root: impl Into<PathBuf>) -> Result<Self>
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.
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 async fn yank(
&self,
crate_name: impl Into<String>,
version: &Version,
) -> Result<()>
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.
Sourcepub async fn unyank(
&self,
crate_name: impl Into<String>,
version: &Version,
) -> Result<()>
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.
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 contains_crate(&self, name: impl AsRef<str>) -> bool
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> 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