Axum custom request extractor and validator using FromRequest

This post documents what I learned about creating custom Axum extractor which can be used with the validator for validation. Create a new test project: ➜ cargo new request-validator cd request-validator The first crate to be added is axum for Axum framework. request-validator on  main [?] via 🦀 v1.79.0 ➜ cargo add axum Updating crates.io index Adding axum v0.7.5 to dependencies Features: + form + http1 + json + matched-path + original-uri + query + tokio + tower-log + tracing - __private_docs - http2 - macros - multipart - ws Updating crates....

July 12, 2024 · 5 min · 988 words · kenno

Rust cannot find derive macro `Serialize` in this scope

While trying out some Rust exercises, I came across the following error: $ cargo run --bin iter2 Compiling tutor-web-app-ssr v0.1.0 (/home/kenno/dev/rust/chapter7/ezytutors/tutor-web-app-ssr) error: cannot find derive macro `Serialize` in this scope --> tutor-web-app-ssr/src/bin/iter2.rs:17:10 | 17 | #[derive(Serialize, Deserialize)] | ^^^^^^^^^ | note: `Serialize` is imported here, but it is only a trait, without a derive macro --> tutor-web-app-ssr/src/bin/iter2.rs:5:26 | 5 | use serde::{Deserialize, Serialize}; | ^^^^^^^^^ error: cannot find derive macro `Deserialize` in this scope --> tutor-web-app-ssr/src/bin/iter2....

May 22, 2024 · 1 min · 157 words · kenno

Rustup - update and remove Rust toolchain

rustup is a utility used to install and remove rust toolchain. To list the current installed toolchain run: kenno@c2:~$ rustup show Default host: aarch64-unknown-linux-gnu rustup home: /home/kenno/.rustup installed toolchains -------------------- stable-aarch64-unknown-linux-gnu (default) 1.70.0-aarch64-unknown-linux-gnu 1.71.1-aarch64-unknown-linux-gnu 1.72.0-aarch64-unknown-linux-gnu active toolchain ---------------- stable-aarch64-unknown-linux-gnu (default) rustc 1.72.0 (5680fa18f 2023-08-23) To remove a specific version of the toolchain, e.g. 1.70.0-aarch64-unknown-linux-gnu run: kenno@c2:~$ rustup toolchain remove 1.70.0-aarch64-unknown-linux-gnu info: uninstalling toolchain '1.70.0-aarch64-unknown-linux-gnu' info: toolchain '1.70.0-aarch64-unknown-linux-gnu' uninstalled Let’s verify:...

October 19, 2023 · 2 min · 360 words · Kenno