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
impl SocketCanChannel
Sourcepub fn open(ifname: &str) -> Result<Self, SocketCanError>
pub fn open(ifname: &str) -> Result<Self, SocketCanError>
Open a channel on the named interface (e.g., "vcan0", "can0").
Sourcepub fn open_iface(ifindex: u32) -> Result<Self, SocketCanError>
pub fn open_iface(ifindex: u32) -> Result<Self, SocketCanError>
Open a channel by kernel interface index.
Trait Implementations§
Source§impl Filterable for SocketCanChannel
impl Filterable for SocketCanChannel
Source§impl Receive for SocketCanChannel
impl Receive for SocketCanChannel
type Error = SocketCanError
Source§fn receive(&mut self) -> Result<Timestamped<CanFrame, Instant>, Self::Error>
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>
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>
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
impl ReceiveFd for SocketCanChannel
type Error = SocketCanError
Source§fn receive_fd(&mut self) -> Result<Timestamped<Frame, Instant>, Self::Error>
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>
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>
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
impl Transmit for SocketCanChannel
Source§impl TransmitFd for SocketCanChannel
impl TransmitFd for SocketCanChannel
type Error = SocketCanError
Source§fn transmit_fd(&mut self, frame: &CanFdFrame) -> Result<(), Self::Error>
fn transmit_fd(&mut self, frame: &CanFdFrame) -> Result<(), Self::Error>
Send a CAN FD frame.
Auto Trait Implementations§
impl Freeze for SocketCanChannel
impl RefUnwindSafe for SocketCanChannel
impl Send for SocketCanChannel
impl Sync for SocketCanChannel
impl Unpin for SocketCanChannel
impl UnsafeUnpin for SocketCanChannel
impl UnwindSafe for SocketCanChannel
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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