Skip to content

async/spi: add helper methods to SpiDevice. #373

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

Merged
merged 1 commit into from
Mar 12, 2022

Conversation

Dirbaio
Copy link
Member

@Dirbaio Dirbaio commented Mar 11, 2022

It's not possible to add them as default methods to SpiDevice itself,
but it's possible to do via an extension trait!

With this, you can avoid interacting with the horrible async closure hack in most
cases. You can now do my_device.write(&buf).await, just like with bare buses.

It's not possible to add them as default methods to `SpiDevice` itself,
but it's possible to do via an extension trait!

With this, you can avoid interacting with the horrible async closure hack in most
cases. You can now do `my_device.write(&buf).await`, just like with bare buses.
@Dirbaio Dirbaio requested a review from a team as a code owner March 11, 2022 20:33
@rust-highfive
Copy link

r? @eldruin

(rust-highfive has picked a reviewer for you, use r? to override)

Copy link
Member

@eldruin eldruin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
Can it be a problem downstream to have the automatic implementation of SpiDeviceExt for all T: SpiDevice ?

@Dirbaio
Copy link
Member Author

Dirbaio commented Mar 11, 2022

Yes. Actually, all SpiDeviceExt impl downstream will conflict with the one in this crate. It's impossible to impl SpiDeviceExt downstream.

That's exactly what we want though. Downstream is supposed to impl just SpiDevice. That makes SpiDeviceExt automatically available.

@ryankurte
Copy link
Contributor

oooh, looks neat!

(gosh i can't wait for actual async traits 😂)

Copy link
Member

@eldruin eldruin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, let's get this merged and gather experiences. Thank you!
bors r+

@bors bors bot merged commit 47df22c into rust-embedded:master Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants