Menu
Sign In Search Podcasts Charts People & Topics Add Podcast API Blog Pricing

Sebastian Scholz

๐Ÿ‘ค Speaker
485 total appearances

Appearances Over Time

Podcast Appearances

Rust in Production
Gama Space with Sebastian Scholz

Or in newer versions, at the time they didn't have that, but in newer versions you have a try variant of all of their functions, which allows to test for certain invariants.

Rust in Production
Gama Space with Sebastian Scholz

For example, if you want to receive a Boolean, a Boolean can either be 1 or 0, but a byte can be 0 to 255, right?

Rust in Production
Gama Space with Sebastian Scholz

So you have a bunch more values that normally shouldn't be allowed.

Rust in Production
Gama Space with Sebastian Scholz

These need to be verified.

Rust in Production
Gama Space with Sebastian Scholz

And that's also one of the critical things.

Rust in Production
Gama Space with Sebastian Scholz

In C, I saw a bunch of code where you just convert from your bytes into integers.

Rust in Production
Gama Space with Sebastian Scholz

And then you use those integers somewhere else.

Rust in Production
Gama Space with Sebastian Scholz

And so it's very easy to mess up

Rust in Production
Gama Space with Sebastian Scholz

with just not validating your inputs enough.

Rust in Production
Gama Space with Sebastian Scholz

And especially if you accept input over satellite connection, there's a bunch of bits that can flip.

Rust in Production
Gama Space with Sebastian Scholz

There's a bunch of stuff that can just go wrong.

Rust in Production
Gama Space with Sebastian Scholz

And so you really need to be sure to pass it correctly.

Rust in Production
Gama Space with Sebastian Scholz

And once again, we can use Rust's type system by making the constructors to all of these payload structs private.

Rust in Production
Gama Space with Sebastian Scholz

and letting it just take bytes and doing all of this validation in this new function, in the constructor, and returning an option of ourself, or a result of ourself.

Rust in Production
Gama Space with Sebastian Scholz

And so if any of the preconditions, they're just local, they're right next to the struct, so it's easy to verify that all of the preconditions that we need when converting from a byte string are checked for.

Rust in Production
Gama Space with Sebastian Scholz

And then afterwards, you're sure if you have the struct, its data is validated.

Rust in Production
Gama Space with Sebastian Scholz

Actually, we have no instances of transmute and it's on the list of things that we really try to avoid.

Rust in Production
Gama Space with Sebastian Scholz

And so far, we have not come across of a use case that is not covered by zero copy.

Rust in Production
Gama Space with Sebastian Scholz

So, of course, sometimes we have to convert between different types in Rust and we use S for that.