Skip to content

Commit beb2dc3

Browse files
committed
can: Merge Transmitter and Receiver traits
1 parent 2c935c1 commit beb2dc3

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/can.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ pub trait Frame: Sized {
4242
fn data(&self) -> &[u8];
4343
}
4444

45-
/// A CAN interface that is able to transmit frames.
46-
pub trait Transmitter {
45+
/// A CAN interface that is able to transmit and receive frames.
46+
pub trait Can {
4747
/// Associated frame type.
4848
type Frame: Frame;
4949

@@ -54,16 +54,8 @@ pub trait Transmitter {
5454
///
5555
/// If the buffer is full, this function will try to replace a lower priority frame
5656
/// and return it. This is to avoid the priority inversion problem.
57+
/// Transmits frames of equal identifier in FIFO fashion.
5758
fn transmit(&mut self, frame: &Self::Frame) -> nb::Result<Option<Self::Frame>, Self::Error>;
58-
}
59-
60-
/// A CAN interface that is able to receive frames.
61-
pub trait Receiver {
62-
/// Associated frame type.
63-
type Frame: Frame;
64-
65-
/// Associated error type.
66-
type Error;
6759

6860
/// Returns a received frame if available.
6961
fn receive(&mut self) -> nb::Result<Self::Frame, Self::Error>;
@@ -163,8 +155,8 @@ pub trait Filter {
163155
fn remote_only(&mut self) -> &mut Self;
164156
}
165157

166-
/// A CAN interface that is able to receive frames and specify filters.
167-
pub trait FilteredReceiver: Receiver {
158+
/// A CAN interface that is able to specify receive filters.
159+
pub trait FilteredReceiver: Can {
168160
/// Associated filter type.
169161
type Filter: Filter;
170162

0 commit comments

Comments
 (0)