Struct specifications::package::PackageIndex
source · pub struct PackageIndex {
pub packages: HashMap<String, PackageInfo>,
pub latest: HashMap<String, (Version, String)>,
}
Expand description
Collects multiple PackageInfos into one database, called the package index.
Fields§
§packages: HashMap<String, PackageInfo>
The list of packages stored in the index.
latest: HashMap<String, (Version, String)>
Cache of the standard ‘latest’ packages so we won’t have to search every time.
Implementations§
source§impl PackageIndex
impl PackageIndex
sourcepub fn empty() -> Self
pub fn empty() -> Self
Constructor for the PackageIndex that initializes it to having no packages.
sourcepub fn new(packages: HashMap<String, PackageInfo>) -> Self
pub fn new(packages: HashMap<String, PackageInfo>) -> Self
Constructor for the PackageIndex.
Arguments
packages
: The map of packages to base this index on. Each key should be<name>-<version>
(i.e., every package version is a separate entry).
sourcepub fn from_path(path: &Path) -> Result<Self, PackageIndexError>
pub fn from_path(path: &Path) -> Result<Self, PackageIndexError>
Edited: Returns PackageIndexErrors now.
Tries to construct a new PackageIndex from the application file at the given path.
Arguments
path
: Path to the application file.
Returns
The new PackageIndex if it all went fine, or a PackageIndexError if it didn’t.
sourcepub fn from_reader<R: Read>(r: R) -> Result<Self, PackageIndexError>
pub fn from_reader<R: Read>(r: R) -> Result<Self, PackageIndexError>
Edited: Returns PackageIndexErrors now.
Tries to construct a new PackageIndex from the given reader.
Arguments
r
: The reader that contains the data to construct the PackageIndex from.
Returns
The new PackageIndex if it all went fine, or a PackageIndexError if it didn’t.
sourcepub async fn from_url(url: &str) -> Result<Self, PackageIndexError>
pub async fn from_url(url: &str) -> Result<Self, PackageIndexError>
Edited: Returns PackageIndexErrors now.
Tries to construct a new PackageIndex from a JSON file at the given URL.
Arguments
url
: The location of the JSON file to parse.
Returns
The new PackageIndex if it all went fine, or a PackageIndexError if it didn’t.
sourcepub fn from_value(v: JValue) -> Result<Self, PackageIndexError>
pub fn from_value(v: JValue) -> Result<Self, PackageIndexError>
Edited: Returns PackageIndexErrors now.
Tries to construct a new PackageIndex from the given JSON-parsed value.
Arguments
v
: The JSON root value of the tree to parse.
Returns
The new PackageIndex if it all went fine, or a PackageIndexError if it didn’t.
sourcepub fn from_packages(
known_packages: Vec<PackageInfo>,
) -> Result<Self, PackageIndexError>
pub fn from_packages( known_packages: Vec<PackageInfo>, ) -> Result<Self, PackageIndexError>
Edited: Returns PackageIndexErrors now.
Tries to construct a new PackageIndex from a list of PackageInfos.
Arguments
known_packages
: List of PackageInfos to incorporate in the PackageIndex.
Returns
The new PackageIndex if it all went fine, or a PackageIndexError if it didn’t.
sourcepub fn get(&self, name: &str, version: Option<&Version>) -> Option<&PackageInfo>
pub fn get(&self, name: &str, version: Option<&Version>) -> Option<&PackageInfo>
Returns the package with the given name and (optional) version.
Arguments
name
: The name of the package.version
: The version of the package to get. If omitted, uses the latest version known to the PackageIndex.
Returns
An (immuteable) reference to the package if it exists, or else None.
Trait Implementations§
source§impl Clone for PackageIndex
impl Clone for PackageIndex
source§fn clone(&self) -> PackageIndex
fn clone(&self) -> PackageIndex
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PackageIndex
impl Debug for PackageIndex
source§impl Default for PackageIndex
impl Default for PackageIndex
source§fn default() -> PackageIndex
fn default() -> PackageIndex
Auto Trait Implementations§
impl Freeze for PackageIndex
impl RefUnwindSafe for PackageIndex
impl Send for PackageIndex
impl Sync for PackageIndex
impl Unpin for PackageIndex
impl UnwindSafe for PackageIndex
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request