class: middle, center # n00bing through Rust ## Yuval Adam --- class: middle, left # Yuval Adam - Full stack developer - Freelance consultant - 10+ years Pythonista - [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 # Slinging media files over UPnP - Reverse engineering a cheap HDMI/UPnP dongle - [https://github.com/yuvadm/rockcast](https://github.com/yuvadm/rockcast) --- class: middle, left # UPnP Casting - 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 --- 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  --- 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, 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 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 # Learn **idiomatic** Rust as fast as possible --- class: middle, left # Title 8 --- class: middle, left # Title 9