theomn.com

Latest Posts

  • Published on

    Rust Error Handling for Pythonistas

    Sometimes things don't turn out the way we want. For instance, I never should have looted that (supposedly cursed) jewel-encrusted sceptre from the Tomb of Rosetta.

    Error handling in Rust, with its extra type-system concerns, can feel awkward when coming from a language like Python.

    In this post, we'll pretend to write a program that will report how many followers you've lost on some imaginary social network (since the last time you checked). Using this premise we'll compare some differences and similarities in the error handling patterns in Python and Rust.

  • Published on

    Writing a Web API Client in Rust (Part 3)

    Continuing on from the previous post in the series (Part 2), this post will be focusing on making async HTTP requests, generics, and JSON parsing with serde.

    This time we'll be assembling all the pieces we've built thus far, and calling them from some new binary targets.

  • Published on

    Writing a Web API Client in Rust (Part 2)

    Continuing on from the previous post in the series (Part 1), this post will focus on making async HTTP requests, and JSON parsing with serde.

    Much of this post will be spent introducing concepts and building foundational tech that will be put to use in the next post.

  • Published on

    Writing a Web API Client in Rust (Part 1)

    Writing a client for a web API is a trivial task in many languages. In fact, as a new student of Python, you might even build such a thing soon after a "hello world".

    If you are new to Rust, you may immediately run into a few topics which I think are non-obvious, and perhaps difficult to navigate from a cold start.

    This series of posts aims to break the ice by working through a toy example using the public Marvel Comics API. Along the way, I'll touch on some of the popular library choices and how they apply to the problem at hand.

    Some of the Rust topics we'll cover in this series include:

    • Working with "split" crate project (multiple binaries with a shared library).
    • Interior Mutability.
    • Using generics to reduce code duplication.
    • Making async HTTP requests with hyper, futures, and tokio.
    • JSON parsing with serde.

    In this post of the series, we'll be focusing on project setup and interior mutability.