pub struct CalSem;
Expand description
Scheme for formats that have both calendar and semantic specifiers, such as
<YYYY>.<MM>.<PATCH>
.
You would have such a format if you want to be able to increase your version multiple times within the period of your smallest calendar specifier, such a second time in the same day.
See the available specifiers for this scheme in the table.
§Rules
- The first specifier must be a year (
YYYY
,YY
, or0Y
). - For adjacent calendar specifiers
a
andb
,b
must be relative toa
:- month specifiers are relative to year ones (e.g.,
<YYYY>.<MM>
) - day specifiers are relative to month ones (e.g.,
<YYYY>.<MM>.<DD>
) - week specifiers are relative to year ones (and not month ones) (e.g.,
<YYYY>.<WW>
)
- month specifiers are relative to year ones (e.g.,
- The format must end with the
PATCH
semantic specifier.MINOR
may optionally come beforePATCH
if more granularity is desired.
- 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
y<YYYY>m<MM>d<DD>-p<PATCH>
.
§Example Formats
<YYYY>.<0M>.<0D>.<PATCH>
: Full year, zero-padded month, zero-padded day, and patch. Dot-separated.<0Y>.<0M>.<0D>.<PATCH>
: Zero-padded year, zero-padded month, zero-padded day, and patch. Dot-separated.<YYYY>.<0W>-<MINOR>.<PATCH>
: Full year, zero-padded week, minor, and patch. Dot- and hyphen-separated.
Implementations§
source§impl CalSem
impl CalSem
sourcepub fn next_version_string(
format_str: &str,
version_str: &str,
date: Date,
level: CalSemLevel
) -> Result<String, CompositeError>
pub fn next_version_string( format_str: &str, version_str: &str, date: Date, level: CalSemLevel ) -> Result<String, CompositeError>
Increments the version string (formatted by the format string) by the given date and 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 date = Date::utc_now(); // assume today is 2024-02-23
let next_str = CalSem::next_version_string(
"<YYYY>.<0M>.<PATCH>",
"2024.01.42",
date,
CalSemLevel::Patch
).unwrap();
assert_eq!("2024.02.0", next_str);
§Errors
Returns a CompositeError
of all error surface area from Self::new_version
and
Version::next
.
Trait Implementations§
source§impl PartialEq for CalSem
impl PartialEq for CalSem
source§impl Scheme for CalSem
impl Scheme for CalSem
source§fn new_format(format_str: &str) -> Result<Format<'_, Self>, FormatError>
fn new_format(format_str: &str) -> Result<Format<'_, Self>, FormatError>
source§fn new_version<'vs>(
format_str: &str,
version_str: &'vs str
) -> Result<Version<'vs, Self>, CompositeError>
fn new_version<'vs>( format_str: &str, version_str: &'vs str ) -> Result<Version<'vs, Self>, CompositeError>
impl Eq for CalSem
impl StructuralPartialEq for CalSem
Auto Trait Implementations§
impl RefUnwindSafe for CalSem
impl Send for CalSem
impl Sync for CalSem
impl Unpin for CalSem
impl UnwindSafe for CalSem
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