pub struct HardwareCapability {
pub channel_count: u8,
pub supports_canfd: bool,
pub max_bitrate: u32,
pub supported_bitrates: Vec<u32>,
pub filter_count: u8,
pub timestamp_precision: TimestampPrecision,
}Expand description
Hardware capability description.
Describes the capabilities and limitations of a CAN hardware backend. Applications can query these capabilities at runtime to adapt their behavior.
§Examples
use canlink_hal::{HardwareCapability, TimestampPrecision};
let capability = HardwareCapability {
channel_count: 2,
supports_canfd: true,
max_bitrate: 8_000_000,
supported_bitrates: vec![125_000, 250_000, 500_000, 1_000_000],
filter_count: 16,
timestamp_precision: TimestampPrecision::Microsecond,
};
assert_eq!(capability.channel_count, 2);
assert!(capability.supports_canfd);Fields§
§channel_count: u8Number of supported channels
supports_canfd: boolWhether CAN-FD is supported
max_bitrate: u32Maximum bitrate in bits per second
supported_bitrates: Vec<u32>List of supported bitrates (bps)
filter_count: u8Number of hardware filters supported
timestamp_precision: TimestampPrecisionTimestamp precision
Implementations§
Source§impl HardwareCapability
impl HardwareCapability
Sourcepub fn new(
channel_count: u8,
supports_canfd: bool,
max_bitrate: u32,
supported_bitrates: Vec<u32>,
filter_count: u8,
timestamp_precision: TimestampPrecision,
) -> Self
pub fn new( channel_count: u8, supports_canfd: bool, max_bitrate: u32, supported_bitrates: Vec<u32>, filter_count: u8, timestamp_precision: TimestampPrecision, ) -> Self
Create a new hardware capability description.
§Examples
use canlink_hal::{HardwareCapability, TimestampPrecision};
let capability = HardwareCapability::new(
2,
true,
8_000_000,
vec![125_000, 250_000, 500_000, 1_000_000],
16,
TimestampPrecision::Microsecond,
);Sourcepub fn supports_bitrate(&self, bitrate: u32) -> bool
pub fn supports_bitrate(&self, bitrate: u32) -> bool
Check if a specific bitrate is supported.
§Examples
use canlink_hal::{HardwareCapability, TimestampPrecision};
let capability = HardwareCapability::new(
2,
true,
8_000_000,
vec![125_000, 250_000, 500_000, 1_000_000],
16,
TimestampPrecision::Microsecond,
);
assert!(capability.supports_bitrate(500_000));
assert!(!capability.supports_bitrate(2_000_000));Sourcepub fn has_channel(&self, channel: u8) -> bool
pub fn has_channel(&self, channel: u8) -> bool
Check if a specific channel exists.
§Examples
use canlink_hal::{HardwareCapability, TimestampPrecision};
let capability = HardwareCapability::new(
2,
true,
8_000_000,
vec![125_000, 250_000, 500_000, 1_000_000],
16,
TimestampPrecision::Microsecond,
);
assert!(capability.has_channel(0));
assert!(capability.has_channel(1));
assert!(!capability.has_channel(2));Trait Implementations§
Source§impl Clone for HardwareCapability
impl Clone for HardwareCapability
Source§fn clone(&self) -> HardwareCapability
fn clone(&self) -> HardwareCapability
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 HardwareCapability
impl Debug for HardwareCapability
Source§impl PartialEq for HardwareCapability
impl PartialEq for HardwareCapability
impl Eq for HardwareCapability
impl StructuralPartialEq for HardwareCapability
Auto Trait Implementations§
impl Freeze for HardwareCapability
impl RefUnwindSafe for HardwareCapability
impl Send for HardwareCapability
impl Sync for HardwareCapability
impl Unpin for HardwareCapability
impl UnsafeUnpin for HardwareCapability
impl UnwindSafe for HardwareCapability
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.