[RFC] Zerocopy for serializing/deserializing ODP service messages #678
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR demonstrates using zerocopy for serializing instead of doing it manually for thermal service messages (and can be used for all services if this approach seems okay).
Notes:
ThermalRequest/ThermalResponseenums themselves, so I derived the appropriate traits for structs which the enums wrapped, then just pattern match over the enum.zerocopy::byteorder::U<N>types to ensure LE representation on the wire (in the very rare case this is running on BE-native hardware) and to force alignment of fields to 1 (since zerocopy does not allow padding and a#repr(packed)could cause issues when accessing the fields from Rust code).U<N>types unfortunately don't impldefmt::Formatso had to manually do it (might try to upstream defmt support)mctp_rstrait methods require serializing into a buffer, instead of just returning a&[u8], so because of that, we lose the zero-copy benefit from zerocopy (and are really just using it for its serialization abilities)The goal is also eventually to have these service message crates be useable from other areas than just the EC (such as host-side secure services).