Skip to main content

SocketCanChannel

Struct SocketCanChannel 

Source
pub struct SocketCanChannel { /* private fields */ }
Expand description

A CAN channel backed by a Linux SocketCAN FD socket.

Implements Transmit, Receive, TransmitFd, ReceiveFd, and Filterable.

Created via SocketCanDriver or SocketCanChannel::open.

Implementations§

Source§

impl SocketCanChannel

Source

pub fn open(ifname: &str) -> Result<Self, SocketCanError>

Open a channel on the named interface (e.g., "vcan0", "can0").

Source

pub fn open_iface(ifindex: u32) -> Result<Self, SocketCanError>

Open a channel by kernel interface index.

Trait Implementations§

Source§

impl Filterable for SocketCanChannel

Source§

type Error = SocketCanError

Source§

fn set_filters(&mut self, filters: &[Filter]) -> Result<(), Self::Error>

Apply the given set of acceptance filters. Read more
Source§

fn clear_filters(&mut self) -> Result<(), Self::Error>

Remove all acceptance filters (accept everything).
Source§

impl Receive for SocketCanChannel

Source§

type Error = SocketCanError

Source§

type Timestamp = Instant

The timestamp type used by this backend (e.g., std::time::Instant).
Source§

fn receive(&mut self) -> Result<Timestamped<CanFrame, Instant>, Self::Error>

Blocks until a classic CAN frame is available.
Source§

fn try_receive( &mut self, ) -> Result<Option<Timestamped<CanFrame, Instant>>, Self::Error>

Returns immediately with Ok(None) if no frame is available.
Source§

fn receive_timeout( &mut self, timeout: Duration, ) -> Result<Option<Timestamped<CanFrame, Instant>>, Self::Error>

Blocks until a frame is available or the timeout expires. Returns Ok(None) on timeout.
Source§

impl ReceiveFd for SocketCanChannel

Source§

type Error = SocketCanError

Source§

type Timestamp = Instant

The timestamp type used by this backend (e.g., std::time::Instant).
Source§

fn receive_fd(&mut self) -> Result<Timestamped<Frame, Instant>, Self::Error>

Blocks until any frame is available; returns Frame enum.
Source§

fn try_receive_fd( &mut self, ) -> Result<Option<Timestamped<Frame, Instant>>, Self::Error>

Non-blocking variant.
Source§

fn receive_fd_timeout( &mut self, timeout: Duration, ) -> Result<Option<Timestamped<Frame, Instant>>, Self::Error>

Blocks until a frame is available or the timeout expires. Returns Ok(None) on timeout.
Source§

impl Transmit for SocketCanChannel

Source§

type Error = SocketCanError

Source§

fn transmit(&mut self, frame: &CanFrame) -> Result<(), Self::Error>

Send a classic CAN frame.
Source§

impl TransmitFd for SocketCanChannel

Source§

type Error = SocketCanError

Source§

fn transmit_fd(&mut self, frame: &CanFdFrame) -> Result<(), Self::Error>

Send a CAN FD frame.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.