Using serde with different features than a dependency


I have an embedded ARM thing that sends data over the serial port. This data is read by a program which sends the data over a websocket to be displayed in a webpage. To send the data from the embedded thing, I serialize it using ssmarshal which depends on serde. Since it has to run on an embedded thing, I have to disable std in both serde and ssmarshal which is fine.

However, in order to send the data to the sockets, I want to use serde_json which requires serde with std. I thought I could solve it by creating a subcrate, imported by both the embedded project and the host. That crate could then be no_std while the host can use the full version of serde.

However, this doesn’t work becausue aparently you can depend on two crates that both depend on another crate, but with different features.

One solution I tried was to symlink the file with the data definitions, but it seems like the representation generated by ssmarshal is not the same when using std

Is there a neat way to solve this without writing my own encoder for the types that are sent from the embedded device?

Here is a link to the repo if youre interested