<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Rust on Kenno&#39;s Open Note</title>
    <link>https://blog.khmersite.net/tags/rust/</link>
    <description>Recent content in Rust on Kenno&#39;s Open Note</description>
    <image>
      <title>Kenno&#39;s Open Note</title>
      <url>https://blog.khmersite.net/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</url>
      <link>https://blog.khmersite.net/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</link>
    </image>
    <generator>Hugo -- 0.154.0</generator>
    <language>en</language>
    <lastBuildDate>Fri, 12 Jul 2024 16:41:07 +1000</lastBuildDate>
    <atom:link href="https://blog.khmersite.net/tags/rust/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Axum custom request extractor and validator using FromRequest</title>
      <link>https://blog.khmersite.net/p/axum-request-extractor-using-fromrequest/</link>
      <pubDate>Fri, 12 Jul 2024 16:41:07 +1000</pubDate>
      <guid>https://blog.khmersite.net/p/axum-request-extractor-using-fromrequest/</guid>
      <description>&lt;p&gt;This post documents what I learned about creating custom Axum extractor which can be used with the &lt;code&gt;validator&lt;/code&gt; for validation.&lt;/p&gt;
&lt;p&gt;Create a new test project:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;➜ cargo new request-validator
cd request-validator
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The first crate to be added is &lt;code&gt;axum&lt;/code&gt; for Axum framework.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;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.io index
     Locking 82 packages to latest compatible versions
...
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;We also need &lt;code&gt;tokio&lt;/code&gt; crate that works together with &lt;code&gt;axum&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Rust cannot find derive macro `Serialize` in this scope</title>
      <link>https://blog.khmersite.net/p/rust-cannot-derive-macro-in-this-scope/</link>
      <pubDate>Wed, 22 May 2024 22:46:23 +1000</pubDate>
      <guid>https://blog.khmersite.net/p/rust-cannot-derive-macro-in-this-scope/</guid>
      <description>&lt;p&gt;While trying out some Rust exercises, I came across the following error:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ 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
  --&amp;gt; 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
  --&amp;gt; tutor-web-app-ssr/src/bin/iter2.rs:5:26
   |
5  | use serde::{Deserialize, Serialize};
   |                          ^^^^^^^^^

error: cannot find derive macro `Deserialize` in this scope
  --&amp;gt; tutor-web-app-ssr/src/bin/iter2.rs:17:21
   |
17 | #[derive(Serialize, Deserialize)]

&amp;lt;SNIP&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This happened because I didn&amp;rsquo;t specify the required dependency feature for &lt;code&gt;serde&lt;/code&gt; crate. Here is what I had in &lt;code&gt;Cargo.toml&lt;/code&gt; when the above error occurred:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Rustup - update and remove Rust toolchain</title>
      <link>https://blog.khmersite.net/p/rustup-update-remove-toolchain/</link>
      <pubDate>Thu, 19 Oct 2023 21:13:20 +1100</pubDate>
      <guid>https://blog.khmersite.net/p/rustup-update-remove-toolchain/</guid>
      <description>&lt;p&gt;&lt;code&gt;rustup&lt;/code&gt; is a utility used to install and remove rust toolchain.&lt;/p&gt;
&lt;p&gt;To list the current installed toolchain run:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;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)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To remove a specific version of the toolchain, e.g. &lt;code&gt;1.70.0-aarch64-unknown-linux-gnu&lt;/code&gt; run:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;kenno@c2:~$ rustup toolchain remove 1.70.0-aarch64-unknown-linux-gnu
info: uninstalling toolchain &amp;#39;1.70.0-aarch64-unknown-linux-gnu&amp;#39;
info: toolchain &amp;#39;1.70.0-aarch64-unknown-linux-gnu&amp;#39; uninstalled
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Let&amp;rsquo;s verify:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;kenno@c2:~$ rustup show
Default host: aarch64-unknown-linux-gnu
rustup home:  /home/kenno/.rustup

installed toolchains
--------------------

stable-aarch64-unknown-linux-gnu (default)
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)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To install udpate the new toolchain, run:&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
