pub fn check_next_version(&self, next: &ProtocolVersion) -> VersionCheckResult {
        // Protocol major versions should increase monotonically by 1.
        let major_bumped = self.0.major.saturating_add(1);
        if next.0.major < self.0.major || next.0.major > major_bumped {
            return VersionCheckResult::Invalid;
        }

        if next.0.major == major_bumped {
            return VersionCheckResult::Valid {
                is_major_version: true,
            };
        }

        // Covers the equal major versions
        debug_assert_eq!(next.0.major, self.0.major);

        if next.0.minor < self.0.minor {
            // Protocol minor versions within the same major version should not go backwards.
            return VersionCheckResult::Invalid;
        }

        if next.0.minor > self.0.minor {
            return VersionCheckResult::Valid {
                is_major_version: false,
            };
        }

        // Code belows covers equal minor versions
        debug_assert_eq!(next.0.minor, self.0.minor);

        // Protocol patch versions should increase monotonically but can be skipped.
        if next.0.patch <= self.0.patch {
            return VersionCheckResult::Invalid;
        }

        VersionCheckResult::Valid {
            is_major_version: false,
        }
    }
/// Checks if next version can be followed.
Checks if next version can be followed.
Checks if next version can be followed .
pub fn check_next_version(&self, next: &ProtocolVersion) -> VersionCheckResult {
        // Protocol major versions should increase monotonically by 1.
        let major_bumped = self.0.major.saturating_add(1);
        if next.0.major < self.0.major || next.0.major > major_bumped {
            return VersionCheckResult::Invalid;
        }
        if next.0.major == major_bumped {
            return VersionCheckResult::Valid {
                is_major_version: true,
            };
        }
        // Covers the equal major versions
        debug_assert_eq!(next.0.major, self.0.major);
        if next.0.minor < self.0.minor {
            // Protocol minor versions within the same major version should not go backwards.
            return VersionCheckResult::Invalid;
        }
        if next.0.minor > self.0.minor {
            return VersionCheckResult::Valid {
                is_major_version: false,
            };
        }
        // Code belows covers equal minor versions
        debug_assert_eq!(next.0.minor, self.0.minor);
        // Protocol patch versions should increase monotonically but can be skipped.
        if next.0.patch <= self.0.patch {
            return VersionCheckResult::Invalid;
        }
        VersionCheckResult::Valid {
            is_major_version: false,
        }
    }
pub fn check_next_version ( & self , next : & ProtocolVersion ) -> VersionCheckResult { // Protocol major versions should increase monotonically by 1. let major_bumped = self . 0 . major . saturating_add ( 1 ) ; if next . 0 . major < self . 0 . major || next . 0 . major > major_bumped { return VersionCheckResult :: Invalid ; } if next . 0 . major == major_bumped { return VersionCheckResult :: Valid { is_major_version : true , } ; } // Covers the equal major versions debug_assert_eq ! ( next 0 major self 0 major ) ; if next . 0 . minor < self . 0 . minor { // Protocol minor versions within the same major version should not go backwards. return VersionCheckResult :: Invalid ; } if next . 0 . minor > self . 0 . minor { return VersionCheckResult :: Valid { is_major_version : false , } ; } // Code belows covers equal minor versions debug_assert_eq ! ( next 0 minor self 0 minor ) ; // Protocol patch versions should increase monotonically but can be skipped. if next . 0 . patch <= self . 0 . patch { return VersionCheckResult :: Invalid ; } VersionCheckResult :: Valid { is_major_version : false , } }
Checks if next version can be followed.
Checks if next version can be followed .
&self
next
&ProtocolVersion
&self
next
&ProtocolVersion