class: middle, center # n00bing through Rust ## Yuval Adam --- class: middle, left # Yuval Adam - Full stack developer - Freelance consultant - 10+ years Pythonista, Rust n00b - [https://yuv.al](https://yuv.al) - [@yuvadm](https://twitter.com/yuvadm) --- class: middle, left ## Baby steps - [https://doc.rust-lang.org/book/second-edition/](https://doc.rust-lang.org/book/second-edition/) - Book is a great reference for specific concepts - That's it. - [https://exercism.io/tracks/rust](https://exercism.io/tracks/rust) - Exercism is a good *exercise* - But I need a real-world project... --- class: middle, left # HDMI "Anycast"
- Reverse engineering a cheap HDMI/UPnP dongle - [https://github.com/yuvadm/rockcast](https://github.com/yuvadm/rockcast) --- class: middle, left # UPnP Casting - Send a UPnP discovery packet over **UDP** broadcast - Dongle on LAN responds with some fugly **XML** - Serve the media file over **HTTP** - Send an XML request to the dongle pointing to the file - Send play/pause actions as neccesary You can implement this with several dozen lines of Python/JS (or any other modern "dynamic" language) --- class: middle, left # UPnP Casting ## Dependencies - `clap` for CLI - `hyper` for HTTP calls - `tokio-fs` for serving the static file - `tokio-io` for handling UDP traffic - `tokio` for wrapping it all in one runtime - `futures` because... you need it It's on [https://github.com/yuvadm/slingr](https://github.com/yuvadm/slingr) --- class: middle, left background-image: url(https://cdn-images-1.medium.com/max/2000/1*TLk1BwXIZA5kaMhEbTXY0g.jpeg) background-size: cover # .white[Rust is **not** a high-level language] --- class: middle, center background-image: url(https://hackerwarehouse.com/wp-content/uploads/2013/03/rtlsdr-dvbt-820t2-454A9410a.jpg) background-size: cover --- class: middle, left # RTL-SDR - A very cool piece of hardware used as *poor man's Software Defined Radio* - [SDR Intro talk at PyCon 2018](https://www.youtube.com/watch?v=xJOFaOM2wUc) (not really a Python talk) - Reference library implemented in C + heavy usage of `libusb` - Let's do an exercise rewrite! --- class: middle, center  --- class: middle, left # `impl RtlSdr` - C **is** the original systems programming language - Writing low-level code gives you a much better grasp of the language vs. C - Personal anecdote: - *really* hard to stop thinking in OOP terms - Especially not having **inheritance** in your toolkit Work in progress at [https://github.com/yuvadm/rustl-sdr/](https://github.com/yuvadm/rustl-sdr/) --- class: top, center background-image: url(https://i2.wp.com/i40club.com/wp-content/uploads/2017/11/Enlightenment-5-Simple-Steps.jpg) background-size: cover # **Idiomatic** Rust --- class: middle, left background-image: url(https://lumiere-a.akamaihd.net/v1/images/Yoda-Retina_2a7ecc26.jpeg) background-size: cover # .white[Mentors] --- class: middle, left ## `:s/mentors/references/g` - [Unofficial Rust API Guidelines](https://rust-lang-nursery.github.io/api-guidelines/) - [Unofficial Rust Design Patterns](https://github.com/rust-unofficial/patterns) - [Writing an OS in Rust](https://os.phil-opp.com/) - [Writing a browser layout engine in Rust](https://limpet.net/mbrubeck/2014/08/08/toy-layout-engine-1.html) - [Building a DNS server in Rust](https://github.com/EmilHernvall/dnsguide) --- class: middle, left # Thanks! ## Questions?