Skip to content

Commit 94a7844

Browse files
authored
Merge pull request #558 from Dirbaio/spi-nodelay-warn
bus/spi: add semver risk warning to `new_no_delay`.
2 parents 5f5570d + 101c6f9 commit 94a7844

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

embedded-hal-bus/src/spi/critical_section.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ impl<'a, BUS, CS, D> CriticalSectionDevice<'a, BUS, CS, D> {
3434
impl<'a, BUS, CS> CriticalSectionDevice<'a, BUS, CS, super::NoDelay> {
3535
/// Create a new [`CriticalSectionDevice`] without support for in-transaction delays.
3636
///
37+
/// **Warning**: The returned instance *technically* doesn't comply with the `SpiDevice`
38+
/// contract, which mandates delay support. It is relatively rare for drivers to use
39+
/// in-transaction delays, so you might still want to use this method because it's more practical.
40+
///
41+
/// Note that a future version of the driver might start using delays, causing your
42+
/// code to panic. This wouldn't be considered a breaking change from the driver side, because
43+
/// drivers are allowed to assume `SpiDevice` implementations comply with the contract.
44+
/// If you feel this risk outweighs the convenience of having `cargo` automatically upgrade
45+
/// the driver crate, you might want to pin the driver's version.
46+
///
3747
/// # Panics
3848
///
3949
/// The returned device will panic if you try to execute a transaction

embedded-hal-bus/src/spi/exclusive.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ impl<BUS, CS, D> ExclusiveDevice<BUS, CS, D> {
4545
impl<BUS, CS> ExclusiveDevice<BUS, CS, super::NoDelay> {
4646
/// Create a new [`ExclusiveDevice`] without support for in-transaction delays.
4747
///
48+
/// **Warning**: The returned instance *technically* doesn't comply with the `SpiDevice`
49+
/// contract, which mandates delay support. It is relatively rare for drivers to use
50+
/// in-transaction delays, so you might still want to use this method because it's more practical.
51+
///
52+
/// Note that a future version of the driver might start using delays, causing your
53+
/// code to panic. This wouldn't be considered a breaking change from the driver side, because
54+
/// drivers are allowed to assume `SpiDevice` implementations comply with the contract.
55+
/// If you feel this risk outweighs the convenience of having `cargo` automatically upgrade
56+
/// the driver crate, you might want to pin the driver's version.
57+
///
4858
/// # Panics
4959
///
5060
/// The returned device will panic if you try to execute a transaction

embedded-hal-bus/src/spi/mutex.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ impl<'a, BUS, CS, D> MutexDevice<'a, BUS, CS, D> {
3232
impl<'a, BUS, CS> MutexDevice<'a, BUS, CS, super::NoDelay> {
3333
/// Create a new [`MutexDevice`] without support for in-transaction delays.
3434
///
35+
/// **Warning**: The returned instance *technically* doesn't comply with the `SpiDevice`
36+
/// contract, which mandates delay support. It is relatively rare for drivers to use
37+
/// in-transaction delays, so you might still want to use this method because it's more practical.
38+
///
39+
/// Note that a future version of the driver might start using delays, causing your
40+
/// code to panic. This wouldn't be considered a breaking change from the driver side, because
41+
/// drivers are allowed to assume `SpiDevice` implementations comply with the contract.
42+
/// If you feel this risk outweighs the convenience of having `cargo` automatically upgrade
43+
/// the driver crate, you might want to pin the driver's version.
44+
///
3545
/// # Panics
3646
///
3747
/// The returned device will panic if you try to execute a transaction

embedded-hal-bus/src/spi/refcell.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ impl<'a, BUS, CS, D> RefCellDevice<'a, BUS, CS, D> {
3131
impl<'a, BUS, CS> RefCellDevice<'a, BUS, CS, super::NoDelay> {
3232
/// Create a new [`RefCellDevice`] without support for in-transaction delays.
3333
///
34+
/// **Warning**: The returned instance *technically* doesn't comply with the `SpiDevice`
35+
/// contract, which mandates delay support. It is relatively rare for drivers to use
36+
/// in-transaction delays, so you might still want to use this method because it's more practical.
37+
///
38+
/// Note that a future version of the driver might start using delays, causing your
39+
/// code to panic. This wouldn't be considered a breaking change from the driver side, because
40+
/// drivers are allowed to assume `SpiDevice` implementations comply with the contract.
41+
/// If you feel this risk outweighs the convenience of having `cargo` automatically upgrade
42+
/// the driver crate, you might want to pin the driver's version.
43+
///
3444
/// # Panics
3545
///
3646
/// The returned device will panic if you try to execute a transaction

0 commit comments

Comments
 (0)