Avoid Option<DeviceType> in all structs
Fixes #4860
It's unfortunate that anyone who deserializes needs to remember to add the custom default path, but we can't add #[serde(default=...)] to the enum itself because that's only supported for structs. A default deserialize implementation sounds a little like overkill.
Welcome all feedback, so I'm just marking this as a draft now.
Codecov Report
Base: 46.91% // Head: 47.04% // Increases project coverage by +0.12% :tada:
Coverage data is based on head (
f73d3cd) compared to base (b6bbe8c). Patch coverage: 89.70% of modified lines in pull request are covered.
Additional details and impacted files
@@ Coverage Diff @@
## main #4861 +/- ##
==========================================
+ Coverage 46.91% 47.04% +0.12%
==========================================
Files 180 181 +1
Lines 14474 14468 -6
==========================================
+ Hits 6791 6806 +15
+ Misses 7683 7662 -21
| Impacted Files | Coverage Δ | |
|---|---|---|
| components/fxa-client/src/internal/http_client.rs | 0.00% <0.00%> (ø) |
|
| .../fxa-client/src/internal/oauth/attached_clients.rs | 0.00% <0.00%> (ø) |
|
| components/fxa-client/src/lib.rs | 0.00% <ø> (ø) |
|
| components/sync15/src/clients_engine/engine.rs | 0.00% <0.00%> (ø) |
|
| components/sync15/src/clients_engine/record.rs | 0.00% <0.00%> (ø) |
|
| components/sync15/src/lib.rs | 100.00% <ø> (ø) |
|
| components/tabs/src/sync/bridge.rs | 0.00% <ø> (ø) |
|
| components/tabs/src/sync/engine.rs | 0.00% <0.00%> (ø) |
|
| components/sync15/src/client_types.rs | 98.14% <100.00%> (-0.79%) |
:arrow_down: |
| components/sync15/src/device_type.rs | 100.00% <100.00%> (ø) |
|
| ... and 3 more |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Having unknown be, say, Unknown(Option<String>) seems ideal, but I'm really not sure how that flies with mobile.
I update this in the following way:
- Moved DeviceType to a new device_type.rs and added many comments about the semantics for serializing etc.
- Deserialize "phone" as
DeviceType::Mobilegiven https://searchfox.org/mozilla-central/rev/a156a65ced2dae5913ae35a68e9445b8ee7ca457/services/sync/modules/engines/clients.js#292 - I doubt we hit that in practice, but I can't see anything wrong with doing this.
I also tested iOS and Android (although I failed to get Fenix working for reasons unrelated to this. So it seems fine to land.