pub struct Version {
pub epoch: Option<u32>,
pub upstream_version: String,
pub debian_revision: Option<String>,
}Expand description
A Debian version string
Fields§
§epoch: Option<u32>The epoch of the version, if any
upstream_version: StringThe upstream version
debian_revision: Option<String>The Debian revision, if any
Implementations§
Source§impl Version
impl Version
Sourcepub fn parse_lenient(text: &str) -> Result<Version, ParseError>
pub fn parse_lenient(text: &str) -> Result<Version, ParseError>
Parse a version string with lenient parsing rules.
This method accepts version strings that may not strictly comply with Debian Policy,
such as versions containing underscores. While the standard FromStr implementation
enforces strict Debian Policy compliance, this method is more permissive to handle
real-world packages that may use non-standard characters.
§Examples
use debversion::Version;
// This version contains underscores, which violates Debian Policy
// but may appear in real-world packages
let v = Version::parse_lenient("2.0.37+cvs.JCW_PRE2_2037-1").unwrap();
assert_eq!(v.upstream_version, "2.0.37+cvs.JCW_PRE2_2037");
assert_eq!(v.debian_revision, Some("1".to_string()));Sourcepub fn is_bin_nmu(&self) -> bool
pub fn is_bin_nmu(&self) -> bool
Is this a binNMU?
A binNMU is a binary-only NMU (Non-Maintainer Upload) where the source package is not changed.
Note that this checks for the presence of the +b[:digit:] suffix, which is not part of the Debian
Policy Manual, but it is commonly used to indicate a binNMU.
§Examples
use debversion::Version;
assert!("1.0+b1".parse::<Version>().unwrap().is_bin_nmu());
assert!("1.0-1+b1".parse::<Version>().unwrap().is_bin_nmu());
assert!(!"1.0-1".parse::<Version>().unwrap().is_bin_nmu());
assert!(!"1.0".parse::<Version>().unwrap().is_bin_nmu());Sourcepub fn bin_nmu_count(&self) -> Option<i32>
pub fn bin_nmu_count(&self) -> Option<i32>
Return the binNMU count of this version
This will return the binNMU count of this version, or None if this is not a binNMU.
Sourcepub fn increment_bin_nmu(self) -> Version
pub fn increment_bin_nmu(self) -> Version
Create a binNMU version from this version
This will increment the binNMU suffix by one, or add a +b1 suffix if there is no binNMU
suffix.
Sourcepub fn is_nmu(&self) -> bool
pub fn is_nmu(&self) -> bool
Check if this version is a sourceful NMU
A sourceful NMU is a Non-Maintainer Upload where the source package is changed.
This recognises two conventions:
- a
+nmu[:digit:]suffix, used for native packages (and sometimes derivatives). This is not part of the Debian Policy Manual, but it is commonly used to indicate a sourceful NMU. - the classic non-native form, where the Debian revision of the last
maintainer upload is extended with a
.[:digit:]component, e.g.1becomes1.1and2.1becomes2.2.
Sourcepub fn nmu_count(&self) -> Option<i32>
pub fn nmu_count(&self) -> Option<i32>
Return the sourceful NMU count of this version
This will return the sourceful NMU count of this version, or None if this is not a
sourceful NMU. See Version::is_nmu for the conventions that are recognised.
Sourcepub fn is_backport(&self) -> bool
pub fn is_backport(&self) -> bool
Check if this version is a backport.
Backports use a ~bpoN+M suffix, where N is the Debian release
number being targeted and M the backport revision, e.g.
1.0-1~bpo12+1. Such uploads are made by the maintainer and are
exempt from the sourceful NMU check.
§Examples
use debversion::Version;
assert!("1.0-1~bpo12+1".parse::<Version>().unwrap().is_backport());
assert!("1.0-1~bpo11+2".parse::<Version>().unwrap().is_backport());
assert!(!"1.0-1".parse::<Version>().unwrap().is_backport());Sourcepub fn is_stable_update(&self) -> bool
pub fn is_stable_update(&self) -> bool
Check if this version is a stable or security update.
Stable and security updates use a ~debNuM or +debNuM suffix,
where N is the Debian release number and M the update revision,
e.g. 1.0-1+deb12u1. Such uploads are exempt from the sourceful NMU
check.
§Examples
use debversion::Version;
assert!("1.0-1+deb12u1".parse::<Version>().unwrap().is_stable_update());
assert!("1.0-1~deb11u2".parse::<Version>().unwrap().is_stable_update());
assert!(!"1.0-1".parse::<Version>().unwrap().is_stable_update());Sourcepub fn canonicalize(&self) -> Version
pub fn canonicalize(&self) -> Version
Return canonicalized version of this version
§Examples
use debversion::Version;
assert_eq!("1.0-0".parse::<Version>().unwrap().canonicalize(), "1.0".parse::<Version>().unwrap());
assert_eq!("1.0-1".parse::<Version>().unwrap().canonicalize(), "1.0-1".parse::<Version>().unwrap());Sourcepub fn increment_debian(&mut self)
pub fn increment_debian(&mut self)
Increment the Debian revision.
For native packages, increment the upstream version number. For other packages, increment the debian revision.
Sourcepub fn bump_nmu(self) -> Version
pub fn bump_nmu(self) -> Version
Create a sourceful NMU version from this version.
For native packages (those without a Debian revision), this appends a
+nmu1 suffix to the upstream version, or bumps an existing +nmuN
suffix.
For non-native packages, the Debian revision is bumped following the
NMU convention: 1 becomes 1.1, 2 becomes 2.1 (first NMU) and
1.1 becomes 1.2 (further NMU). For revisions that don’t follow the
plain integer or integer.integer shape (e.g. 1ubuntu1), where the
correct NMU revision cannot be derived mechanically, a +nmuN suffix
is appended to the Debian revision instead.
§Examples
use debversion::Version;
assert_eq!(
"1.0".parse::<Version>().unwrap().bump_nmu(),
"1.0+nmu1".parse().unwrap()
);
assert_eq!(
"1.0+nmu1".parse::<Version>().unwrap().bump_nmu(),
"1.0+nmu2".parse().unwrap()
);
assert_eq!(
"1.0-1".parse::<Version>().unwrap().bump_nmu(),
"1.0-1.1".parse().unwrap()
);
assert_eq!(
"1.0-2.1".parse::<Version>().unwrap().bump_nmu(),
"1.0-2.2".parse().unwrap()
);Trait Implementations§
Source§impl AsVersion for Version
impl AsVersion for Version
Source§fn into_version(self) -> Result<Version, ParseError>
fn into_version(self) -> Result<Version, ParseError>
Source§impl<'de> Deserialize<'de> for Version
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Version
serde only.Source§fn deserialize<D>(
deserializer: D,
) -> Result<Version, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Version, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
impl Eq for Version
Source§impl FromPyObject<'_, '_> for Version
Available on crate feature python-debian only.
impl FromPyObject<'_, '_> for Version
python-debian only.Source§impl<'py> IntoPyObject<'py> for Version
Available on crate feature python-debian only.
impl<'py> IntoPyObject<'py> for Version
python-debian only.Source§type Output = Bound<'py, <Version as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <Version as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Version as IntoPyObject<'py>>::Output, <Version as IntoPyObject<'py>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Version as IntoPyObject<'py>>::Output, <Version as IntoPyObject<'py>>::Error>
Source§impl Ord for Version
impl Ord for Version
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Version
impl PartialOrd for Version
Source§impl Serialize for Version
Available on crate feature serde only.
impl Serialize for Version
serde only.Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Auto Trait Implementations§
impl Freeze for Version
impl RefUnwindSafe for Version
impl Send for Version
impl Sync for Version
impl Unpin for Version
impl UnsafeUnpin for Version
impl UnwindSafe for Version
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
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<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.impl<'py, T> FromPyObjectOwned<'py> for Twhere
T: for<'a> FromPyObject<'a, 'py>,
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<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
Source§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.