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

I mean, it's okay if you use the same pin for two different things.

Rust in Production
Gama Space with Sebastian Scholz

You can write to the registers and it's not going to care.

Rust in Production
Gama Space with Sebastian Scholz

But the end result is that

Rust in Production
Gama Space with Sebastian Scholz

the pin is not going to do what you want because you're using it for two things at the same time.

Rust in Production
Gama Space with Sebastian Scholz

And by expressing this notion of only one part of your program can use this specific thing via a token, the compiler can ensure that this, in fact, is the case.

Rust in Production
Gama Space with Sebastian Scholz

Exactly.

Rust in Production
Gama Space with Sebastian Scholz

Yes, we use this in a bunch of places.

Rust in Production
Gama Space with Sebastian Scholz

Also, for example, for wrapping C libraries, it's kind of an interesting thing.

Rust in Production
Gama Space with Sebastian Scholz

During our Gamma Alpha project, we used a communication protocol called CSP.

Rust in Production
Gama Space with Sebastian Scholz

And unfortunately, at the time, there was no pure Rust implementation of it.

Rust in Production
Gama Space with Sebastian Scholz

So we had no choice but to wrap, well, either implement the whole thing ourselves, but that would have taken quite a bit of time, which we didn't have, or to wrap the C library.

Rust in Production
Gama Space with Sebastian Scholz

And the C library has a bunch of invariants when you use it.

Rust in Production
Gama Space with Sebastian Scholz

One of them is you have to call a function called CSP init before you do anything else.

Rust in Production
Gama Space with Sebastian Scholz

And so this kind of a thing, once again, we have a serial size struct in Rust called CSP.

Rust in Production
Gama Space with Sebastian Scholz

It has an init function and it gives you, is the only place where you can get an instance of this CSP struct.

Rust in Production
Gama Space with Sebastian Scholz

And then the CSP struct allows you to call other functions on itself.

Rust in Production
Gama Space with Sebastian Scholz

But you need a self, so you need an instance of destruct.

Rust in Production
Gama Space with Sebastian Scholz

And so that proves that you have initialized the CSP, the underlying C library.

Rust in Production
Gama Space with Sebastian Scholz

There's only one place to get this token.

Rust in Production
Gama Space with Sebastian Scholz

And in that place, we initialized the library just before.