Skip to main content

Version

Struct Version 

Source
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: String

The upstream version

§debian_revision: Option<String>

The Debian revision, if any

Implementations§

Source§

impl Version

Source

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()));
Source

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());
Source

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.

Source

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.

Source

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.

Source

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.

Source

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());
Source

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.

Source

pub fn is_native(&self) -> bool

Return true if this is a native package

Trait Implementations§

Source§

impl AsVersion for Version

Source§

fn into_version(self) -> Result<Version, ParseError>

Convert the argument into a Version
Source§

impl Clone for Version

Source§

fn clone(&self) -> Version

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Version

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Version

Available on crate feature serde only.
Source§

fn deserialize<D>( deserializer: D, ) -> Result<Version, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Version

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl FromPyObject<'_, '_> for Version

Available on crate feature python-debian only.
Source§

type Error = PyErr

The type returned in the event of a conversion error. Read more
Source§

fn extract(ob: Borrowed<'_, '_, PyAny>) -> Result<Version, PyErr>

Extracts Self from the bound smart pointer obj. Read more
Source§

impl FromStr for Version

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(text: &str) -> Result<Version, <Version as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Version

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'py> IntoPyObject<'py> for Version

Available on crate feature python-debian only.
Source§

type Target = PyAny

The Python output type
Source§

type Output = Bound<'py, <Version as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
Source§

type Error = PyErr

The type returned in the event of a conversion error.
Source§

fn into_pyobject( self, py: Python<'py>, ) -> Result<<Version as IntoPyObject<'py>>::Output, <Version as IntoPyObject<'py>>::Error>

Performs the conversion.
Source§

impl Ord for Version

Source§

fn cmp(&self, other: &Version) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Version

Source§

fn eq(&self, other: &Version) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Version

Source§

fn partial_cmp(&self, other: &Version) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Version

Available on crate feature serde only.
Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Version

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'py, T> IntoPyObjectExt<'py> for T
where T: IntoPyObject<'py>,

Source§

fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>

Converts self into an owned Python object, dropping type information.
Source§

fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>

Converts self into an owned Python object, dropping type information and unbinding it from the 'py lifetime.
Source§

fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>

Converts self into a Python object. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> PyErrArguments for T
where T: for<'py> IntoPyObject<'py> + Send + Sync,

Source§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<'py, T> FromPyObjectOwned<'py> for T
where T: for<'a> FromPyObject<'a, 'py>,

Source§

impl<T> Sequence for T
where T: Eq + Hash,

Source§

impl<T> Ungil for T
where T: Send,