1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
<!DOCTYPE html>
<html>
<head>
<title>n00bing through Rust</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<textarea id="source">
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
- 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?
</textarea>
<script src="https://remarkjs.com/downloads/remark-latest.min.js" type="text/javascript">
</script>
<script type="text/javascript">
var slideshow = remark.create();
</script>
</body>
</html>
|