Skip to content

Commit 7721848

Browse files
committed
Turn modules inside-out
1 parent 3dcb672 commit 7721848

File tree

29 files changed

+102
-78
lines changed

29 files changed

+102
-78
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515
### Changed
1616
- Swap PWM channel arguments to references
1717
- All trait methods have been renamed to remove the `try_` prefix (i.e. `try_send` -> `send`) for consistency.
18-
- Moved all traits into two modules depending on the execution model: `blocking` and `nb` (non-blocking).
18+
- Moved all traits into two sub modules for each feature depending on the execution model: `blocking` and `nb` (non-blocking). For example, the spi traits can now be found under `embedded_hal::spi::blocking` or `embedded_hal::spi::nb`.
1919
- Re-export `nb::{block!, Error, Result}` to avoid version mismatches. These should be used instead of
20-
importing the `nb` crate directly in dependendent crates.
20+
importing the `nb` crate directly in dependent crates.
2121
- `blocking::Serial`: renamed `bwrite_all` to `write`, `bflush` to `flush.
2222
- Removed `prelude` to avoid method name conflicts between different flavors (blocking, nb) of the same trait. Traits must now be manually imported.
2323
- Removed the various `Default` marker traits.

src/adc/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! Analog-digital conversion traits
2+
3+
pub mod nb;

src/nb/adc.rs renamed to src/adc/nb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
///
99
/// ```
1010
/// # use core::marker::PhantomData;
11-
/// # use embedded_hal::nb::adc::Channel;
11+
/// # use embedded_hal::adc::nb::Channel;
1212
///
1313
/// struct Adc1; // Example ADC with single bank of 8 channels
1414
/// struct Gpio1Pin1<MODE>(PhantomData<MODE>);
@@ -55,7 +55,7 @@ pub trait Channel<ADC> {
5555
/// of the request (in contrast to continuous asynchronous sampling).
5656
///
5757
/// ```
58-
/// use embedded_hal::nb::adc::{Channel, OneShot};
58+
/// use embedded_hal::adc::nb::{Channel, OneShot};
5959
///
6060
/// struct MyAdc; // 10-bit ADC, with 5 channels
6161
/// # impl MyAdc {

src/blocking/mod.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/capture/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! Input capture traits
2+
3+
pub mod nb;
File renamed without changes.
File renamed without changes.

src/delay/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! Delay traits
2+
3+
pub mod blocking;

src/blocking/digital.rs renamed to src/digital/blocking.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
//! Digital I/O
2+
//!
3+
//! In some cases it's possible to implement these blocking traits on top of one of the core HAL
4+
//! traits. To save boilerplate when that's the case a `Default` marker trait may be provided.
5+
//! Implementing that marker trait will opt in your type into a blanket implementation.
26
37
use core::{convert::From, ops::Not};
48

@@ -7,7 +11,7 @@ use core::{convert::From, ops::Not};
711
/// Conversion from `bool` and logical negation are also implemented
812
/// for this type.
913
/// ```rust
10-
/// # use embedded_hal::blocking::digital::PinState;
14+
/// # use embedded_hal::digital::blocking::PinState;
1115
/// let state = PinState::from(false);
1216
/// assert_eq!(state, PinState::Low);
1317
/// assert_eq!(!state, PinState::High);
@@ -115,7 +119,7 @@ pub trait InputPin {
115119
///
116120
/// ```
117121
/// use core::time::Duration;
118-
/// use embedded_hal::blocking::digital::{IoPin, InputPin, OutputPin};
122+
/// use embedded_hal::digital::blocking::{IoPin, InputPin, OutputPin};
119123
///
120124
/// pub fn ping_and_read<TInputPin, TOutputPin, TError>(
121125
/// mut pin: TOutputPin, delay_fn: &dyn Fn(Duration) -> ()) -> Result<bool, TError>

src/digital/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! Digital I/O traits
2+
3+
pub mod blocking;

0 commit comments

Comments
 (0)