Introducing: DHCProto

DHCProto is available now on DHCProto implements a parser/encoder for DHCPv4 & DHCPv6. This crate was born out of the dearth of DHCP offerings currently available. It has a comprehensive list of option types implemented, includes serializing a message back to bytes, and DHCPv6. This library was written at my work (Bluecat), and they have graciously let us open source it, available on github for issues/comments/PRs. The encoder/decoder traits are inspired a lot by trust-dns-proto. [Read More]

nailgun: DNS benchmarking tool

nailgun is a small hobby project I’ve been working on sparsely for a few months, it’s a cli DNS benchmarking tool heavily inspired by flamethrower but written in Rust with tokio. I’ve been working at the intersection of DNS & Rust for a little while and this is something I’ve been pushing along in my free time. Rest assured, it has no real reason for existing just yet other than I felt like writing it so if you’re looking for a quality DNS performance testing client then you should probably still use flamethrower. [Read More]

A look at tokio 1.0 API Changes

I’ve been working in the Rust space for about a year now using tokio & async/await with DNS. The result of this work is a sizeable from-scratch tokio server using 0.2 (that’s now in production– yay! hopefully I can share more about this later). As a result, I’ve gotten to know the UDP API of tokio quite well, and have even got to submit a few PRs (double yay). I’d like to highlight some interesting changes that have happened in tokio’s API between 0. [Read More]

Cheating Higher Ranks with Traits

I ran into this a little while ago and thought it would be helpful to share a possible solution. Imagine you have an enum that describes a set of possible branches, for each branch there is a type associated with it that you want to run through a function, for this example– serialize. enum Var{One,Two,}#[derive(Serialize)]struct Foo;#[derive(Serialize)]struct Bar;fn write<W>(var: Var,mutwriter: W)-> serde_json::Result<()>whereW: Write,{matchvar{Var::One=>serde_json::to_writer(&mutwriter,&Foo),Var::Two=>serde_json::to_writer(&mutwriter,&Bar),}} Life is good. Then you realize that you actually needed to format these types in two different ways, one with to_writer and the other with to_writer_pretty. [Read More]

Rust for Java Devs

I’d like to take a change for this blog and leave the more bleeding edge topics to focus on perhaps one of the most important things one can do in the Rust community: teaching new Rust developers. I’ve been thinking about how best to approach teaching Rust to those used to working with Java, in order to bring a group of developers up to speed with the language for a new project. [Read More]

Rotary Encoders in Embedded Rust

Recently, I’ve been trying to learn more about electronics and embedded development. Maybe I’m just tired of operating purely in the virtual, but there’s something cool about being able to physically put together a circuit and push a button to make something happen. I went through the usual Arduino resources before seeing what Rust had to offer. I’m happy to report there’s some really good material out there. Discovery book Rust Embedded book Real Time For the Masses If you’re new to embedded (but not new to Rust), I’d recommend the Discovery book as your jumping off point. [Read More]

Updating to Async/Await

Unless you’ve been living under a rock; you know async/await is coming to rust stable. My last post was about implementing a simple protocol using manual futures, and interacting with tokio. It’s only fitting, then, that I update the lib that post was inspired by to async/await and report back on my findings. If you’re curious about my library or you use the window manager i3, it’s available here or on crates under tokio-i3ipc. [Read More]

Protocols in Tokio (i3 IPC)

There’s a dearth of blog posts online that cover the details of implementing a custom protocol in tokio, at least that I’ve found. I’m going to cover some of the steps I went through in implementing an async version i3wm’s IPC. Granted, I’ve not finished my library to a point I’m comfortable releasing it, but I hope I can provide some examples for the aspiring async IO enthusiast that I wish I had when I started. [Read More]

Unit Type Params

Updated: The cs140e hosted on Stanford’s servers is down, but Sergio has helpfully put up an archived copy here. I’ve changed the links in this post to reflect that. I always enjoy reading blogs about patterns or tricks people have picked up writing Rust. I’ve seen this a few times but not read about it anywhere. I’ve been doing class assignments from Operating Systems cs140e. I highly recommend this class if you know a bit of Rust and would like to try writing some lower level code. [Read More]