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§
Source§impl 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§
Source§impl Clone for PackageVersion
impl Clone for PackageVersion
Source§fn clone(&self) -> PackageVersion
fn clone(&self) -> PackageVersion
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PackageVersion
impl Debug for PackageVersion
Source§impl Display for PackageVersion
impl Display for PackageVersion
Source§impl Hash for PackageVersion
impl Hash for PackageVersion
Source§impl Ord for PackageVersion
impl Ord for PackageVersion
Source§impl PartialEq for PackageVersion
impl PartialEq for PackageVersion
Source§impl PartialOrd for PackageVersion
impl PartialOrd for PackageVersion
impl Eq for PackageVersion
impl StructuralPartialEq for PackageVersion
Auto Trait Implementations§
impl Freeze for PackageVersion
impl RefUnwindSafe for PackageVersion
impl Send for PackageVersion
impl Sync for PackageVersion
impl Unpin for PackageVersion
impl UnwindSafe for PackageVersion
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§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.