Sebastian Scholz
๐ค SpeakerAppearances Over Time
Podcast Appearances
You need to provide your own heap if you need it.
And so you're very, very specific about the places that you need a heap.
And you try to avoid it in all other cases.
One thing that can help with that a lot is a crate called ZeroCopy, for example.
In our telecommand and telemetry system, we use it very extensively.
So the way it works is you define your structs, the data that you want to send, want to be able to send, and you use your copy to convert them or let them be converted safely into bytes and from bytes.
without the use of an extra buffer, without the use of an extra allocation.
Just the same amount of memory.
It's basically a safe transmute, a safer transmute.
And so, because we need to send the data as bytes, obviously.
So we need to do this conversion to and from bytes.
And zero copy is a great help for that sort of work.
So there's two ways of using it.
First of all, the easy way is you already have a struct and you want to convert it into bytes and send those bytes over the network.
Zero copy helps you with that.
But then the other way around is
You receive a bunch of bytes and then you want to pass these bytes as a struct.
And zero copy makes this passing, this conversion from just a view of the bytes into a reference to the actual struct possible and safe.
by making sure that there's no invariants that can't be uphold.