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>
impl<'fs, S: Scheme> Format<'fs, S>
sourcepub fn new_version<'vs>(
&self,
version_str: &'vs str
) -> Result<Version<'vs, S>, VersionError>
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
- If the version string does not match the format string, returns a
VersionError::VersionFormatMismatch
.
Trait Implementations§
source§impl<'fs, S: PartialEq + Scheme> PartialEq for Format<'fs, S>
impl<'fs, S: PartialEq + Scheme> PartialEq for Format<'fs, S>
impl<'fs, S: Eq + Scheme> Eq for Format<'fs, S>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more