Step-by-Step Guide to Building a WebSocket Chat App with Axum and React

In this guide, we’ll walk through the process of creating a full-stack chat app using WebSocket. Our backend will be built with Axum, a powerful Rust backend framework, and Shuttle, a development platform, while the frontend will be developed using React and Vite. We’ll cover Utilizing WebSocket in Axum and React. Generating unique identifiers using nanoid. Incorporating telemetry with tracing for enhanced logging. You can find the complete code for this project on GitHub....

April 22, 2024 · 12 min

Deploying a Rust WebAssembly (WASM) App to GitHub Pages

In this tutorial, we’ll guide you through the step-by-step process of deploying a Rust WebAssembly (WASM) app on GitHub Pages. The final website will consist of a JavaScript frontend that utilizes WASM, generated from Rust code. The project we’ll use is called lp, a logical operation language that I created earlier. We won’t delve into the implementation details; instead, our focus will be on incorporating WASM into an existing Rust project....

March 5, 2024 · 6 min

Building a Lisp-like Language from Scratch in Rust

This post delves into building an interpreter for a Lisp-like language using Rust. No knowledge beyond Rust basics is required to follow this post. Inspiration and Project Overview Inspired by Stepan Parunashvili’s article Risp (in (Rust) (Lisp)), I created lip, an interpreted language designed for logical operations with a Lisp-like syntax. This supports logical operations (not, and, or), branching (if expression), lambda functions, and variable definition. This post guides you through the process of building an interpreter, focusing on the core functionalities of tokenizing, parsing, and evaluating expressions....

March 4, 2024 · 11 min

PDF Summarizer with Ollama in 20 Lines of Rust

Explore the simplicity of building a PDF summarization CLI app in Rust using Ollama, a tool similar to Docker for large language models (LLM). Ollama allows for local LLM execution, unlocking a myriad of possibilities. This post guides you through leveraging Ollama’s functionalities from Rust, illustrated by a concise example. Since PDF is a prevalent format for e-books or papers, it would be useful to be able to summarize it....

February 10, 2024 · 3 min

Rust Error Handling: thiserror, anyhow, and When to Use Each

In this blog post, we’ll explore strategies for streamlining error handling in Rust using two popular libraries: thiserror and anyhow. We’ll discuss their features, use cases, and provide insights on when to choose each library. TL;DR thiserror simplifies the implementation of custom error type, removing boilerplates anyhow consolidates errors that implement std::error::Error While thiserror provides detailed error information for specific reactions, anyhow hides internal details Return Different Error Types from Function Let’s start by creating a function decode() for illustration....

February 6, 2024 · 6 min

Organize Rust Integration Tests Without Dead Code Warning

In this blog post, we’ll explore strategies for organizing integration tests in Rust, addressing challenges like dead code warnings and maximizing modularity. Integration Testing In Rust Conventionally, integration test files are placed in tests directory at the top level of a project. Let’s create a project for illustration: 1 cargo new --lib my-tests 1 2 3 4 5 6 7 8 ❯ exa --tree --level 2 . ├── Cargo.lock ├── Cargo....

February 5, 2024 · 6 min

Embarking on Backend Development with "Zero To Production In Rust"

In this blog post, I will share insights gained from Zero To Production In Rust, a comprehensive guide to backend development in Rust. Through the development of a newsletter app, this book covers various important topics for developing an API server. TDD and User Stories: A Shared Vision This book adopts Test Driven Development (TDD) as a consistent approach, starting implementation with tests. This improves code reliability and, more importantly, facilitates a shared vision when collaborating with others....

February 4, 2024 · 4 min