Skip to content

Commit 6261126

Browse files
bors[bot]ryankurte
andauthored
Merge #435
435: Added hal-team meeting minutes r=therealprof a=ryankurte so we have a canonical source, cc. @jamesmunns Co-authored-by: Ryan <[email protected]>
2 parents c6f6484 + 6098981 commit 6261126

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed

minutes/2020-03-10-hal-team.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Embedded-HAL Meeting - 2020-03-10
2+
3+
## Final Summary
4+
5+
We agreed on 5 things to do NOW (e.g. aiming for a 1.0 or pre-1.0 release), and two things we MIGHT do in the future, if necessary.
6+
7+
The things that we WILL do NOW/ASAP, that will constitute a BREAKING change on next release:
8+
9+
1. We will KEEP the "monolithic" embedded-hal crate, where all traits are exposed and developed in a single crate.
10+
* This has the impact of closing/rejecting https://github.com/rust-embedded/embedded-hal/pull/169.
11+
2. We will REMOVE versioned traits within the same repo (e.g. `digital::V2`/`digital::V3`). Instead, all breaking changes will be made by making semver changes to the `embedded-hal` crate directly, e.g. going from `0.9.x` to `0.10.0` or `2.x.y` to `3.0.0`.
12+
* This has the impact of closing/rejecting https://github.com/rust-embedded/wg/pull/393
13+
3. For the next major release, we will ONLY be offering *Fallible* traits, e.g. traits that return `Result`s. All trait method names will be prefixed with `try_` for consistency, e.g. `try_send`.
14+
4. We will not be providing backwards compatibility/blanket impls/semver tricks. We instead are aiming for "one simple breaking change", instead of trying to make things as gentle as possible.
15+
5. We will remove the `unproven` feature. In the future, new traits will only be added when they are already "proven stable", outside of the `embedded-hal` crate.
16+
17+
The things that we MAY do in the future, if necessary, but NOT for the initial release:
18+
19+
6. Reintroduce `Infallible` traits on a case-by-case basis, if there is demand. In particular these may be applied to `Digital*` traits, where it is a very common demand.
20+
7. Split up the embedded-hal traits into separate crates, e.g. one for `embedded-hal-uart`, one for `embedded-hal-spi`
21+
22+
### Justification/Reasoning
23+
24+
#### 1 - Monolithic Crate
25+
26+
In general, we saw this choice of balancing two options:
27+
28+
* A monolithic crate that is tightly versioned, offering:
29+
* Preventing N-to-M version mismatches between individual components of embedded-hal traits
30+
* No complicated crate structure, workspaces, submodules, etc.
31+
* Many individual crates (`embedded-hal-serial`, `-spi`, `-digital`), with MAYBE re-exporting all traits from a top level convenience crate (`embedded-hal`). This could be one repo (with or without a workspace), or multiple separate repos. This would offer:
32+
* Ability to make breaking changes on a single-domain item, e.g. `-serial` could have a breaking change while `-spi` wouldn't.
33+
34+
We decided in favor of the former, for the sake of initial simplicity. If this becomes an issue in practice, e.g. many breaking changes in individual traits causing frequent breaking changes to `embedded-hal` as a crate, we may decide to implement [optional item 7](#7-OPTIONAL---Broken-up-repos).
35+
36+
#### 2 - Removing multiple version in one crate
37+
38+
While well intentioned, having multiple version of a trait (particularly with the same Trait/trait method names) seemed to cause problems in practice, particularly in the `digital::(v1|v2|v3)` transitions. Instead, we decided to use Rust's semantic versioning to manage breaking changes.
39+
40+
#### 3 - Only Fallible Traits
41+
42+
This was a point of extensive discussion. In general, it is difficult to consistently handle (either at the target driver, application, or library driver level) a mix of Fallible and Infallible traits. We would likely have problems where:
43+
44+
* A microcontroller driver implements one flavor of a trait, while a library driver requires the other flavor of a trait, OR
45+
* There would be hard to see "unwraps" implicit in the code when providing compatibility
46+
47+
In order to support the general case of "handle errors explicitly", we decided to only offer Fallible traits to start.
48+
49+
If this is TOO painful in practice, in particular with types that almost never are fallible, such as GPIOs using `Digital` traits, we may decide to implement [optional item 6](#6-OPTIONAL---Infallible-traits).
50+
51+
#### 4 - No mitigations for breaking changes
52+
53+
This was also a point of extensive discussion. In practice, all attempts in the past to "mitigate" breaking changes through semver tricks, blanket impls, or other approaches have generally had unforseen negative side effects, either immediately, or when later changes were desired.
54+
55+
Instead, we decided to "keep it simple", which would require many crates to change in a breaking way, but also hopefully in a very simple way. We also discussed tooling to discover and propose changes/PRs across the ecosystem to help mitigate usage issues.
56+
57+
#### 5 - No more `unproven` feature
58+
59+
In the past, managing `unproven` features, and having "sort of breaking" changes have been a struggling point. Also, people tended to adopt `unproven` features quickly, but the features would take a very long time to stabilize.
60+
61+
Instead, we would like to push experimentation OUT of the embedded-hal crate, allowing people to experiment externally, and merge when some kind of feasability had been proven.
62+
63+
We don't plan to specify exhaustively *HOW* to achieve this, but instead provide some examples that could make sense. Examples of how to do this include:
64+
65+
* For standalone traits, e.g. for CAN, you could make a standalone "trait crate". Once it hits community acceptance/"1.0 status", then we can merge it into embedded-hal
66+
* For additions/modifications to existing traits, this could be done by forking embedded-hal, and providing an example impl or two across different targets/drivers to demonstrate feasability. These could be breaking or non-breaking changes
67+
68+
Acceptance of new traits/modules/functions, it would be up to the `embedded-hal` team to discuss and approve changes. These discussions should be "lighter" for non-breaking changes, and breaking changes should be considered carefully.
69+
70+
#### 6 (OPTIONAL) - Infallible traits
71+
72+
See [required item 3](#3---Only-Fallible-Traits).
73+
74+
#### 7 (OPTIONAL) - Broken up repos
75+
76+
See [required item 1](#1---Monolithic-Crate).
77+
78+
## Meeting Notes:
79+
80+
## Topics
81+
82+
- digital:v3 https://github.com/rust-embedded/wg/pull/393
83+
- Make automatic conversion opt-in
84+
- Re-Organizing Repo: https://github.com/rust-embedded/embedded-hal/pull/169
85+
- Criteria to actually accept things into embedded hal? https://github.com/rust-embedded/wg/pull/415
86+
- Remove unproven config gate
87+
88+
89+
James' meta proposal:
90+
91+
- embedded-hal as a top level item
92+
- All independent areas as standalone crates
93+
- No more "proven", we merge things to the meta for approval
94+
95+
problems:
96+
97+
- NxM compatibility problem
98+
99+
Choices:
100+
101+
- Monorepo + Crate
102+
- Monometacrate, individual parts
103+
104+
Splitting crates into pieces:
105+
106+
- Makes workspaces harder to manage
107+
- Submodules can be bad
108+
109+
Two options:
110+
111+
- Workspaces
112+
- Problem publishing
113+
- Totally separate crates
114+
- Have to pull them in, compilation time
115+
116+
Can't get things done, because tedious
117+
118+
```rust
119+
trait Uart {
120+
type Error;
121+
122+
fn try_send(&mut self, u8) -> Result<(), Self::Error>;
123+
124+
// Default, but overridable impl
125+
fn send(&mut self, foo: u8) {
126+
self.try_send(foo).unwrap();
127+
}
128+
}
129+
130+
// in nrf52-hal
131+
impl Uart for nUart {
132+
type Error = Infallible;
133+
134+
fn try_send(&mut self, u8) -> Result<(), Self::Error> {
135+
unimplemented!()
136+
}
137+
}
138+
```
139+
140+
https://github.com/ryankurte/rust-embedded-driver

0 commit comments

Comments
 (0)