Querying SQLServer using Rust via ODBC

SQL Server is very easy to interact with in .Net thanks to ADO.Net. There is no Rust port however. So how can you interact with SQL Server from a Rust application? As of now, the easiest is to use the official ODBC driver (get it here). It’s available for every major platform so your Rust code will remain cross-platform. As for Rust, there is an excellent crate called odbc that makes working with FFI easier....

13 May 2021 · 6 min · Francesco Cogno

Let's build a Prometheus exporter in Rust

Intro In this post we will build a very simple Prometheus exporter in Rust. Prometheus is a time-series database especially useful in storing and retrieving OS vital signs. It can be paired with Grafana in order to create beautiful dashboards, like this one below: Prometheus is peculiar because instead of receiving the events to store it goes on and retrieves them itself. There is no magic though: Prometheus just calls a preconfigured URI and expects a very specific plain text output....

19 June 2019 · 8 min · Francesco Cogno

Rust builder pattern with types

Intro Rust has a very rich type system. It also has move semantics. Using these two features together you can build your APIs using the builder pattern. Let’s see an actual example on why you would want to use the builder pattern and how to implement is (well, I’m showing you a way to implement it, not necessarily the best one). Example Suppose we have a function that takes a lot of parameters: some of them are mandatory, others are optional....

26 July 2018 · 8 min · Francesco Cogno

Let's build Zork using Rust!

Games like Zork are basically big state machines. You advance in the game performing actions that lead your character from situation to situation. Eventually you either die horribly or win the game. The purpose of this post is to build a - simplified - textual game. We use it as a pretext to explore one way of treating state machines using Rust (yes, it’s a clickbaity title)… State machines in Rust There are various ways to model a state machine in Rust....

17 January 2018 · 8 min · Francesco Cogno