Trait CanDevice

Source
pub trait CanDevice: Clone + TryFrom<DeviceBuilder, Error = Error> {
    type Channel: Display;
    type Frame: Frame<Channel = Self::Channel>;

    // Required methods
    fn opened_channels(&self) -> Vec<Self::Channel>;
    fn transmit(
        &self,
        msg: Self::Frame,
        timeout: Option<u32>,
    ) -> CanResult<(), Error>;
    fn receive(
        &self,
        channel: Self::Channel,
        timeout: Option<u32>,
    ) -> CanResult<Vec<Self::Frame>, Error>;
    fn shutdown(&mut self);

    // Provided method
    fn is_closed(&self) -> bool { ... }
}

Required Associated Types§

Source

type Channel: Display

Source

type Frame: Frame<Channel = Self::Channel>

Required Methods§

Source

fn opened_channels(&self) -> Vec<Self::Channel>

get all channels that has opened

Source

fn transmit( &self, msg: Self::Frame, timeout: Option<u32>, ) -> CanResult<(), Error>

Transmit a CAN or CAN-FD Frame.

Source

fn receive( &self, channel: Self::Channel, timeout: Option<u32>, ) -> CanResult<Vec<Self::Frame>, Error>

Receive CAN and CAN-FD Frames.

Source

fn shutdown(&mut self)

Close CAN device.

Provided Methods§

Source

fn is_closed(&self) -> bool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§