Struct nextver::Format

source ·
pub struct Format<'fs, S: Scheme> { /* private fields */ }
Expand description

A Format describes the structure of a version, comprised of specifiers and literal text.

Later, the Format can be used to parse a version string into a Version struct.

Implementations§

source§

impl<'fs, S: Scheme> Format<'fs, S>

source

pub fn new_version<'vs>( &self, version_str: &'vs str ) -> Result<Version<'vs, S>, VersionError>

Parses a version string with this format and return a Version object.

A version string is valid for a format if it matches the format exactly. This means that:

  • Specifiers (e.g. <MAJOR>) in the format are replaced with the numeric values. See the table for how these values are expressed (such as zero-padding).

    Note: The values in version_str are not validated to be actual dates. For example, 2021.02.31 is valid for the format <YYYY>.<MM>.<DD>, even though February 31st does not exist.

  • Literal text in the format must match the version string exactly.

§Errors

Trait Implementations§

source§

impl<'fs, S: Clone + Scheme> Clone for Format<'fs, S>

source§

fn clone(&self) -> Format<'fs, S>

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<'fs, S: Debug + Scheme> Debug for Format<'fs, S>

source§

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

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

impl<'fs, S: Scheme> Display for Format<'fs, S>

source§

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

Display a format as a format string.

§Example
use nextver::prelude::*;

let format_str = "<YYYY>.<MM>.<DD>";
let format = Cal::new_format(format_str).unwrap();
assert_eq!(format_str, format.to_string());
source§

impl<'fs, S: PartialEq + Scheme> PartialEq for Format<'fs, S>

source§

fn eq(&self, other: &Format<'fs, S>) -> 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<'fs, S: Eq + Scheme> Eq for Format<'fs, S>

source§

impl<'fs, S: Scheme> StructuralPartialEq for Format<'fs, S>

Auto Trait Implementations§

§

impl<'fs, S> RefUnwindSafe for Format<'fs, S>
where <S as Scheme>::Specifier: RefUnwindSafe,

§

impl<'fs, S> Send for Format<'fs, S>
where <S as Scheme>::Specifier: Sync,

§

impl<'fs, S> Sync for Format<'fs, S>
where <S as Scheme>::Specifier: Sync,

§

impl<'fs, S> Unpin for Format<'fs, S>

§

impl<'fs, S> UnwindSafe for Format<'fs, S>
where <S as Scheme>::Specifier: RefUnwindSafe,

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.