Skip to content

Commit f3c502a

Browse files
bors[bot]ryankurte
andauthored
Merge #325
325: Update readme notes on alpha / 0.2.x compatibility r=eldruin a=ryankurte i wasn't sure whether to remove the comment about implementing both completely as it seems superfluous given the availability of a `compat` layer? cc. `@eldruin` Co-authored-by: ryan kurte <[email protected]>
2 parents c7497ba + 0566542 commit f3c502a

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

README.md

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,28 +83,18 @@ list.
8383

8484
[awesome-embedded-rust]: https://github.com/rust-embedded/awesome-embedded-rust#driver-crates
8585

86-
### Adding support for an `embedded-hal` `-alpha` version in a HAL implementation
87-
88-
It is possible for HAL implementations to support both the latest `0.2.x` version of `embedded-hal`
89-
as well as the latest `1.0.0-alpha` version side by side. This has several big advantadges:
90-
- Allows for a more gradual upgrade process within the community.
91-
- Allows for a faster upgrade to `1.0` once it comes out.
92-
- Provides more oportunities to test the new `embedded-hal` version.
93-
94-
This approach has been implemented in [LPC8xx HAL](https://github.com/lpc-rs/lpc8xx-hal). Here are the steps:
95-
96-
1. Add a dependency to the latest `embedded-hal` version to `Cargo.toml`.
97-
Use the `package` attribute to refer to it by another name, to prevent name collision
98-
([example](https://github.com/lpc-rs/lpc8xx-hal/blob/a2b774e8a9ef025fb5119ddfb09e1b190e510896/Cargo.toml#L44-L46)).
99-
2. Import the traits into the module where they should be implemented.
100-
Change their name using `as` to prevent name collisions
101-
([example](https://github.com/lpc-rs/lpc8xx-hal/blob/a2b774e8a9ef025fb5119ddfb09e1b190e510896/src/gpio.rs#L49-L53)).
102-
3. Implement the traits next to their non-alpha versions
103-
([example](https://github.com/lpc-rs/lpc8xx-hal/blob/a2b774e8a9ef025fb5119ddfb09e1b190e510896/src/gpio.rs#L767-L782)).
104-
105-
While none of this is hard, some HAL maintainers might prefer not to add a dependency on an alpha version.
106-
The main drawback of this approach is that it requires ongoing updates, as new `embedded-hal` alpha versions come out.
107-
As stated before, `embedded-hal` `-alpha` versions are _not guaranteed_ to be compatible with each other.
86+
### Supporting different (alpha and non-alpha) HALs
87+
88+
[embedded-hal-compat](https://github.com/ryankurte/embedded-hal-compat) provides shims
89+
to support interoperability between the latest `0.2.x` and `1.0.0-alpha.N` HALs, allowing one to use
90+
incompatible HAL components (generally) without alteration.
91+
See the [docs](https://docs.rs/embedded-hal-compat/) for examples.
92+
93+
It is also possible for HAL implementations to support both the latest `0.2.x` and `1.0.0-alpha.N` versions
94+
side by side, for an example see [LPC8xx HAL](https://github.com/lpc-rs/lpc8xx-hal).
95+
96+
Note that `embedded-hal` `-alpha` versions are a moving target and _not guaranteed_ to be compatible.
97+
Because of this we only aim to support the latest `-alpha`.
10898

10999
## Minimum Supported Rust Version (MSRV)
110100

0 commit comments

Comments
 (0)