-
Notifications
You must be signed in to change notification settings - Fork 235
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 4 commits
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,17 @@ | ||
//! Async CAN API | ||
|
||
/// An async CAN interface that is able to transmit and receive frames. | ||
pub trait Can { | ||
/// Associated frame type. | ||
type Frame: crate::Frame; | ||
|
||
/// Associated error type. | ||
type Error: crate::Error; | ||
|
||
/// Puts a frame in the transmit buffer. | ||
/// Awaits until space is available in the transmit buffer. | ||
async fn transmit(&mut self, frame: &Self::Frame) -> Result<(), Self::Error>; | ||
|
||
/// Awaits until a frame was received or an error occurred. | ||
async fn receive(&mut self) -> Result<Self::Frame, Self::Error>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,15 @@ | |
|
||
#![warn(missing_docs)] | ||
#![no_std] | ||
|
||
// disable warning for already-stabilized features. | ||
// Needed to pass CI, because we deny warnings. | ||
// We don't immediately remove them to not immediately break older nightlies. | ||
// When all features are stable, we'll remove them. | ||
#![cfg_attr(nightly, allow(stable_features, unknown_lints))] | ||
#![cfg_attr(nightly, feature(async_fn_in_trait, impl_trait_projections))] | ||
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. these cfg_attrs do nothing without this in build.rs. These were for compat with older nightlies before AFIT was stable. Now that AFIT has been stable for a few rust versions since 1.75, i'd just not put them, and support stable 1.75+ only. |
||
#![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? |
||
|
||
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.