Skip to content

Commit d065eb5

Browse files
eldruinDirbaio
authored andcommitted
Add initial version of migration guide
1 parent 6c09acb commit d065eb5

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

MIGRATING-0.2-1.0.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Migrating from embedded-hal 0.2.x to 1.0.0
2+
3+
## Table of contents
4+
5+
- [Migrating from embedded-hal 0.2.x to 1.0.0](#migrating-from-embedded-hal-02x-to-100)
6+
- [Table of contents](#table-of-contents)
7+
- [Trait organization](#trait-organization)
8+
- [Fallibility](#fallibility)
9+
- [Method renaming](#method-renaming)
10+
- [`nb` dependency](#nb-dependency)
11+
- [Prelude](#prelude)
12+
- [Features](#features)
13+
- [Use-case-specific help](#use-case-specific-help)
14+
- [For driver authors](#for-driver-authors)
15+
- [I2C traits](#i2c-traits)
16+
- [SPI traits](#spi-traits)
17+
- [For HAL authors](#for-hal-authors)
18+
19+
## Trait organization
20+
21+
All traits have been organized in modules depending on their execution model. That includes `blocking` and `nb` for
22+
non-blocking. In the future when we add asynchronous traits, we envision adding a `futures` (or similarly-named) module.
23+
24+
## Fallibility
25+
26+
All trait methods are now fallible so that they can be used in any possible situation.
27+
However, HAL implementations can also provide infallible versions of the methods.
28+
29+
## Method renaming
30+
31+
The methods in `SPI`, `I2C` and `Serial` traits for both `blocking` and `nb` execution models have been renamed
32+
to `write()`, `read()` and `flush()`.
33+
34+
## `nb` dependency
35+
36+
The `Result` type and `block!` macro from the [`nb`] crate are now reexported in `embeddeh_hal::nb`.
37+
This ensures there are no version mismatches.
38+
You should remove the `nb` crate dependency in your `Cargo.toml` in any version and use the reexported items.
39+
40+
In your `Cargo.toml`:
41+
```diff
42+
- nb = "1"
43+
```
44+
45+
In your code:
46+
```diff
47+
- use nb;
48+
+ use embedded_hal::nb;
49+
```
50+
You can also drop `#[macro_use]` if you are using Rust edition 2018.
51+
52+
Alternatively (needs Rust edition 2018):
53+
```diff
54+
- use nb::{Result, block};
55+
+ use embedded_hal::nb::{Result, block};
56+
```
57+
58+
## Prelude
59+
60+
The prelude has been removed because it could make method calls ambiguous, since the method names are now
61+
the same across execution models.
62+
To overcome this, simply import the traits you wish to use individually.
63+
If you run into ambiguous method calls, you can disambiguate using fully-qualified syntax (the error message
64+
from the compiler should already tell you how it should look like in your case) or tweak your trait imports or code
65+
to limit the scope of the trait imports and thus avoid ambiguity.
66+
Please note that it is also possible to import traits *inside a function*.
67+
68+
## Features
69+
70+
The `unproven` feature has been removed and the traits have been marked as proven.
71+
In the past, managing unproven features, and having "sort of breaking" changes have been a struggling point.
72+
Also, people tended to adopt `unproven` features quickly, but the features would take a very
73+
long time to stabilize.
74+
75+
Instead, we would like to push experimentation OUT of the `embedded-hal` crate, allowing people to
76+
experiment externally, and merge when some kind of feasability had been proven.
77+
78+
## Use-case-specific help
79+
80+
### For driver authors
81+
82+
### I2C traits
83+
84+
Nothing changed.
85+
86+
#### SPI traits
87+
88+
For the blocking traits nothing changed.
89+
For the non-blocking traits, TODO
90+
91+
### For HAL authors
92+
93+
TODO
94+
95+
96+
[MeetingSummary]: https://hackmd.io/ck-xRXtMTmKYXdK5bEh82A

0 commit comments

Comments
 (0)