Skip to content

Commit 007f7cd

Browse files
committed
CAN: make creation method return option since there is no error type
1 parent 7dc7a7b commit 007f7cd

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/can/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ pub use id::*;
1010
/// A CAN2.0 Frame
1111
pub trait Frame: Sized {
1212
/// Creates a new frame.
13-
/// Returns an error when the data slice is too long.
14-
fn new(id: impl Into<Id>, data: &[u8]) -> Result<Self, ()>;
13+
///
14+
/// This will return `None` if the data slice is too long.
15+
fn new(id: impl Into<Id>, data: &[u8]) -> Option<Self>;
1516

1617
/// Creates a new remote frame (RTR bit set).
17-
/// Returns an error when the data length code (DLC) is not valid.
18-
fn new_remote(id: impl Into<Id>, dlc: usize) -> Result<Self, ()>;
18+
///
19+
/// This will return `None` if the data length code (DLC) is not valid.
20+
fn new_remote(id: impl Into<Id>, dlc: usize) -> Option<Self>;
1921

2022
/// Returns true if this frame is a extended frame.
2123
fn is_extended(&self) -> bool;

0 commit comments

Comments
 (0)