pub trait MessageFilter: Send + Sync {
// Required method
fn matches(&self, message: &CanMessage) -> bool;
// Provided methods
fn priority(&self) -> u32 { ... }
fn is_hardware(&self) -> bool { ... }
}Expand description
Message filter trait
All filter implementations must implement this trait. Filters can be either hardware-accelerated or software-based.
§Thread Safety
Implementations must be Send + Sync to allow use across threads.
§Example
ⓘ
use canlink_hal::filter::MessageFilter;
use canlink_hal::message::CanMessage;
struct MyFilter {
target_id: u32,
}
impl MessageFilter for MyFilter {
fn matches(&self, message: &CanMessage) -> bool {
message.id() == self.target_id
}
}Required Methods§
Sourcefn matches(&self, message: &CanMessage) -> bool
fn matches(&self, message: &CanMessage) -> bool
Check if a message matches this filter
Returns true if the message should be accepted.
Provided Methods§
Sourcefn priority(&self) -> u32
fn priority(&self) -> u32
Get the filter priority
Higher priority filters are evaluated first. Default is 0 (lowest priority).
Sourcefn is_hardware(&self) -> bool
fn is_hardware(&self) -> bool
Check if this is a hardware filter
Hardware filters are executed by the CAN controller,
reducing CPU load. Returns false by default.