pub struct PackedVersion(/* private fields */);Expand description
Packed semantic version represented as a u32
Format: major * 1_000_000 + minor * 1_000 + patch
Implementations§
Source§impl PackedVersion
impl PackedVersion
Sourcepub const MAX_MAJOR: u32 = 4293
pub const MAX_MAJOR: u32 = 4293
Maximum allowed major version (leaves room for minor/patch) u32::MAX = 4,294,967,295 With max minor (999,999), max major = 4,293
Sourcepub fn new(major: u32, minor: u32, patch: u32) -> Result<Self, VersionError>
pub fn new(major: u32, minor: u32, patch: u32) -> Result<Self, VersionError>
Create a new packed version from components
Returns an error if any component exceeds its maximum value.
Sourcepub const fn from_raw(value: u32) -> Self
pub const fn from_raw(value: u32) -> Self
Create from a u32 directly (unsafe - no validation)
Use this when you’ve already validated the packed format or received it from a trusted source (e.g., wire protocol).
Sourcepub fn parse(s: &str) -> Result<Self, VersionError>
pub fn parse(s: &str) -> Result<Self, VersionError>
Parse a version string in “major.minor.patch” format
§Examples
use synapse_primitives::semver::PackedVersion;
let version = PackedVersion::parse("2.3.1").unwrap();
assert_eq!(version.as_u32(), 2_003_001);Sourcepub fn is_compatible_with(&self, other: &Self) -> bool
pub fn is_compatible_with(&self, other: &Self) -> bool
Check if this version is compatible with another (same major version)
Sourcepub fn is_breaking_change_from(&self, other: &Self) -> bool
pub fn is_breaking_change_from(&self, other: &Self) -> bool
Check if this version is a breaking change from another (major version increased)
Trait Implementations§
Source§impl Clone for PackedVersion
impl Clone for PackedVersion
Source§fn clone(&self) -> PackedVersion
fn clone(&self) -> PackedVersion
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PackedVersion
impl Debug for PackedVersion
Source§impl Display for PackedVersion
impl Display for PackedVersion
Source§impl From<PackedVersion> for u32
impl From<PackedVersion> for u32
Source§fn from(v: PackedVersion) -> u32
fn from(v: PackedVersion) -> u32
Converts to this type from the input type.
Source§impl Hash for PackedVersion
impl Hash for PackedVersion
Source§impl Ord for PackedVersion
impl Ord for PackedVersion
Source§fn cmp(&self, other: &PackedVersion) -> Ordering
fn cmp(&self, other: &PackedVersion) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for PackedVersion
impl PartialEq for PackedVersion
Source§impl PartialOrd for PackedVersion
impl PartialOrd for PackedVersion
impl Copy for PackedVersion
impl Eq for PackedVersion
impl StructuralPartialEq for PackedVersion
Auto Trait Implementations§
impl Freeze for PackedVersion
impl RefUnwindSafe for PackedVersion
impl Send for PackedVersion
impl Sync for PackedVersion
impl Unpin for PackedVersion
impl UnsafeUnpin for PackedVersion
impl UnwindSafe for PackedVersion
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