pub struct Version(/* private fields */);Expand description
A monotonically increasing event version number.
Wraps NonZeroU64 — event versions are always >= 1.
A fresh aggregate with no events has Option<Version> = None.
The only public entry points are:
Version::INITIAL— the first event version (1)Version::new()— construct from au64(returnsNonefor 0)version.next()— derives the next version, returnsNoneon overflow
§Example
use mnesis::Version;
let v = Version::INITIAL;
assert_eq!(v.as_u64(), 1);
assert_eq!(v.next().unwrap().as_u64(), 2);Implementations§
Source§impl Version
impl Version
Sourcepub const fn next(self) -> Option<Version>
pub const fn next(self) -> Option<Version>
The next version in sequence.
Returns None if the version is u64::MAX (overflow).
Sourcepub const fn new(v: u64) -> Option<Version>
pub const fn new(v: u64) -> Option<Version>
Construct a Version from a u64.
Returns None if v is 0 (invalid — versions are always >= 1).
Mirrors NonZeroU64::new.
Sourcepub fn run(start: Version, len: usize) -> Option<VersionRun>
pub fn run(start: Version, len: usize) -> Option<VersionRun>
len consecutive versions start, start+1, …, start+len-1.
The whole run is validated up front, so iteration is infallible and
never silently truncates on overflow — a lazy infinite iterator
zipped against a batch could drop items; this cannot. Returns None
if the run would overflow past u64::MAX, consistent with
Version::new/Version::next returning Option. len == 0
yields an empty run.
Trait Implementations§
impl Copy for Version
impl Eq for Version
Source§impl From<SchemaVersion> for Version
impl From<SchemaVersion> for Version
Source§fn from(sv: SchemaVersion) -> Self
fn from(sv: SchemaVersion) -> Self
Widen to the kernel’s Version (NonZeroU64). Total — NonZeroU32
always fits in NonZeroU64.
Source§impl Ord for Version
impl Ord for Version
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Version
impl PartialOrd for Version
impl StructuralPartialEq for Version
Auto Trait Implementations§
impl Freeze for Version
impl RefUnwindSafe for Version
impl Send for Version
impl Sync for Version
impl Unpin for Version
impl UnsafeUnpin for Version
impl UnwindSafe for Version
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.