pub struct Version { /* private fields */ }Expand description
Provides journal version support within the AIM file. The version header represents a version with an epoch and optional partial component.
A version consists of two parts:
- epoch: The major version number that increments when creating new versions
- partial: The minor version number that increments for partial updates within the same epoch
This versioning system is used throughout AIM to track changes and enable efficient version control. The epoch represents major structural changes while partial versions represent incremental updates within the same epoch.
§Examples
use aimx::aim::Version;
// Create a new version
let version = Version::new(1, 0);
assert_eq!(version.epoch(), 1);
assert_eq!(version.partial(), 0);
// Create a version with partial
let version_with_partial = Version::new(2, 3);
assert_eq!(version_with_partial.epoch(), 2);
assert_eq!(version_with_partial.partial(), 3);Implementations§
Source§impl Version
impl Version
Sourcepub fn new(epoc: u32, partial: u32) -> Self
pub fn new(epoc: u32, partial: u32) -> Self
Creates a new Version with the specified epoch and partial values.
§Parameters
epoc- The major version numberpartial- The minor version number (typically 0 for new epochs)
§Returns
A new Version instance with the specified values.
§Examples
use aimx::aim::Version;
let version = Version::new(1, 0);
assert_eq!(version.epoc(), 1);
assert_eq!(version.partial(), 0);Sourcepub fn epoch(&self) -> u32
pub fn epoch(&self) -> u32
Returns the epoch (major version) of this version.
This is an alias for Self::epoc() for better readability.
§Returns
The epoch value as a u32.
§Examples
use aimx::aim::Version;
let version = Version::new(2, 5);
assert_eq!(version.epoch(), 2);Sourcepub fn set_epoc(&mut self, epoc: u32)
pub fn set_epoc(&mut self, epoc: u32)
Sets the epoch and resets the partial to 0.
This method is typically used when moving to a new major version. Setting the epoch automatically resets the partial to 0 since partial versions are specific to their epoch.
§Parameters
epoc- The new epoch value
§Examples
use aimx::aim::Version;
let mut version = Version::new(1, 5);
version.set_epoc(2);
assert_eq!(version.epoc(), 2);
assert_eq!(version.partial(), 0); // Reset to 0Sourcepub fn increment_epoc(&mut self)
pub fn increment_epoc(&mut self)
Increments the epoch and resets the partial to 0.
This method is used to advance to the next major version. The partial is automatically reset to 0 since partial versions are specific to their epoch.
§Examples
use aimx::aim::Version;
let mut version = Version::new(1, 5);
version.increment_epoc();
assert_eq!(version.epoc(), 2);
assert_eq!(version.partial(), 0); // Reset to 0Sourcepub fn set_partial(&mut self, partial: u32)
pub fn set_partial(&mut self, partial: u32)
Sets the partial value.
This method allows setting the partial version directly without affecting the epoch. Use this when you need to set a specific partial version within the same epoch.
§Parameters
partial- The new partial value
§Examples
use aimx::aim::Version;
let mut version = Version::new(1, 0);
version.set_partial(3);
assert_eq!(version.epoc(), 1); // Unchanged
assert_eq!(version.partial(), 3);Sourcepub fn increment_partial(&mut self)
pub fn increment_partial(&mut self)
Increments the partial value by 1.
This method is used to advance to the next partial version within the same epoch. This is commonly used for incremental updates that don’t warrant a new epoch.
§Examples
use aimx::aim::Version;
let mut version = Version::new(1, 2);
version.increment_partial();
assert_eq!(version.epoc(), 1); // Unchanged
assert_eq!(version.partial(), 3);