I originally planned to make a Rust program that would fix the broken encodings in my music files. Luckily, I could solve that without Rust. Luckily, because from what I’ve experienced since then, it would’ve been a horrible pain in the ass to do.
I still wanted to give Rust a try. Contributing Servo is pretty much out of question – it’s just too high level to jump into as a complete beginner. (And honestly, I don’t think I’ll get past “complete beginner” with Rust anytime soon if ever.) It wasn’t hard to find another issue.
Namely, my new phone (an Xperia XZ1 Compact) won’t let me mount it using MSC, only MTP. It works in Ubuntu, kinda. I can definitely mount the phone, browse and copy files, all that. Except… Clementine, the music player I’d always use to sync my playlist to my phone, can’t seem to handle MTP. It crashes every single time I try. I couldn’t find another music player that could do the job.
Since I couldn’t find a way to mount my phone MSC mode anywhere in its settings and Clementine wordlessly dies otherwise, I decided to make a syncing script in Rust. The task is simple: given an M3U file (which I generate in Clementine) and a target
mtp:// path, copy all the files in the playlist to the target folder.
It took two days of suffering, but now I have a bare minimal working code. Needless to say, it wasn’t a joyride. Handling MTP itself was relatively easy – I just needed to call
Commands. The rest, though…
The strong typing makes Rust insufferable and getting everything wrapped in
Options that I’d need to
match for errors just makes it worse.
I understand where it’s coming from (I’d love to use some type/class restrictions in big Ruby programs), but it’s done nothing but get in my way achieving a relatively simple task. It kept yelling at me with errors I couldn’t make any sense of (and searching the net didn’t really help), most of which I solved by putting
&s in various places until it stopped yelling. Not having a REPL/console to test in just makes it worse.
I tried to go a bit further and copy the files into “artist – album” folders, but the ID3 library I found would die with “not valid utf-8” errors so I just gave up. And then I didn’t even attempt converting non-mp3 files.
Honestly I think I’d have had an easier time achieving the same in plain Shell and I’ve forgotten all the Shell I ever knew years ago. Or maybe I could just symlink the MTP-mounted drive somehow?
To sum it up, I’ll not touch Rust again with a ten feet pole unless you pay me to. And I thought Clojure’s cryptic error messages were bad.