pub struct PackageId<V = MaybeVersion> { /* private fields */ }
Expand description
A unique identifier for a package that describes its registry, group, name, and (possibly) version.
There are two different variations of a PackageId, which have different formatting and parsing rules.
- A
PackageId<WithVersion>
represents a fully-qualified package name that also refers to a specific version of the package. It is rendered (and parsed) as a string in the following form:
<registry>/<group>/<name>:<version>
OR
<group>/<name>:<version>
OR
<name>:<version>
Note that a PackageId<WithVersion>
has strong guarantees on its
FromStr
implementation (and therefore, it’s parse()
rules). This
means that a PackageId<WithVersion>
is guaranteed to have a version
embedded in it, which can be accessed via .version()
.
- A
PackageId
(i.e.PackageId<MaybeVersion>
) might or might not contain a version, and will parse a package string that does OR does not have a version in it. This is the type you should use if you don’t need a version or if you want to do something different based on whether or not a version is given. An example of this might be installing a specific version of a package if a version is given, or defaulting to the latest version if not given.
Valid forms that will parse into a PackageId
include:
<registry>/<group>/<name>
<group>/<name>
<name>
<registry>/<group>/<name>:<version>
<group>/<name>:<version>
<name>:<version>
Implementations§
Source§impl<T> PackageId<T>
impl<T> PackageId<T>
Sourcepub fn registry(&self) -> &Registry
pub fn registry(&self) -> &Registry
Return the registry of the package specified by this identifier
Sourcepub fn name(&self) -> &PackageName
pub fn name(&self) -> &PackageName
Return the name of the package specified by this identifier
Sourcepub fn pretty(&self) -> impl Display
pub fn pretty(&self) -> impl Display
A printable representation of this PackageId
This displays the most concise representation of this PackageId
that is still unique.
For example, if the registry and group name are default values, this will display only
the package name. If the group name is non-standard, it will be printed. If the registry
is non-standard, both the registry and the group name will be printed.
Sourcepub fn uid(&self) -> String
pub fn uid(&self) -> String
A unique representation of this package, excluding version.
This is intended to be used for comparing two PackageId’s to see whether they refer to the same package entity, regardless of version.
§Example
let pid1: PackageId<MaybeVersion> = "fluvio/fluvio".parse().unwrap();
let pid2: PackageId<WithVersion> = "https://packages.fluvio.io/v1/fluvio/fluvio:1.2.3".parse().unwrap();
assert_eq!(pid1.uid(), pid2.uid());
Source§impl PackageId<WithVersion>
impl PackageId<WithVersion>
Sourcepub fn version(&self) -> &PackageVersion
pub fn version(&self) -> &PackageVersion
A PackageId
Sourcepub fn into_version(self) -> PackageVersion
pub fn into_version(self) -> PackageVersion
Return the inner PackageVersion, consuming the PackageId
Sourcepub fn into_maybe_versioned(self) -> PackageId<MaybeVersion>
pub fn into_maybe_versioned(self) -> PackageId<MaybeVersion>
Convert to a PackageId<WithVersion>
preserving the inner Version
Sourcepub fn into_unversioned(self) -> PackageId<MaybeVersion>
pub fn into_unversioned(self) -> PackageId<MaybeVersion>
Convert to a PackageId<WithVersion>
, dropping the inner Version
Source§impl PackageId<MaybeVersion>
impl PackageId<MaybeVersion>
Sourcepub fn into_versioned(self, version: PackageVersion) -> PackageId<WithVersion>
pub fn into_versioned(self, version: PackageVersion) -> PackageId<WithVersion>
Add a Version to any PackageId to create a PackageId