Writing a Windows Service in Rust

I’m currently writing a cross-platform server application in Rust which should also be able to run as a service on Windows. While this sounds like a relatively straight-forward thing to do, it was a bit more involved than I originally thought (especially compared to running unix services). Below you’ll find my notes and a well-documented code sample for running a small echo server for demonstration purposes as a Windows service. I’m going to cover service initialization, responding to control commands (like STOP) and also handling shutdowns in a tokio runtime setting where the individual tasks need to be cancelled. The sample application can also be run in console mode and the Windows service parts are conditionally compiled – so you can run/compile it on Unix systems for console mode use as well. ...

February 28, 2026 · David Hamann

Writing scripts in Rust – with rust-script or nightly Cargo

A while ago I stumbled upon rust-script, a tool which lets you write single-file Rust programs and execute them as if they were standalone script files. This comes in very handy when you want to experiment with Rust code, write up executable examples or build small utility programs, but don’t always want to deal with explicitly setting up Cargo projects for every little script. Using rust-script Let’s have a look at how this works: ...

January 30, 2026 · David Hamann