pub struct ProtocolVersion { /* private fields */ }Expand description
Describes the semantic version of this implementation of the NBMC interface.
Implementations§
Source§impl ProtocolVersion
impl ProtocolVersion
Sourcepub const fn new(major: u8, minor: u8, patch: u8) -> ProtocolVersion
pub const fn new(major: u8, minor: u8, patch: u8) -> ProtocolVersion
Construct a new ProtocolVersion.
This isn’t a message but instead can form part of a message. For example, you should have a register address which provides the version of the NBMC protocol implemented.
Pass in the major version, the minor version and the patch version.
Sourcepub const fn is_compatible_with(&self, my_version: &ProtocolVersion) -> bool
pub const fn is_compatible_with(&self, my_version: &ProtocolVersion) -> bool
Check if this ProtocolVersion is compatible with my_version.
let my_version = ProtocolVersion::new(1, 1, 0);
// This is compatible.
let bmc_a = ProtocolVersion::new(1, 1, 1);
assert!(bmc_a.is_compatible_with(&my_version));
// This is incompatible - patch is too low.
let bmc_b = ProtocolVersion::new(1, 0, 0);
assert!(!bmc_b.is_compatible_with(&my_version));
// This is incompatible - major is too high.
let bmc_c = ProtocolVersion::new(2, 0, 0);
assert!(!bmc_c.is_compatible_with(&my_version));
// This is incompatible - major is too low.
let bmc_d = ProtocolVersion::new(0, 1, 0);
assert!(!bmc_d.is_compatible_with(&my_version));Trait Implementations§
Source§impl Clone for ProtocolVersion
impl Clone for ProtocolVersion
Source§fn clone(&self) -> ProtocolVersion
fn clone(&self) -> ProtocolVersion
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 ProtocolVersion
impl Debug for ProtocolVersion
Source§impl PartialEq for ProtocolVersion
impl PartialEq for ProtocolVersion
Source§impl Sendable for ProtocolVersion
impl Sendable for ProtocolVersion
impl Copy for ProtocolVersion
impl Eq for ProtocolVersion
impl StructuralPartialEq for ProtocolVersion
Auto Trait Implementations§
impl Freeze for ProtocolVersion
impl RefUnwindSafe for ProtocolVersion
impl Send for ProtocolVersion
impl Sync for ProtocolVersion
impl Unpin for ProtocolVersion
impl UnwindSafe for ProtocolVersion
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