pub struct SingleStandardFilter { /* private fields */ }
Expand description

A filter that matches against a single 11 bit id, the rtr bit, and the first two bytes of the payload.

Warning: This is not a perfect filter. Extended ids that match the bit layout of this filter will also be accepted.

Implementations§

source§

impl SingleStandardFilter

source

pub const fn new( id: &[u8; 11], rtr: &[u8; 1], payload: [&[u8; 8]; 2] ) -> SingleStandardFilter

Create a new filter that matches against a single 11-bit standard id. The filter can match against the packet’s id, rtr bit, and first two bytes of the payload.

Example matching only even ids, allowing any rtr value and any payload data:

const FILTER: SingleStandardFilter =
    SingleStandardFilter::new(b"xxxxxxxxxx0", b"x", [b"xxxxxxxx", b"xxxxxxxx"]);
source

pub fn new_from_code_mask( id_code: StandardId, id_mask: StandardId, rtr_code: bool, rtr_mask: bool, payload_code: [u8; 2], payload_mask: [u8; 2] ) -> SingleStandardFilter

The masks indicate which bits of the code the filter should match against. Set bits in the mask indicate that the corresponding bit in the code should match.

Examples

A filter that matches every standard id that is even, is not an rtr frame, with any bytes for the first two payload bytes.

let filter = twai::filter::SingleStandardFilter::new_from_code_mask(
    StandardId::new(0x000).unwrap(),
    StandardId::new(0x001).unwrap(),
    false,
    true,
    [0x00, 0x00],
    [0x00, 0x00],
);

Trait Implementations§

source§

impl Filter for SingleStandardFilter

source§

const FILTER_TYPE: FilterType = FilterType::Single

The type of the filter.
source§

fn to_registers(&self) -> [u8; 8]

Get the register level representation of the filter.
source§

fn filter_type(&self) -> FilterType

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.