use core::time::Duration;
use crate::error::CanError;
use crate::frame::{CanFdFrame, CanFrame, Frame, Timestamped};
pub trait Transmit {
type Error: CanError;
fn transmit(&mut self, frame: &CanFrame) -> Result<(), Self::Error>;
}
pub trait Receive {
type Error: CanError;
type Timestamp: Clone;
fn receive(&mut self) -> Result<Timestamped<CanFrame, Self::Timestamp>, Self::Error>;
fn try_receive(
&mut self,
) -> Result<Option<Timestamped<CanFrame, Self::Timestamp>>, Self::Error>;
fn receive_timeout(
&mut self,
timeout: Duration,
) -> Result<Option<Timestamped<CanFrame, Self::Timestamp>>, Self::Error>;
}
pub trait TransmitFd {
type Error: CanError;
fn transmit_fd(&mut self, frame: &CanFdFrame) -> Result<(), Self::Error>;
}
pub trait ReceiveFd {
type Error: CanError;
type Timestamp: Clone;
fn receive_fd(&mut self) -> Result<Timestamped<Frame, Self::Timestamp>, Self::Error>;
fn try_receive_fd(
&mut self,
) -> Result<Option<Timestamped<Frame, Self::Timestamp>>, Self::Error>;
fn receive_fd_timeout(
&mut self,
timeout: Duration,
) -> Result<Option<Timestamped<Frame, Self::Timestamp>>, Self::Error>;
}