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 is indicated by the presence of a +nmu[:digit:] suffix.
This is not part of the Debian Policy Manual, but it is commonly used to indicate a
sourceful NMU.
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.
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.
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>,
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,
impl Eq for Version
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
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.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.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
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.