use std::future::Future;
pub mod constant;
pub mod frame;
pub mod identifier;
pub mod j1939;
pub trait Conversion
where
Self: Sized, {
type Type;
fn from_bits(bits: Self::Type) -> Self;
fn from_hex(hex_str: &str) -> Self;
fn try_from_bits(bits: Self::Type) -> Option<Self>;
fn try_from_hex(hex_str: &str) -> Option<Self>;
fn into_bits(self) -> Self::Type;
fn into_hex(self) -> String;
}
#[repr(C)]
#[derive(Debug, Clone, Eq, PartialEq, Default)]
pub enum Direct {
#[default]
Transmit,
Receive,
}
pub trait CanDeviceSync {
type Error;
type Frame;
type Channel;
fn transmit_sync(&self, channel: Self::Channel, frames: Self::Frame, canfd: bool, _: Option<usize>)
-> Result<usize, Self::Error>;
fn receive_sync(&self, channel: Self::Channel, canfd: bool, timeout: Option<usize>)
-> Result<Self::Frame, Self::Error>;
}
pub trait CanDeviceAsync {
type Error;
type Frame;
type Channel;
fn transmit_async(&self, channel: Self::Channel, frames: Self::Frame, canfd: bool, _: Option<usize>)
-> impl Future<Output = Result<usize, Self::Error>>;
fn receive_async(&self, channel: Self::Channel, canfd: bool, timeout: Option<usize>)
-> impl Future<Output = Result<Self::Frame, Self::Error>>;
}