pub enum UnresolvedVersionSpec {
Canary,
Alias(String),
Req(VersionReq),
ReqAny(Vec<VersionReq>),
Version(Version),
}
Expand description
Represents an unresolved version or alias that must be resolved to a fully-qualified and semantic result.
Variants§
Canary
A special canary target.
Alias(String)
An alias that is used as a map to a version.
Req(VersionReq)
A partial version, requirement, or range (^
, ~
, etc).
ReqAny(Vec<VersionReq>)
A list of requirements to match any against (joined by ||
).
Version(Version)
A fully-qualified semantic version.
Implementations§
source§impl UnresolvedVersionSpec
impl UnresolvedVersionSpec
sourcepub fn parse<T>(value: T) -> Result<UnresolvedVersionSpec, Error>
pub fn parse<T>(value: T) -> Result<UnresolvedVersionSpec, Error>
Parse the provided string into an unresolved specification based on the following rules, in order:
- If the value “canary”, map as
Canary
variant. - If an alpha-numeric value that starts with a character, map as
Alias
. - If contains
||
, split and parse each item withVersionReq
, and map asReqAny
. - If contains
,
orVersionReq
, and map asReq
. - If starts with
=
,^
,~
,>
,<
, or*
, parse withVersionReq
, and map asReq
. - Else parse with
Version
, and map asVersion
.
sourcepub fn is_alias<A>(&self, name: A) -> bool
pub fn is_alias<A>(&self, name: A) -> bool
Return true if the provided alias matches the current specification.
sourcepub fn is_latest(&self) -> bool
pub fn is_latest(&self) -> bool
Return true if the current specification is the “latest” alias.
sourcepub fn to_resolved_spec(&self) -> VersionSpec
pub fn to_resolved_spec(&self) -> VersionSpec
Convert the current unresolved specification to a resolved specification.
Note that this does not actually resolve or validate against a manifest,
and instead simply constructs the VersionSpec
.
Furthermore, the Req
and ReqAny
variants will panic, as they are not
resolved or valid versions.
Trait Implementations§
source§impl AsRef<UnresolvedVersionSpec> for UnresolvedVersionSpec
impl AsRef<UnresolvedVersionSpec> for UnresolvedVersionSpec
source§fn as_ref(&self) -> &UnresolvedVersionSpec
fn as_ref(&self) -> &UnresolvedVersionSpec
source§impl Clone for UnresolvedVersionSpec
impl Clone for UnresolvedVersionSpec
source§fn clone(&self) -> UnresolvedVersionSpec
fn clone(&self) -> UnresolvedVersionSpec
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for UnresolvedVersionSpec
impl Debug for UnresolvedVersionSpec
source§impl Default for UnresolvedVersionSpec
impl Default for UnresolvedVersionSpec
source§fn default() -> UnresolvedVersionSpec
fn default() -> UnresolvedVersionSpec
Returns a latest
alias.
source§impl<'de> Deserialize<'de> for UnresolvedVersionSpec
impl<'de> Deserialize<'de> for UnresolvedVersionSpec
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<UnresolvedVersionSpec, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<UnresolvedVersionSpec, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl Display for UnresolvedVersionSpec
impl Display for UnresolvedVersionSpec
source§impl FromStr for UnresolvedVersionSpec
impl FromStr for UnresolvedVersionSpec
source§impl Hash for UnresolvedVersionSpec
impl Hash for UnresolvedVersionSpec
source§impl Into<String> for UnresolvedVersionSpec
impl Into<String> for UnresolvedVersionSpec
source§impl PartialEq<VersionSpec> for UnresolvedVersionSpec
impl PartialEq<VersionSpec> for UnresolvedVersionSpec
source§fn eq(&self, other: &VersionSpec) -> bool
fn eq(&self, other: &VersionSpec) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq for UnresolvedVersionSpec
impl PartialEq for UnresolvedVersionSpec
source§fn eq(&self, other: &UnresolvedVersionSpec) -> bool
fn eq(&self, other: &UnresolvedVersionSpec) -> bool
self
and other
values to be equal, and is used
by ==
.