pub struct SemanticVersioningEngine {
pub artifacts: HashMap<String, VersionedArtifact>,
pub compatibility_rules: CompatibilityMatrix,
}Expand description
Manages versioned artifacts with SemVer-based change detection, compatibility analysis, and migration-path computation.
Fields§
§artifacts: HashMap<String, VersionedArtifact>Registered artifacts keyed by their ID.
compatibility_rules: CompatibilityMatrixRules governing cross-version compatibility.
Implementations§
Source§impl SemanticVersioningEngine
impl SemanticVersioningEngine
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new engine with sensible default compatibility rules:
- Same major (distance 0) →
CompatibilityLevel::FullyCompatible. - Adjacent major (distance 1) →
CompatibilityLevel::BackwardCompatible. - All other pairs →
CompatibilityLevel::Incompatible.
Rules are pre-populated for majors 0..=9.
Sourcepub fn register_artifact(
&mut self,
artifact: VersionedArtifact,
) -> Result<(), SemVerError>
pub fn register_artifact( &mut self, artifact: VersionedArtifact, ) -> Result<(), SemVerError>
Register a new artifact.
Returns SemVerError::ArtifactAlreadyExists if an artifact with the
same ID is already registered.
Sourcepub fn publish_change(
&mut self,
artifact_id: &str,
change_type: ChangeType,
description: String,
now: u64,
) -> Result<SemVer, SemVerError>
pub fn publish_change( &mut self, artifact_id: &str, change_type: ChangeType, description: String, now: u64, ) -> Result<SemVer, SemVerError>
Apply a change to an artifact, auto-bumping its version according to
ChangeType::required_bump, appending a ChangeRecord, and
returning the new version.
Returns SemVerError::ArtifactNotFound when artifact_id is
unknown.
Sourcepub fn get_version(&self, artifact_id: &str) -> Option<&SemVer>
pub fn get_version(&self, artifact_id: &str) -> Option<&SemVer>
Return the current version of an artifact, or None if not found.
Sourcepub fn version_history(&self, artifact_id: &str) -> Vec<&ChangeRecord>
pub fn version_history(&self, artifact_id: &str) -> Vec<&ChangeRecord>
Return all changelog entries for an artifact in registration order.
Sourcepub fn check_compatibility(
&self,
from_id: &str,
to_id: &str,
) -> Result<CompatibilityLevel, SemVerError>
pub fn check_compatibility( &self, from_id: &str, to_id: &str, ) -> Result<CompatibilityLevel, SemVerError>
Determine the compatibility level between the current versions of two artifacts.
Returns errors when either artifact ID is unknown.
Sourcepub fn find_breaking_changes(
&self,
artifact_id: &str,
since: &SemVer,
) -> Vec<&ChangeRecord>
pub fn find_breaking_changes( &self, artifact_id: &str, since: &SemVer, ) -> Vec<&ChangeRecord>
Return all changelog entries with ChangeType::Breaking whose
version is strictly greater than since.
Sourcepub fn migration_path(&self, from: &SemVer, to: &SemVer) -> Vec<SemVer>
pub fn migration_path(&self, from: &SemVer, to: &SemVer) -> Vec<SemVer>
Compute a migration path between two SemVer values.
Rules:
- Same version →
[from] - Same major, different minor →
[from, intermediate, to]whereintermediateis(from.major, to.minor, 0)(i.e. from’s major with to’s minor bumped in). - Adjacent major (|delta| == 1) →
[from, to] - Otherwise →
[](incompatible gap, no path)
Sourcepub fn artifacts_at_version(&self, version: &SemVer) -> Vec<&str>
pub fn artifacts_at_version(&self, version: &SemVer) -> Vec<&str>
Return the IDs of all artifacts whose current version equals version.
Sourcepub fn stats(&self) -> VersioningStats
pub fn stats(&self) -> VersioningStats
Compute aggregate statistics over all registered artifacts.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SemanticVersioningEngine
impl RefUnwindSafe for SemanticVersioningEngine
impl Send for SemanticVersioningEngine
impl Sync for SemanticVersioningEngine
impl Unpin for SemanticVersioningEngine
impl UnsafeUnpin for SemanticVersioningEngine
impl UnwindSafe for SemanticVersioningEngine
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.