pub fn compatibility_message(version: u32) -> StringExpand description
Generates a user-facing message describing version compatibility status.
This function produces human-readable error messages and recommendations for handling version mismatches. The messages are designed to be displayed directly to end users in error logs or CLI output.
§Parameters
version: The format version number from a snapshot header
§Returns
A String containing:
- Full compatibility: Confirmation message
- Degraded compatibility: Warning about potential feature limitations
- Incompatibility: Error message with actionable remediation steps
§Message Content
§Fully Supported Version
"Version 1 is fully supported."§Too Old (version < MIN_SUPPORTED_VERSION)
"Version 0 is too old (min supported: 1). Please upgrade the snapshot."Remediation: Use hexz-migrate upgrade to convert the snapshot.
§Too New (version > MAX_SUPPORTED_VERSION)
"Version 2 is too new (max supported: 1). Please upgrade Hexz."Remediation: Install a newer version of the Hexz toolchain.
§Degraded Compatibility (Future)
"Version 2 is newer than supported (1), features may be missing."Remediation: Upgrade Hexz for full feature support, or proceed with warnings.
§Usage in Error Handling
This function is typically called when displaying compatibility errors to users:
ⓘ
use hexz_core::format::version::{check_version, compatibility_message};
fn validate_snapshot(header: &Header) -> Result<(), String> {
let compat = check_version(header.version);
if !compat.is_compatible() {
return Err(compatibility_message(header.version));
}
Ok(())
}§Examples
use hexz_core::format::version::{compatibility_message, MAX_SUPPORTED_VERSION};
// Supported version
let msg = compatibility_message(1);
assert!(msg.contains("fully supported"));
// Version too new
let msg = compatibility_message(MAX_SUPPORTED_VERSION + 1);
assert!(msg.contains("too new"));
assert!(msg.contains("upgrade Hexz"));
// Version too old (hypothetical if MIN_SUPPORTED_VERSION > 1)
let msg = compatibility_message(0);
assert!(msg.contains("too old"));
assert!(msg.contains("upgrade the snapshot"));§CLI Integration
$ hexz open old_snapshot.hxz
Error: Version 0 is too old (min supported: 1). Please upgrade the snapshot.
Run: hexz-migrate upgrade old_snapshot.hxz new_snapshot.hxz