-
Notifications
You must be signed in to change notification settings - Fork 15
Description
I've noticed lately that due to something flaky with my hardware or with gpsd, it tends to emits these JSON messages:
{"class":"DEVICE","path":"/dev/ttyAMA0","activated":0}Serde fails to parse this. The error I get from gpd_proto::get_data() is:
JsonError(Error("invalid type: integer `0`, expected a string", line: 0, column: 0))
Since Device.activated is an Option<String>, this appears to be why it fails on 0, an integer.
According to the gpsd documentation, the "activated" field is only a string, so at first I thought this is a bug in gpsd, since it's not writing the correct output. But apparently this is intentional, since later on in the documentation is this example output:
{"class":"DEVICE","path":"/dev/pts1","activated":0}
So my interpretation is that that the Device.activated should still be an Option<String>, but that a value of 0 should parse as None. Is this possible to do?
(Alternately, it could be an Option<StringOrInt> with an enum for StringOrInt, but that seems excessive and would be an API change.)