Struct debian_packaging::package_version::PackageVersion
source · [−]pub struct PackageVersion { /* private fields */ }Expand description
A Debian package version.
Debian package versions consist of multiple sub-components and have rules about sorting. The semantics are defined at https://www.debian.org/doc/debian-policy/ch-controlfields.html#version. This type attempts to implement all the details.
The concise version is the format is [epoch:]upstream_version[-debian_revision]
and each component has rules about what characters are allowed. Our
Self::parse() should be compliant with the specification and reject invalid
version strings and parse components to the appropriate field.
This type implements a custom ordering function that implements the complex rules around Debian package version ordering.
use debian_packaging::package_version::PackageVersion;
let v = PackageVersion::parse("1:4.7.0+dfsg1-2").unwrap();
assert_eq!(v.epoch(), Some(1));
assert_eq!(v.upstream_version(), "4.7.0+dfsg1");
assert_eq!(v.debian_revision(), Some("2"));
assert_eq!(format!("{}", v), "1:4.7.0+dfsg1-2");
assert!(v < PackageVersion::parse("1:4.7.0+dfsg1-3").unwrap());Implementations
sourceimpl PackageVersion
impl PackageVersion
sourcepub fn epoch(&self) -> Option<u32>
pub fn epoch(&self) -> Option<u32>
The epoch component of the version string.
Only Some if present or defined explicitly.
sourcepub fn epoch_assumed(&self) -> u32
pub fn epoch_assumed(&self) -> u32
Assumed value of epoch component.
If the component isn’t explicitly defined, a default of 0 will be assumed.
sourcepub fn upstream_version(&self) -> &str
pub fn upstream_version(&self) -> &str
upstream component of the version string.
This is the main part of the version number.
It is typically the original version of the software from which this package came. Although it may be massaged to be compatible with packaging requirements.
sourcepub fn debian_revision(&self) -> Option<&str>
pub fn debian_revision(&self) -> Option<&str>
debian_revision component of the version string.
The part of the version string that specifies the version of the Debian package based on the upstream version.
Trait Implementations
sourceimpl Clone for PackageVersion
impl Clone for PackageVersion
sourcefn clone(&self) -> PackageVersion
fn clone(&self) -> PackageVersion
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for PackageVersion
impl Debug for PackageVersion
sourceimpl Display for PackageVersion
impl Display for PackageVersion
sourceimpl Ord for PackageVersion
impl Ord for PackageVersion
sourceimpl PartialEq<PackageVersion> for PackageVersion
impl PartialEq<PackageVersion> for PackageVersion
sourcefn eq(&self, other: &PackageVersion) -> bool
fn eq(&self, other: &PackageVersion) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &PackageVersion) -> bool
fn ne(&self, other: &PackageVersion) -> bool
This method tests for !=.
sourceimpl PartialOrd<PackageVersion> for PackageVersion
impl PartialOrd<PackageVersion> for PackageVersion
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl Eq for PackageVersion
impl StructuralEq for PackageVersion
impl StructuralPartialEq for PackageVersion
Auto Trait Implementations
impl RefUnwindSafe for PackageVersion
impl Send for PackageVersion
impl Sync for PackageVersion
impl Unpin for PackageVersion
impl UnwindSafe for PackageVersion
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key and return true if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more