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

Construct an instance by parsing a version string.

The epoch component of the version string.

Only Some if present or defined explicitly.

Assumed value of epoch component.

If the component isn’t explicitly defined, a default of 0 will be assumed.

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.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

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

Returns the argument unchanged.

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

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

Calls U::from(self).

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

Should always be Self

The resulting type after obtaining ownership.

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

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

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