Skip to main content

CanFdSocket

Type Alias CanFdSocket 

Source
pub type CanFdSocket = AsyncCanSocket<CanFdSocket>;
Available on crate feature tokio only.
Expand description

An Asynchronous CAN FD Socket

Aliased Type§

pub struct CanFdSocket(/* private fields */);

Implementations§

Source§

impl CanFdSocket

Source

pub async fn write_frame<F>(&self, frame: &F) -> IoResult<()>
where F: Into<CanAnyFrame> + AsPtr,

Write a CAN FD frame to the socket asynchronously

Source

pub fn try_write_frame<F>(&self, frame: &F) -> IoResult<()>
where F: Into<CanAnyFrame> + AsPtr,

Attempt to write a CAN frame to the socket without blocking.

Returns WouldBlock if the send buffer is full.

Bypasses the tokio readiness reactor: this call goes straight to the underlying non-blocking fd, so no AsyncFd readiness event is consumed. Mixing with write_frame on the same socket is safe — the async path will simply re-check OS-level readiness on its next poll and may briefly round-trip through WouldBlock before re-arming.

Source

pub async fn read_frame(&self) -> IoResult<CanAnyFrame>

Reads a CAN FD frame from the socket asynchronously

Source

pub fn try_read_frame(&self) -> IoResult<CanAnyFrame>

Attempt to read a CAN frame from the socket without blocking.

Returns WouldBlock if no frame is immediately available.

Bypasses the tokio readiness reactor: this call goes straight to the underlying non-blocking fd, so no AsyncFd readiness event is consumed. Mixing with read_frame on the same socket is safe — the async path will simply re-check OS-level readiness on its next poll and may briefly round-trip through WouldBlock before re-arming.

Source

pub fn has_hw_timestamps(&self) -> bool

Returns true if the bound interface supports hardware receive timestamps.

Source

pub async fn read_frame_with_timestamp( &self, ) -> IoResult<(CanAnyFrame, SystemTime)>

Read a CAN frame and its socket-layer arrival timestamp asynchronously.

Requires SocketOptions::set_recv_timestamp to be called first.

Source

pub async fn read_frame_with_timestamps( &self, ) -> IoResult<(CanAnyFrame, CanTimestamps)>

Read a CAN frame and all available timestamps asynchronously.

Timestamp fields are None for modes not enabled on the socket.

Source

pub async fn read_frame_with_hw_timestamp( &self, ) -> IoResult<(CanAnyFrame, Duration)>

Read a CAN frame and its raw hardware clock timestamp asynchronously.

Requires SocketOptions::set_timestamping with SOF_TIMESTAMPING_RX_HARDWARE | SOF_TIMESTAMPING_OPT_CMSG to be called first.

Trait Implementations§

Source§

impl AsyncRead for CanFdSocket

Source§

fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll<IoResult<()>>

Attempts to read from the AsyncRead into buf. Read more
Source§

impl AsyncWrite for CanFdSocket

Source§

fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<IoResult<usize>>

Attempt to write bytes from buf into the object. Read more
Source§

fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<IoResult<()>>

Attempts to flush the object, ensuring that any buffered data reach their destination. Read more
Source§

fn poll_shutdown( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll<IoResult<()>>

Initiates or attempts to shut down this writer, returning success when the I/O connection has completely shut down. Read more
Source§

fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>

Like poll_write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

Determines if this writer has an efficient poll_write_vectored implementation. Read more
Source§

impl Sink<CanAnyFrame> for CanFdSocket

Source§

type Error = Error

The type of value produced by the sink when an error occurs.
Source§

fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>

Attempts to prepare the Sink to receive a value. Read more
Source§

fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<()>>

Flush any remaining output from this sink. Read more
Source§

fn poll_close(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<()>>

Flush any remaining output and close this sink, if necessary. Read more
Source§

fn start_send(self: Pin<&mut Self>, item: CanAnyFrame) -> Result<()>

Begin the process of sending a value to the sink. Each call to this function must be preceded by a successful call to poll_ready which returned Poll::Ready(Ok(())). Read more
Source§

impl Stream for CanFdSocket

Source§

type Item = Result<CanAnyFrame, Error>

Values yielded by the stream.
Source§

fn poll_next( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Self::Item>>

Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None if the stream is exhausted. Read more
Source§

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the stream. Read more