-
Notifications
You must be signed in to change notification settings - Fork 238
Add async API for CAN #585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
2e5301d
d6315c1
f772c8a
0fbbbd6
94b2c2d
5d35622
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//! Async CAN API | ||
|
||
/// An async CAN interface that is able to transmit frames. | ||
pub trait CanTx { | ||
/// Associated frame type. | ||
type Frame: crate::Frame; | ||
|
||
/// Associated error type. | ||
type Error: crate::Error; | ||
|
||
/// Puts a frame in the transmit buffer or awaits until space is available | ||
/// in the transmit buffer. | ||
async fn transmit(&mut self, frame: &Self::Frame) -> Result<(), Self::Error>; | ||
} | ||
|
||
/// An async CAN interface that is able to receive frames. | ||
pub trait CanRx { | ||
/// Associated frame type. | ||
type Frame: crate::Frame; | ||
|
||
/// Associated error type. | ||
type Error: crate::Error; | ||
|
||
/// Awaits until a frame was received or an error occurs. | ||
async fn receive(&mut self) -> Result<Self::Frame, Self::Error>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,9 @@ | |
|
||
#![warn(missing_docs)] | ||
#![no_std] | ||
#![allow(async_fn_in_trait)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this still required on stable Rust? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not, however, an appropriate MSRV should be used in Cargo.toml for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is required for the MSRV listed in the Cargo.toml (1.81). Do you want me to keep it or bump the MSRV? |
||
|
||
pub mod asynch; | ||
pub mod blocking; | ||
pub mod nb; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think these should be in the form
to avoid needing
#![allow(async_fn_in_trait)]
(which iirc will be deprecated in the future). you can still implement usingasync fn
in either case.