pub fn is_compatible_with(version: &Version) -> bool
Expand description

Returns true if the provided version is compatible with the protocol version.

use distant_protocol::{is_compatible_with, PROTOCOL_VERSION};
use distant_protocol::semver::Version;

// The current protocol version tied to this crate is always compatible
assert!(is_compatible_with(&PROTOCOL_VERSION));

// Major bumps in distant's protocol version are always considered incompatible
assert!(!is_compatible_with(&Version::new(
    PROTOCOL_VERSION.major + 1,
    PROTOCOL_VERSION.minor,
    PROTOCOL_VERSION.patch,
)));

// While distant's protocol is being stabilized, minor version bumps
// are also considered incompatible!
assert!(!is_compatible_with(&Version::new(
    PROTOCOL_VERSION.major,
    PROTOCOL_VERSION.minor + 1,
    PROTOCOL_VERSION.patch,
)));

// Patch bumps in distant's protocol are always considered compatible
assert!(is_compatible_with(&Version::new(
    PROTOCOL_VERSION.major,
    PROTOCOL_VERSION.minor,
    PROTOCOL_VERSION.patch + 1,
)));