Struct nextver::Sem

source ·
pub struct Sem;
Expand description

Scheme for formats that have only semantic specifiers, such as <MAJOR>.<MINOR>.<PATCH>.

Sem behaves almost exactly like the SemVer scheme, but with a few differences.

See the available specifiers for this scheme in the table.

§Rules

  • The first specifier must be MAJOR.
  • MINOR and PATCH are not required. If MINOR is present, it must be after MAJOR, and if PATCH is present, it must be after MINOR.
  • As for all schemes, arbitrary literals can be placed in the format string. For example, dots, hyphens, or any other character(s) can be used, such as v<MAJOR>#<MINOR>-p<PATCH>.

§Example Formats

  • <MAJOR>.<MINOR>.<PATCH>: Major, minor, and patch. Dot-separated.
  • v<MAJOR>.<MINOR>: v followed by major and minor. Dot-separated.

Implementations§

source§

impl Sem

source

pub fn next_version_string( format_str: &str, version_str: &str, level: SemLevel ) -> Result<String, CompositeError>

Increments the version string (formatted by the format string) by the given semantic specifier and returns the new version’s string.

This is a convenience method that creates a temporary Format and Version with Scheme::new_version, and increments it with Version::next.

§Example
use nextver::prelude::*;

let next_str = Sem::next_version_string(
  "<MAJOR>.<MINOR>.<PATCH>",
  "1.2.3",
   SemLevel::Minor
).unwrap();

assert_eq!("1.3.0", next_str);
§Errors

Returns a CompositeError of all error surface area from Self::new_version and Version::next.

Trait Implementations§

source§

impl Debug for Sem

source§

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

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

impl PartialEq for Sem

source§

fn eq(&self, other: &Sem) -> 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 Scheme for Sem

source§

fn new_format(format_str: &str) -> Result<Format<'_, Self>, FormatError>

Parse a format string containing specifier and literal tokens into a Format. Read more
source§

fn new_version<'vs>( format_str: &str, version_str: &'vs str ) -> Result<Version<'vs, Self>, CompositeError>

Parses a version string against a format string, and returns a Version object if the version string matches the format string. Otherwise, returns a NextError. Read more
source§

fn is_valid(format_str: &str, version_str: &str) -> Result<bool, FormatError>

Returns Ok(true) if the given version string is valid for the given format string, or else Ok(false). Returns an error if the format string could not be parsed. Read more
source§

impl Eq for Sem

source§

impl StructuralPartialEq for Sem

Auto Trait Implementations§

§

impl RefUnwindSafe for Sem

§

impl Send for Sem

§

impl Sync for Sem

§

impl Unpin for Sem

§

impl UnwindSafe for Sem

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