Struct versions::Mess

source ·
pub struct Mess {
    pub chunks: Vec<MChunk>,
    pub next: Option<(Sep, Box<Mess>)>,
}
Expand description

A complex version number with no specific structure.

Like Version this is a descriptive scheme, but it is based on examples of stupidly crafted, near-lawless version numbers used in the wild. Versions like this are a considerable burden to package management software.

With Mess, groups of letters/numbers are separated by a period, but can be further separated by the symbols _-+:.

Unfortunately, Chunk cannot be used here, as some developers have numbers like 1.003.04 which make parsers quite sad.

Some Mess values have a shape that is tantalizingly close to a SemVer. Example: 1.6.0a+2014+m872b87e73dfb-1. For values like these, we can extract the SemVer-compatible values out with Mess::nth.

In general this is not guaranteed to have well-defined ordering behaviour, but existing tests show sufficient consistency. Mess::nth is used internally where appropriate to enhance accuracy.

§Examples

use versions::{Mess, SemVer, Version};

let mess = "20.0026.1_0-2+0.93";

let s = SemVer::new(mess);
let v = Version::new(mess);
let m = Mess::new(mess);

assert!(s.is_none());
assert!(v.is_none());
assert_eq!(Some(mess.to_string()), m.map(|v| format!("{}", v)));

Fields§

§chunks: Vec<MChunk>

The first section of a Mess.

§next: Option<(Sep, Box<Mess>)>

The rest of the Mess.

Implementations§

source§

impl Mess

source

pub fn new(s: &str) -> Option<Mess>

Parse a Mess from some input.

source

pub fn nth(&self, x: usize) -> Option<u32>

Try to extract a position from the Mess as a nice integer, as if it were a SemVer.

use versions::Mess;

let mess = Mess::new("1.6a.0+2014+m872b87e73dfb-1").unwrap();
assert_eq!(Some(1), mess.nth(0));
assert_eq!(None, mess.nth(1));
assert_eq!(Some(0), mess.nth(2));
source

pub fn parse(i: &str) -> IResult<&str, Mess>

The raw nom parser for Mess. Feel free to use this in combination with other general nom parsers.

Trait Implementations§

source§

impl Clone for Mess

source§

fn clone(&self) -> Mess

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Mess

source§

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

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

impl Default for Mess

source§

fn default() -> Mess

Returns the “default value” for a type. Read more
source§

impl Display for Mess

source§

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

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

impl FromStr for Mess

§

type Err = Error

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

fn from_str(s: &str) -> Result<Self, Self::Err>

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

impl Hash for Mess

source§

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

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 Ord for Mess

Build metadata does not affect version precendence, and pre-release versions have lower precedence than normal versions.

source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · source§

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

Compares and returns the maximum of two values. Read more
1.21.0 · source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · source§

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

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

impl PartialEq for Mess

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Mess

source§

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

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

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

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

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

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

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

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

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

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

impl TryFrom<&str> for Mess

source§

fn try_from(value: &str) -> Result<Self, Self::Error>

use versions::Mess;

let orig = "1.2.3.4_123_abc+101a";
let prsd: Mess = orig.try_into().unwrap();
assert_eq!(orig, prsd.to_string());
§

type Error = Error

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

impl Eq for Mess

source§

impl StructuralPartialEq for Mess

Auto Trait Implementations§

§

impl Freeze for Mess

§

impl RefUnwindSafe for Mess

§

impl Send for Mess

§

impl Sync for Mess

§

impl Unpin for Mess

§

impl UnwindSafe for Mess

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T> ToOwned for T
where T: Clone,

§

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§

default fn to_string(&self) -> String

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

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

§

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>,

§

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.