pub struct BackendVersion { /* private fields */ }Expand description
Backend version information.
Uses semantic versioning (SemVer) for version management. Backends with the
same major version are considered compatible.
§Examples
use canlink_hal::BackendVersion;
let version = BackendVersion::new(1, 2, 3);
assert_eq!(version.major(), 1);
assert_eq!(version.minor(), 2);
assert_eq!(version.patch(), 3);Implementations§
Source§impl BackendVersion
impl BackendVersion
Sourcepub fn new(major: u64, minor: u64, patch: u64) -> BackendVersion
pub fn new(major: u64, minor: u64, patch: u64) -> BackendVersion
Create a new backend version.
§Examples
use canlink_hal::BackendVersion;
let version = BackendVersion::new(1, 2, 3);
assert_eq!(version.to_string(), "1.2.3");Sourcepub fn major(&self) -> u64
pub fn major(&self) -> u64
Get the major version number.
§Examples
use canlink_hal::BackendVersion;
let version = BackendVersion::new(1, 2, 3);
assert_eq!(version.major(), 1);Sourcepub fn minor(&self) -> u64
pub fn minor(&self) -> u64
Get the minor version number.
§Examples
use canlink_hal::BackendVersion;
let version = BackendVersion::new(1, 2, 3);
assert_eq!(version.minor(), 2);Sourcepub fn patch(&self) -> u64
pub fn patch(&self) -> u64
Get the patch version number.
§Examples
use canlink_hal::BackendVersion;
let version = BackendVersion::new(1, 2, 3);
assert_eq!(version.patch(), 3);Sourcepub fn is_compatible_with(&self, other: &BackendVersion) -> bool
pub fn is_compatible_with(&self, other: &BackendVersion) -> bool
Check if this version is compatible with another version.
Two versions are compatible if they have the same major version number. This follows semantic versioning rules where major version changes indicate breaking changes.
§Examples
use canlink_hal::BackendVersion;
let v1 = BackendVersion::new(1, 2, 3);
let v2 = BackendVersion::new(1, 3, 0);
let v3 = BackendVersion::new(2, 0, 0);
assert!(v1.is_compatible_with(&v2));
assert!(!v1.is_compatible_with(&v3));Sourcepub fn satisfies(&self, req: &str) -> Result<bool, Error>
pub fn satisfies(&self, req: &str) -> Result<bool, Error>
Check if this version satisfies a version requirement.
§Examples
use canlink_hal::BackendVersion;
let version = BackendVersion::new(1, 2, 3);
assert!(version.satisfies("^1.0.0").unwrap());
assert!(!version.satisfies("^2.0.0").unwrap());§Errors
Returns an error if the requirement string cannot be parsed.
Trait Implementations§
Source§impl Clone for BackendVersion
impl Clone for BackendVersion
Source§fn clone(&self) -> BackendVersion
fn clone(&self) -> BackendVersion
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 BackendVersion
impl Debug for BackendVersion
Source§impl Display for BackendVersion
impl Display for BackendVersion
Source§impl From<Version> for BackendVersion
impl From<Version> for BackendVersion
Source§fn from(version: Version) -> BackendVersion
fn from(version: Version) -> BackendVersion
Converts to this type from the input type.
Source§impl PartialEq for BackendVersion
impl PartialEq for BackendVersion
impl Eq for BackendVersion
impl StructuralPartialEq for BackendVersion
Auto Trait Implementations§
impl Freeze for BackendVersion
impl RefUnwindSafe for BackendVersion
impl Send for BackendVersion
impl Sync for BackendVersion
impl Unpin for BackendVersion
impl UnsafeUnpin for BackendVersion
impl UnwindSafe for BackendVersion
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.