I'm a little behind with this update as it took me a little longer to prepare and launch my project: diff-libraries. I'm planning to write a more detailed post on that later, but it's my most involved Rust project so far. The webserver is powered by Rocket and it uses diesel for the SQL backend. I'm using Tera templates, which feel like Jinja2 templates, but are missing some of the nice Flask integrations like url_for
.
I've gotten a pretty good setup going with GitLab-CI now: rust-ci-pipeline (the name and setup are inspired by what Debian has). There are still a few problems with cargo-tarpaulin segfaulting every now and then but I haven't been able to debug it yet.
I published my first real library crate too: eventstreams (docs). It's a wrapper around Wikimedia's new recent changes feed. I think the fact that docs.rs automatically builds documentation for every single library on crates.io, with no extra action needed is a real game changer. Even the auto-generated documentation is super useful, and it makes authors more likely to fill in the documentation knowing that someone will actually read it.
My goal for this past week was to learn async, and I kind of did, I ported subdown3 to be all async. I think I get the basics, but eh, over it for now. The fact that reqwest
didn't let me incrementally migrate from it's blocking mode to the async version was frustrating, because it meant I had to port the entire codebase over to async before I could even get any of it to run to verify I was heading in the right direction.
Code written/released:
Libraries used:
Concepts learned:
- async/await (beginner)
std::thread
- build.rs
- visibility in libraries/modules (
pub
)
Next week:
- I want to have a better understanding of lifetimes, especially with regards to threads.
- @janriemer gave me some tips on mocking libraries that I still need to look into (thanks!).
I think I'm starting to understand why people like Rust so much. The tooling, especially rustup
and cargo
are pretty fantastic. The fact that rustfmt
(code auto-formatter), clippy
(linter) and a test runner are all integrated through cargo
is super convenient. I feel like Python used to have that with setuptools
/setup.py
but over time that's been lost.
This week I ported my Gerrit helper grr to Rust, and wrote a Reddit downloader tool, subdown3, that I originally wrote in Python nearly a decade ago. subdown3 has straightforward command-line options and primarily deals with URL parsing and hitting various APIs. grr is a convenience wrapper around git that just shells out.
I'm also hosting my Rust projects on GitLab, primarily to take advantage of its CI features (which I don't feel like setting up for git.legoktm.com). I've been using cargo-tarpaulin to generate coverage for tests, which has been simple. No extra configuration or anything, you just run it.
One thing I've been struggling with is figuring out how to mock functions. Because grr primarily shells out to git, integration testing isn't that useful, but testing what exactly we're shelling out to is more useful.
Code written:
Libraries used:
Concepts learned:
- iterators
std::process::Command
- publishing stuff on crates.io
Next week:
Originally posted on mastodon.technology.
Took me a while, but libkiwix9 is now waiting in Debian's NEW queue: https://ftp-master.debian.org/new/libkiwix_9.2.2+dfsg-1.html
Also, hopefully going to have another cool announcement in the future, still waiting on a PR to be merged :)
I'm trying to learn Rust this summer. I've found I learn languages the best by just trying to do something in it, figuring out the building blocks as I go along. So I plan on writing/porting different projects to Rust.
This week I set up rustup, installed the stable and nightly toolchains and started getting familiar with cargo/the build system.
I ported my newusers Toolforge tool to Rust. It's a simple web server with a single route that makes an API request, and dumps the output in plaintext.
I picked the rocket
framework because it seemed more straightforward and similar to Python's Flask compared to hyper
, but it was a bit weird to me that it required a nightly build of Rust to compile and run (though it's apparently about to change). I also used Magnus's mediawiki
crate mostly to see what it was like, this API request was so simple I didn't really need any MediaWiki-specific code. Thank you to qedk
in #wikimedia-tech
who helped work around a dependency issue I ran into.
I also wrote up an analysis of supporting Rust tools on Toolforge in the future.
Code written:
Libraries used:
Concepts learned:
Next week:
- Writing a command-line tool.
Originally posted on mastodon.technology.
Tried to get a #rustlang tool deployed on #Toolforge today and failed. Wrote a quick summary on how to move forward: https://phabricator.wikimedia.org/T194953#6183849
Input from experienced rust Toolforgers like @magnusmanske and @danielhglus would be appreciated.
Originally posted on mastodon.technology.
New bugfix release for my Skip Mobile Wikipedia addon: https://addons.mozilla.org/en-US/android/addon/skip-mobile-wikipedia/
It's fully compatible with Firefox for Android if you always want to use the desktop Wikipedia view on your phone. Despite the name, it supports all Wikimedia wikis.
Today's release, 0.2.1, fixes wikidata.org support.