<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Rust on Thorsten Hans</title>
		<link>https://thorsten-hans.com/tags/rust/</link>
		<description>Recent content in Rust on Thorsten Hans</description>
		<generator>Hugo</generator>
		<language>en-US</language>
		
		
		
		
			<lastBuildDate>Tue, 13 Oct 2026 08:45:00 +0200</lastBuildDate>
		
			<atom:link href="https://thorsten-hans.com/tags/rust/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Out Now: Building Serverless Applications with WebAssembly &amp; Spin</title>
				<link>https://thorsten-hans.com/building-serverless-apps-with-wasm-and-spin-released/</link>
				<pubDate>Tue, 13 Oct 2026 08:45:00 +0200</pubDate>
				<guid>https://thorsten-hans.com/building-serverless-apps-with-wasm-and-spin-released/</guid>
				<description>&lt;p&gt;Hey friends 👋🏼,&lt;/p&gt;&#xA;&lt;p&gt;The wait is finally over! After countless early mornings, extensive refactorings, and hours spent obsessing over every code sample and diagram, the first version of &lt;strong&gt;Building Serverless Applications with WebAssembly &amp;amp; Spin&lt;/strong&gt; is officially live.&lt;/p&gt;&#xA;&lt;p&gt;You can grab your copy right now on Leanpub:&lt;/p&gt;&#xA;&lt;p&gt;👉 &lt;a href=&#34;https://leanpub.com/building-serverless-apps-with-wasm-and-spin&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&lt;strong&gt;https://leanpub.com/building-serverless-apps-with-wasm-and-spin&lt;/strong&gt;&lt;/a&gt;&#xA;&lt;/p&gt;&#xA;&lt;figure&gt;&lt;a href=&#34;https://leanpub.com/building-serverless-apps-with-wasm-and-spin&#34; target=&#34;_blank&#34;&gt;&lt;img src=&#34;https://thorsten-hans.com/building-serverless-apps-with-wasm-and-spin-released/images/spin-book-cover.png&#34; width=&#34;600&#34;&gt;&lt;/a&gt;&lt;figcaption&gt;&#xA;&#x9;&#x9;&#x9;&lt;h4&gt;Building Serverless Applications with WebAssembly &amp;amp; Spin&lt;/h4&gt;&#xA;&#x9;&#x9;&lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&#xA;&lt;h2 id=&#34;what-the-book-is-about&#34;&gt;What the Book Is About&lt;/h2&gt;&#xA;&lt;p&gt;Server-side WebAssembly represents the next major evolution in cloud architecture. By combining sub-millisecond cold starts, near-native performance, and robust sandboxed isolation, Wasm components eliminate the overhead of traditional containers and function-as-a-service platforms.&lt;/p&gt;</description>
			</item>
			<item>
				<title>A comprehensive guide on authoring plugins for Fermyon Spin</title>
				<link>https://thorsten-hans.com/comprehensive-guide-on-authoring-plugins-for-fermyon-spin/</link>
				<pubDate>Fri, 25 Aug 2023 10:05:15 +0200</pubDate>
				<guid>https://thorsten-hans.com/comprehensive-guide-on-authoring-plugins-for-fermyon-spin/</guid>
				<description>&lt;p&gt;Did you know that you can extend the &lt;code&gt;spin&lt;/code&gt; CLI with custom plugins that integrate seamlessly and feel like functionality provided by Fermyon itself?&lt;/p&gt;&#xA;&lt;p&gt;No? &lt;strong&gt;No problem!&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;In this article, we will explore how I build the &lt;code&gt;check-for-update&lt;/code&gt; plugin - a simple Spin plugin that allows you to check if your local installation of the &lt;code&gt;spin&lt;/code&gt; CLI is outdated. On top of building the actual Spin Plugin, we&amp;rsquo;ll also go through the process of testing and distributing the &lt;code&gt;check-for-update&lt;/code&gt; plugin. Finally we&amp;rsquo;ll wrap up this article by adding the custom Spin Plugin to the &lt;strong&gt;Spin Up Hub&lt;/strong&gt;, to ensure users can discover it.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Weekly Rust Trivia: How to use pattern matching</title>
				<link>https://thorsten-hans.com/weekly-rust-trivia-pattern-matching/</link>
				<pubDate>Thu, 03 Aug 2023 13:00:00 +0200</pubDate>
				<guid>https://thorsten-hans.com/weekly-rust-trivia-pattern-matching/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://thorsten-hans.com/tags/weekly-rust-trivia&#34;&gt;&lt;em&gt;Weekly Rust Trivia&lt;/em&gt;&lt;/a&gt;&#xA; is a problem-oriented series of articles that assist developers while learning Rust. Every article solves simple, everyday development tasks using the Rust standard library or leveraging popular and proven crates.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How to use pattern matching in Rust?&lt;/p&gt;&#xA;&lt;p&gt;In Rust, &lt;em&gt;pattern matching&lt;/em&gt; is a powerful language feature that allows you to destructure data and match it against specific patterns. It helps you handle different cases and extract values from complex data structures with concise and readable code. The &lt;code&gt;match&lt;/code&gt; keyword is used to perform pattern matching. Inside a &lt;code&gt;match&lt;/code&gt; block, you define patterns and corresponding code blocks for each pattern. When the input data matches a specific pattern, the corresponding code block will be executed.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Weekly Rust Trivia: How to share state between threads</title>
				<link>https://thorsten-hans.com/weekly-rust-trivia-share-state-between-threads/</link>
				<pubDate>Thu, 27 Jul 2023 13:00:00 +0200</pubDate>
				<guid>https://thorsten-hans.com/weekly-rust-trivia-share-state-between-threads/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://thorsten-hans.com/tags/weekly-rust-trivia&#34;&gt;&lt;em&gt;Weekly Rust Trivia&lt;/em&gt;&lt;/a&gt;&#xA; is a problem-oriented series of articles that assist developers while learning Rust. Every article solves simple, everyday development tasks using the Rust standard library or leveraging popular and proven crates.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How to share state between threads in Rust?&lt;/p&gt;&#xA;&lt;p&gt;In Rust, we have the ability to share data between threads by using concurrent data structures and synchronization tools provided by the Rust standard library. The most popular concurrent data structures in Rust include &lt;code&gt;Arc&lt;/code&gt; (atomic reference counting) and &lt;code&gt;Mutex&lt;/code&gt; (mutual exclusion). These allow multiple threads to access shared data in a safe and synchronized manner.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Weekly Rust Trivia: How to write a function-like macro</title>
				<link>https://thorsten-hans.com/weekly-rust-trivia-function-like-macros/</link>
				<pubDate>Thu, 20 Jul 2023 13:00:00 +0200</pubDate>
				<guid>https://thorsten-hans.com/weekly-rust-trivia-function-like-macros/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://thorsten-hans.com/tags/weekly-rust-trivia&#34;&gt;&lt;em&gt;Weekly Rust Trivia&lt;/em&gt;&lt;/a&gt;&#xA; is a problem-oriented series of articles that assist developers while learning Rust. Every article solves simple, everyday development tasks using the Rust standard library or leveraging popular and proven crates.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How to implement a function-like macro in Rust?&lt;/p&gt;&#xA;&lt;p&gt;Function-like macros in Rust are powerful tools that allow you to define macros that resemble function calls. They can take in arguments and generate code based on those arguments. Function-like macros are defined using the &lt;code&gt;macro_rules!&lt;/code&gt; keyword and a set of rules that define patterns and transformations. For demonstration purposes, we&amp;rsquo;ll define the &lt;code&gt;factorial&lt;/code&gt; macro, which will generate code to calculate the factorial of a given number:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Weekly Rust Trivia: How to write an HTTP API with Actix</title>
				<link>https://thorsten-hans.com/weekly-rust-trivia-http-api-with-actix/</link>
				<pubDate>Thu, 13 Jul 2023 13:00:00 +0200</pubDate>
				<guid>https://thorsten-hans.com/weekly-rust-trivia-http-api-with-actix/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://thorsten-hans.com/tags/weekly-rust-trivia&#34;&gt;&lt;em&gt;Weekly Rust Trivia&lt;/em&gt;&lt;/a&gt;&#xA; is a problem-oriented series of articles that assist developers while learning Rust. Every article solves simple, everyday development tasks using the Rust standard library or leveraging popular and proven crates.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How to implement the builder pattern in Rust?&lt;/p&gt;&#xA;&lt;p&gt;To create an HTTP API with &lt;em&gt;Actix&lt;/em&gt;, we must add the &lt;code&gt;actix-web&lt;/code&gt; crate to our project. We can add it using &lt;code&gt;cargo add&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&#xA;  &lt;div class=&#34;code-toolbar&#34;&gt;&#xA;    &lt;span class=&#34;code-lang&#34;&gt;BASH&lt;/span&gt;&#xA;    &lt;button type=&#34;button&#34; class=&#34;code-copy-btn&#34; aria-label=&#34;Copy code to clipboard&#34;&gt;&#xA;      &lt;svg class=&#34;copy-icon&#34; viewBox=&#34;0 0 24 24&#34; width=&#34;14&#34; height=&#34;14&#34; fill=&#34;none&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34; aria-hidden=&#34;true&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;span class=&#34;copy-text&#34;&gt;Copy&lt;/span&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&#xA;  &lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Add actix-web as dependency&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cargo add actix-web&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Having the crate added to our project, we can move on and use &lt;em&gt;Actix&lt;/em&gt; to implement our HTTP API. First, we will implement two handlers, responsible for constructing HTTP responses. &lt;code&gt;actix-web&lt;/code&gt; provides macros like &lt;code&gt;post&lt;/code&gt;, &lt;code&gt;get&lt;/code&gt;, &amp;hellip; with which we can decrate our handler functions to describe how &lt;em&gt;Actix&lt;/em&gt; should expose them via HTTP:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Weekly Rust Trivia: How to Implement the Builder Pattern</title>
				<link>https://thorsten-hans.com/weekly-rust-trivia-implement-the-builder-pattern/</link>
				<pubDate>Thu, 06 Jul 2023 13:00:00 +0200</pubDate>
				<guid>https://thorsten-hans.com/weekly-rust-trivia-implement-the-builder-pattern/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://thorsten-hans.com/tags/weekly-rust-trivia&#34;&gt;&lt;em&gt;Weekly Rust Trivia&lt;/em&gt;&lt;/a&gt;&#xA; is a problem-oriented series of articles that assist developers while learning Rust. Every article solves simple, everyday development tasks using the Rust standard library or leveraging popular and proven crates.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How to implement the builder pattern in Rust?&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;derive_builder&lt;/code&gt; crate provides a macro which allows us to satisfy the builder pattern for your individual structs without writing custom code.&lt;/p&gt;&#xA;&lt;p&gt;First let&amp;rsquo;s add the dependency using &lt;code&gt;cargo add&lt;/code&gt;:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Weekly Rust Trivia: How to Implement a Generic Stack</title>
				<link>https://thorsten-hans.com/weekly-rust-trivia-implement-a-generic-stack/</link>
				<pubDate>Thu, 29 Jun 2023 13:00:00 +0200</pubDate>
				<guid>https://thorsten-hans.com/weekly-rust-trivia-implement-a-generic-stack/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://thorsten-hans.com/tags/weekly-rust-trivia&#34;&gt;&lt;em&gt;Weekly Rust Trivia&lt;/em&gt;&lt;/a&gt;&#xA; is a problem-oriented series of articles that assist developers while learning Rust. Every article solves simple, everyday development tasks using the Rust standard library or leveraging popular and proven crates.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How to implement a generic stack in Rust?&lt;/p&gt;&#xA;&lt;p&gt;To implement a generic stack, we can simply create a custom struct wrapping a vector (&lt;code&gt;Vec&amp;lt;T&amp;gt;&lt;/code&gt;):&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&#xA;  &lt;div class=&#34;code-toolbar&#34;&gt;&#xA;    &lt;span class=&#34;code-lang&#34;&gt;RUST&lt;/span&gt;&#xA;    &lt;button type=&#34;button&#34; class=&#34;code-copy-btn&#34; aria-label=&#34;Copy code to clipboard&#34;&gt;&#xA;      &lt;svg class=&#34;copy-icon&#34; viewBox=&#34;0 0 24 24&#34; width=&#34;14&#34; height=&#34;14&#34; fill=&#34;none&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34; aria-hidden=&#34;true&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;span class=&#34;copy-text&#34;&gt;Copy&lt;/span&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&#xA;  &lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-rust&#34; data-lang=&#34;rust&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;struct&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Stack&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;items&lt;/span&gt;: &lt;span class=&#34;nb&#34;&gt;Vec&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;impl&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Stack&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;fn&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;-&amp;gt; &lt;span class=&#34;nc&#34;&gt;Stack&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Stack&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;items&lt;/span&gt;: &lt;span class=&#34;nb&#34;&gt;Vec&lt;/span&gt;::&lt;span class=&#34;n&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;fn&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;push&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;mut&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;bp&#34;&gt;self&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;item&lt;/span&gt;: &lt;span class=&#34;nc&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;bp&#34;&gt;self&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;items&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;push&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;item&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;fn&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;pop&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;mut&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;bp&#34;&gt;self&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;-&amp;gt; &lt;span class=&#34;nb&#34;&gt;Option&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;bp&#34;&gt;self&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;items&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;pop&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;fn&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;is_empty&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&#34;bp&#34;&gt;self&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;-&amp;gt; &lt;span class=&#34;kt&#34;&gt;bool&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;bp&#34;&gt;self&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;items&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;is_empty&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;fn&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;size&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&#34;bp&#34;&gt;self&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;-&amp;gt; &lt;span class=&#34;kt&#34;&gt;usize&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;bp&#34;&gt;self&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;items&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;len&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;The implementation (&lt;code&gt;impl&amp;lt;T&amp;gt; Stack&amp;lt;T&amp;gt;&lt;/code&gt;) uses a generic type &lt;code&gt;T&lt;/code&gt; to allow it to store any type of data. The &lt;code&gt;Stack&lt;/code&gt; struct has four methods: &lt;code&gt;new&lt;/code&gt;, &lt;code&gt;push&lt;/code&gt;, &lt;code&gt;pop&lt;/code&gt;, &lt;code&gt;is_empty&lt;/code&gt;, and &lt;code&gt;size&lt;/code&gt;:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Weekly Rust Trivia: How to Retrieve Image Dimensions</title>
				<link>https://thorsten-hans.com/weekly-rust-trivia-retrieve-image-dimensions/</link>
				<pubDate>Thu, 22 Jun 2023 13:00:00 +0200</pubDate>
				<guid>https://thorsten-hans.com/weekly-rust-trivia-retrieve-image-dimensions/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://thorsten-hans.com/tags/weekly-rust-trivia&#34;&gt;&lt;em&gt;Weekly Rust Trivia&lt;/em&gt;&lt;/a&gt;&#xA; is a problem-oriented series of articles that assist developers while learning Rust. Every article solves simple, everyday development tasks using the Rust standard library or leveraging popular and proven crates.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How to retrieve the dimensions of an image in Rust?&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;image&lt;/code&gt; crate provides necessary functionality to work with images in Rust. We can combine functionality provided by the crate with the &lt;code&gt;path&lt;/code&gt; module from Rusts standard library to solve this trivia. We also use the &lt;code&gt;anyhow&lt;/code&gt; crate, to streamline error handling.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Weekly Rust Trivia: How to create a TCP Server</title>
				<link>https://thorsten-hans.com/weekly-rust-trivia-create-a-tcp-server/</link>
				<pubDate>Thu, 15 Jun 2023 13:00:00 +0200</pubDate>
				<guid>https://thorsten-hans.com/weekly-rust-trivia-create-a-tcp-server/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://thorsten-hans.com/tags/weekly-rust-trivia&#34;&gt;&lt;em&gt;Weekly Rust Trivia&lt;/em&gt;&lt;/a&gt;&#xA; is a problem-oriented series of articles that assist developers while learning Rust. Every article solves simple, everyday development tasks using the Rust standard library or leveraging popular and proven crates.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How to create a TCP server in Rust?&lt;/p&gt;&#xA;&lt;p&gt;We can use the &lt;code&gt;io&lt;/code&gt; and &lt;code&gt;net&lt;/code&gt; and &lt;code&gt;thread&lt;/code&gt; modules from Rust standard library this trivia.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&#xA;  &lt;div class=&#34;code-toolbar&#34;&gt;&#xA;    &lt;span class=&#34;code-lang&#34;&gt;RUST&lt;/span&gt;&#xA;    &lt;button type=&#34;button&#34; class=&#34;code-copy-btn&#34; aria-label=&#34;Copy code to clipboard&#34;&gt;&#xA;      &lt;svg class=&#34;copy-icon&#34; viewBox=&#34;0 0 24 24&#34; width=&#34;14&#34; height=&#34;14&#34; fill=&#34;none&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34; aria-hidden=&#34;true&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;span class=&#34;copy-text&#34;&gt;Copy&lt;/span&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&#xA;  &lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-rust&#34; data-lang=&#34;rust&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;use&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;std&lt;/span&gt;::&lt;span class=&#34;n&#34;&gt;io&lt;/span&gt;::&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Read&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Write&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;use&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;std&lt;/span&gt;::&lt;span class=&#34;n&#34;&gt;net&lt;/span&gt;::&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TcpListener&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TcpStream&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;use&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;std&lt;/span&gt;::&lt;span class=&#34;n&#34;&gt;thread&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;fn&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;handle&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;mut&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;stream&lt;/span&gt;: &lt;span class=&#34;nc&#34;&gt;TcpStream&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// 64 KB buffer for demonstration purposes&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;let&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;mut&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;65536&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;];&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;loop&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;let&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;bytes_read&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;match&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;stream&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;read&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;mut&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;Ok&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;return&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// End of stream&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;Ok&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;Err&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;_&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;return&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Error reading from stream&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Echo the data back to the client&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;let&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;Err&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;_&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;stream&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;write&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;buffer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;..&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;bytes_read&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;])&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;return&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Error writing to stream&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;The &lt;code&gt;handle&lt;/code&gt; function takes in a &lt;code&gt;TcpStream&lt;/code&gt; object representing a client connection.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Weekly Rust Trivia: How to Implement Binary Search</title>
				<link>https://thorsten-hans.com/weekly-rust-trivia-implement-binary-search/</link>
				<pubDate>Thu, 08 Jun 2023 13:00:00 +0200</pubDate>
				<guid>https://thorsten-hans.com/weekly-rust-trivia-implement-binary-search/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://thorsten-hans.com/tags/weekly-rust-trivia&#34;&gt;&lt;em&gt;Weekly Rust Trivia&lt;/em&gt;&lt;/a&gt;&#xA; is a problem-oriented series of articles that assist developers while learning Rust. Every article solves simple, everyday development tasks using the Rust standard library or leveraging popular and proven crates.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How to implement binary search in Rust?&lt;/p&gt;&#xA;&lt;p&gt;All we need to implement binary search in Rust is bringing the &lt;code&gt;cmp&lt;/code&gt; module into scope. The &lt;code&gt;cmp::Ordering&lt;/code&gt; enum and the &lt;code&gt;cmd::Ord&lt;/code&gt; trait provide everything required to implement a generic binary search supporting all types implementing the &lt;code&gt;Ord&lt;/code&gt; trait.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Weekly Rust Trivia: How to Read a CSV File</title>
				<link>https://thorsten-hans.com/weekly-rust-trivia-read-a-csv-file/</link>
				<pubDate>Thu, 01 Jun 2023 13:00:00 +0200</pubDate>
				<guid>https://thorsten-hans.com/weekly-rust-trivia-read-a-csv-file/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://thorsten-hans.com/tags/weekly-rust-trivia&#34;&gt;&lt;em&gt;Weekly Rust Trivia&lt;/em&gt;&lt;/a&gt;&#xA; is a problem-oriented series of articles that assist developers while learning Rust. Every article solves simple, everyday development tasks using the Rust standard library or leveraging popular and proven crates.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How to read a &lt;code&gt;.csv&lt;/code&gt; file in Rust?&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;csv&lt;/code&gt; crate provides necessary functionality to work with &lt;code&gt;.csv&lt;/code&gt; files in Rust. We can combine functionality provided by the crate with the &lt;code&gt;fs&lt;/code&gt; module from Rusts standard library to solve this trivia. We also use the &lt;code&gt;anyhow&lt;/code&gt; crate, to streamline error handling.&lt;/p&gt;</description>
			</item>
			<item>
				<title>How to use Azure Cosmos DB as a key-value store for Fermyon Spin</title>
				<link>https://thorsten-hans.com/azure-cosmos-db-as-key-value-store-for-fermyon-spin/</link>
				<pubDate>Fri, 26 May 2023 10:04:05 +0200</pubDate>
				<guid>https://thorsten-hans.com/azure-cosmos-db-as-key-value-store-for-fermyon-spin/</guid>
				<description>&lt;p&gt;With the 1.2.1 release of Fermyon Spin, we can now use Azure Cosmos DB as a key-value store for persisting data when building serverless applications. In this article, I guide you through setting up the necessary infrastructure and creating a fairly simple app to store and retrieve arbitrary values using Azure Cosmos DB as the key-value store.&lt;/p&gt;&#xA;&lt;p&gt;All code shown in this article is also available on GitHub at &lt;a href=&#34;https://github.com/ThorstenHans/spin-kv-azure-cosmosdb&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;https://github.com/ThorstenHans/spin-kv-azure-cosmosdb&lt;/a&gt;&#xA;.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Weekly Rust Trivia: How to Compute a SHA256 Hash of a File</title>
				<link>https://thorsten-hans.com/weekly-rust-trivia-compute-a-sha256-hash-of-a-file/</link>
				<pubDate>Thu, 25 May 2023 13:00:00 +0200</pubDate>
				<guid>https://thorsten-hans.com/weekly-rust-trivia-compute-a-sha256-hash-of-a-file/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://thorsten-hans.com/tags/weekly-rust-trivia&#34;&gt;&lt;em&gt;Weekly Rust Trivia&lt;/em&gt;&lt;/a&gt;&#xA; is a problem-oriented series of articles that assist developers while learning Rust. Every article solves simple, everyday development tasks using the Rust standard library or leveraging popular and proven crates.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How to compute a &lt;code&gt;SHA256&lt;/code&gt; hash of a file in Rust?&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;sha2&lt;/code&gt; crate is an implementation of cryptographic hash algorithms that we can use to compute hashes. We can combine functionality provided by the crate with the &lt;code&gt;fs&lt;/code&gt; and &lt;code&gt;io&lt;/code&gt; modules from Rusts standard library to solve this trivia. We also use the &lt;code&gt;anyhow&lt;/code&gt; crate, to streamline error handling.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Weekly Rust Trivia: How to Download an Image to a File</title>
				<link>https://thorsten-hans.com/weekly-rust-trivia-download-an-image-to-a-file/</link>
				<pubDate>Thu, 18 May 2023 13:00:00 +0200</pubDate>
				<guid>https://thorsten-hans.com/weekly-rust-trivia-download-an-image-to-a-file/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://thorsten-hans.com/tags/weekly-rust-trivia&#34;&gt;&lt;em&gt;Weekly Rust Trivia&lt;/em&gt;&lt;/a&gt;&#xA; is a problem-oriented series of articles that assist developers while learning Rust. Every article solves simple, everyday development tasks using the Rust standard library or leveraging popular and proven crates.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How to download an image from the web and store it in a file using Rust?&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;reqwest&lt;/code&gt; crate allows us to create HTTP requests with ease, we can combine functionality provided by the crate with the &lt;code&gt;fs&lt;/code&gt; and &lt;code&gt;io&lt;/code&gt; modules from Rusts standard library to solve this trivia. We also use the &lt;code&gt;anyhow&lt;/code&gt; crate, to streamline error handling.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Weekly Rust Trivia: How to Get all Files in a Directory</title>
				<link>https://thorsten-hans.com/weekly-rust-trivia-get-all-files-in-a-directory/</link>
				<pubDate>Thu, 11 May 2023 13:00:00 +0200</pubDate>
				<guid>https://thorsten-hans.com/weekly-rust-trivia-get-all-files-in-a-directory/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://thorsten-hans.com/tags/weekly-rust-trivia&#34;&gt;&lt;em&gt;Weekly Rust Trivia&lt;/em&gt;&lt;/a&gt;&#xA; is a problem-oriented series of articles that assist developers while learning Rust. Every article solves simple, everyday development tasks using the Rust standard library or leveraging popular and proven crates.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; How to get a vector (&lt;code&gt;Vec&amp;lt;String&amp;gt;&lt;/code&gt;) containing all filenames of a particular directory in Rust?&lt;/p&gt;&#xA;&lt;p&gt;We can use the &lt;code&gt;fs&lt;/code&gt; and &lt;code&gt;io&lt;/code&gt; modules from Rust standard library this trivia.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&#xA;  &lt;div class=&#34;code-toolbar&#34;&gt;&#xA;    &lt;span class=&#34;code-lang&#34;&gt;RUST&lt;/span&gt;&#xA;    &lt;button type=&#34;button&#34; class=&#34;code-copy-btn&#34; aria-label=&#34;Copy code to clipboard&#34;&gt;&#xA;      &lt;svg class=&#34;copy-icon&#34; viewBox=&#34;0 0 24 24&#34; width=&#34;14&#34; height=&#34;14&#34; fill=&#34;none&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34; aria-hidden=&#34;true&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;span class=&#34;copy-text&#34;&gt;Copy&lt;/span&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&#xA;  &lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-rust&#34; data-lang=&#34;rust&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;use&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;std&lt;/span&gt;::&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;fs&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;io&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;fn&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;get_files_in_directory&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;path&lt;/span&gt;: &lt;span class=&#34;kp&#34;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;str&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;-&amp;gt; &lt;span class=&#34;nc&#34;&gt;io&lt;/span&gt;::&lt;span class=&#34;nb&#34;&gt;Result&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;Vec&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Get a list of all entries in the folder&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;let&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;entries&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;fs&lt;/span&gt;::&lt;span class=&#34;n&#34;&gt;read_dir&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;path&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;?&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;// Extract the filenames from the directory entries and store them in a vector&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;let&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;file_names&lt;/span&gt;: &lt;span class=&#34;nb&#34;&gt;Vec&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;entries&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;filter_map&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;|&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;entry&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;|&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;let&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;path&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;entry&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ok&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;?&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;path&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;path&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;is_file&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;                &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;path&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;file_name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;?&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;to_str&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;().&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;map&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;|&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;s&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;|&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;s&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;to_owned&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;())&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;else&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;                &lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;None&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;            &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;})&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;collect&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;Ok&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;file_names&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;In this example, we pass the path of the desired directory as argument to the &lt;code&gt;get_files_in_directory&lt;/code&gt; function. We then use the &lt;code&gt;fs::read_dir()&lt;/code&gt; method to get a list of all entries in the directory, which returns a &lt;code&gt;std::fs::ReadDir&lt;/code&gt; iterator. We use the &lt;code&gt;filter_map()&lt;/code&gt; method to filter out any &lt;code&gt;None&lt;/code&gt; values from the iterator, then check whether each entry is a file or a directory using the &lt;code&gt;is_file()&lt;/code&gt; method of the &lt;code&gt;std::path::Path&lt;/code&gt; struct.&lt;/p&gt;</description>
			</item>
			<item>
				<title>A First Glance at the Spin Router for Rust</title>
				<link>https://thorsten-hans.com/first-glance-at-spin-router-for-rust/</link>
				<pubDate>Tue, 18 Apr 2023 13:02:41 +0200</pubDate>
				<guid>https://thorsten-hans.com/first-glance-at-spin-router-for-rust/</guid>
				<description>&lt;p&gt;With the release of Fermyon Spin 1.1 (April 15th, 2023), the Spin SDKs for Rust and Go now provide a built-in router for HTTP applications. In this post, we will take a quick look at the built-in router supplied by the Spin SDK for Rust and build a small sample application to illustrate how one could solve day-to-day requirements when building serverless applications with WebAssembly (Wasm).&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#whats-the-purpose-of-a-router-in-http-apps&#34;&gt;What&amp;rsquo;s the purpose of a router in HTTP apps?&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#our-demo-application&#34;&gt;Our demo application&lt;/a&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#how-requests-flow-through-a-spin-app&#34;&gt;How requests flow through a Spin app&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#lets-implement-the-book-api-sample&#34;&gt;Let&amp;rsquo;s implement the book API sample&lt;/a&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#prerequirements&#34;&gt;Prerequirements&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#find-the-sample-repository-on-github&#34;&gt;Find the sample repository on GitHub&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#create-the-spin-application&#34;&gt;Create the Spin application&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#key-value-store-configuration&#34;&gt;key-value store configuration&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#api-models-book-entity-persistence--handlers&#34;&gt;API models, book entity, persistence &amp;amp; handlers&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#configure-the-built-in-router-of-spin&#34;&gt;Configure the built-in Router of Spin&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#conclusion&#34;&gt;Conclusion&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr&gt;&#xA;&lt;h2 id=&#34;whats-the-purpose-of-a-router-in-http-apps&#34;&gt;What&amp;rsquo;s the purpose of a router in HTTP apps?&lt;/h2&gt;&#xA;&lt;p&gt;In HTTP applications, a router serves as a central component to direct incoming HTTP requests to the appropriate handler functions that can process and respond to those requests. The router does so by looking at different parts of an incoming HTTP request, such as:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Let&#39;s build a HTTP router for Spin with Rust</title>
				<link>https://thorsten-hans.com/http-router-for-spin-with-rust/</link>
				<pubDate>Fri, 14 Apr 2023 11:13:43 +0200</pubDate>
				<guid>https://thorsten-hans.com/http-router-for-spin-with-rust/</guid>
				<description>&lt;p&gt;Although we can build more complex HTTP applications in Fermyon Spin by composing multiple components, having a single component is easier, reduces development time, and is more flexible in the first place. In this article, I will explain how to implement simple routing capabilities using enumerations in Rust.&lt;/p&gt;&#xA;&lt;aside class=&#34;note&#34;&gt;&#xA;    &lt;h3&gt;Note: 💡 Spin 1.1 brings Built-in Router for Rust &amp;amp; Go&lt;/h3&gt;&#xA;    &lt;div class=&#34;content&#34;&gt;&lt;p&gt;Shortly after publishing this article, Fermyon released version 1.1 of Spin 🎉. With that release, the Spin SDK for Rust comes with a built-in router for HTTP applications.&lt;/p&gt;&#xA;&lt;p&gt;Consult the &lt;a href=&#34;https://www.fermyon.com/blog/introducing-spin-v11&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;announcement of Spin 1.1&lt;/a&gt;&#xA; to get more details on the built-in router.&lt;/p&gt;&#xA;&lt;/div&gt;&#xA;&lt;/aside&gt;</description>
			</item>
			<item>
				<title>Let Spin lift your key-value store</title>
				<link>https://thorsten-hans.com/let-spin-lift-your-key-value-store/</link>
				<pubDate>Sat, 08 Apr 2023 15:41:09 +0200</pubDate>
				<guid>https://thorsten-hans.com/let-spin-lift-your-key-value-store/</guid>
				<description>&lt;p&gt;For quite sometime now (since version 0.9.0), Spin has had built-in key-value support. In this article, we will quickly investigate how we can use that built-in key-value support when building serverless applications with Fermyon Spin.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#what-are-key-value-stores&#34;&gt;What are key-value stores&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#why-should-you-use-key-value-stores-in-serverless-apps&#34;&gt;Why should you use key-value stores in serverless apps&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#key-value-stores-in-spin&#34;&gt;Key-value stores in Spin&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#lets-build-a-simple-url-shortener-using-the-spin-key-value-store&#34;&gt;Let&amp;rsquo;s build a simple URL shortener using the Spin key-value store&lt;/a&gt;&#xA;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#add-necessary-dependencies-to-cargotoml&#34;&gt;Add necessary dependencies to &lt;code&gt;Cargo.toml&lt;/code&gt;&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#configure-spin-the-key-value-store-in-spintoml&#34;&gt;Configure Spin the key-value store in &lt;code&gt;Spin.toml&lt;/code&gt;&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#implement-the-handler-for-creating-new-short-links&#34;&gt;Implement the handler for creating new short-links&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#implement-the-handler-for-openening-a-short-link&#34;&gt;Implement the handler for openening a short-link&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#implement-the-handler-for-receiving-all-short-links&#34;&gt;Implement the handler for receiving all short-links&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#wiring-up-the-handlers&#34;&gt;Wiring up the handlers&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#testing-the-url-shortener&#34;&gt;Testing the URL shortener&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#conclusion&#34;&gt;Conclusion&lt;/a&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr&gt;&#xA;&lt;h2 id=&#34;what-are-key-value-stores&#34;&gt;What are key-value stores&lt;/h2&gt;&#xA;&lt;p&gt;A key-value store is a type of database that stores data as a collection of key-value pairs. Each key in the database maps to a corresponding value, which can be retrieved by querying the key. Key-value stores are often used for storing and retrieving data quickly, as they can perform reads and writes with very low latency. They are commonly used in web applications, caching layers, and distributed systems and can be implemented using various technologies, such as Redis, Cassandra, etcd, SQLite, and others.&lt;/p&gt;</description>
			</item>
			<item>
				<title>CRUD in WebAssembly with Fermyon Spin and MySQL</title>
				<link>https://thorsten-hans.com/crud-in-webassembly-with-fermyon-spin-and-mysql/</link>
				<pubDate>Tue, 20 Dec 2022 16:32:11 +0100</pubDate>
				<guid>https://thorsten-hans.com/crud-in-webassembly-with-fermyon-spin-and-mysql/</guid>
				<description>&lt;p&gt;With the latest release of Fermyon Spin (v 0.7.0), we can persist data in MySQL (persistence in PostgreSQL has been available for quite some time now). Being able to persist and retrieve some sort of data is a must-have for any kind of application.&lt;/p&gt;&#xA;&lt;p&gt;In this article, we’ll take a look at a full-fledged CRUD implementation. We’ll build an HTTP-API that allows its users to &lt;strong&gt;C&lt;/strong&gt;reate, &lt;strong&gt;R&lt;/strong&gt;ead, &lt;strong&gt;U&lt;/strong&gt;pdate, and &lt;strong&gt;D&lt;/strong&gt;elete products using corresponding HTTP methods (&lt;code&gt;POST&lt;/code&gt;, &lt;code&gt;GET&lt;/code&gt;, &lt;code&gt;PUT&lt;/code&gt;, and &lt;code&gt;DELETE&lt;/code&gt;). All code shown in this article is available &lt;a href=&#34;https://github.com/ThorstenHans/spin-crud-mysql&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;on GitHub at ThorstenHans/spin-crud-mysql&lt;/a&gt;&#xA;.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Master configuration data in Fermyon Spin</title>
				<link>https://thorsten-hans.com/master-configuration-data-in-fermyon-spin/</link>
				<pubDate>Thu, 15 Dec 2022 14:01:01 +0100</pubDate>
				<guid>https://thorsten-hans.com/master-configuration-data-in-fermyon-spin/</guid>
				<description>&lt;p&gt;Every application has to deal with configuration data, and applications built using Fermyon Spin are no exception here. Instead of baking configuration data into your source code, you should attach it from the outside to alter behavior of your applications without having to re-compile your source code.&lt;/p&gt;&#xA;&lt;p&gt;This short article demonstrates how to deal with configuration data when building applications using WebAssembly and Fermyon Spin. You can find the source code of the sample application (spin-to-slack) &lt;a href=&#34;https://github.com/ThorstenHans/spin-to-slack&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;on GitHub at ThorstenHans/spin-to-slack&lt;/a&gt;&#xA;.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Building Microservices With WebAssembly and Fermyon Spin</title>
				<link>https://thorsten-hans.com/building-microservices-with-webassembly-and-fermyon-spin/</link>
				<pubDate>Sun, 11 Dec 2022 15:18:16 +0100</pubDate>
				<guid>https://thorsten-hans.com/building-microservices-with-webassembly-and-fermyon-spin/</guid>
				<description>&lt;p&gt;Although WebAssembly is an excellent fit for bringing complex solutions that need near-native runtime performance to the client (Browser), I see WebAssembly as a technology with way more potential and a way bigger impact on the server (read: cloud) in contrast. That said, WebAssembly will not replace containers on the server side. It’s an addition or alternative approach to packaging and distributing specific software components typically part of a bigger system. It’s on us - the developers and software architects - to decide if a container or WebAssembly is the better foundation for meeting a particular requirement.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Let&#39;s build a gRPC server and client in Rust with tonic</title>
				<link>https://thorsten-hans.com/grpc-services-in-rust-with-tonic/</link>
				<pubDate>Thu, 07 Jul 2022 17:13:13 +0200</pubDate>
				<guid>https://thorsten-hans.com/grpc-services-in-rust-with-tonic/</guid>
				<description>&lt;p&gt;Last week I was showcasing WebAssembly in the cloud using &lt;a href=&#34;https://krustlet.dev/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;krustlet&lt;/a&gt;&#xA; and &lt;a href=&#34;https://spin.fermyon.dev/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Fermyon Spin&lt;/a&gt;&#xA; at Cloudland 2022 in Brühl (Germany). While preparing for the talk, I recognized how much I&amp;rsquo;d missed Rust 🦀 over the past months.&lt;/p&gt;&#xA;&lt;p&gt;Although I&amp;rsquo;ve been reading articles and watching some videos on Rust in general from time to time, I missed doing some hands-on. So I dedicated some time to do a quick refresher for Rust, updated my local installation &lt;code&gt;rustup update&lt;/code&gt;, and wrote a small gRPC server in Rust using &lt;a href=&#34;https://github.com/hyperium/tonic&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;tonic&lt;/a&gt;&#xA;. However, before we dive into the tutorial, let&amp;rsquo;s quickly look at what tonic is and what we can do with it.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Check if your application is running in a Docker container</title>
				<link>https://thorsten-hans.com/check-if-application-is-running-in-docker-container/</link>
				<pubDate>Thu, 21 Apr 2022 17:22:42 +0000</pubDate>
				<guid>https://thorsten-hans.com/check-if-application-is-running-in-docker-container/</guid>
				<description>&lt;p&gt;Especially when building cloud-native applications, we tend to develop applications that run in any environment. We design components, so we can run them with or without container technologies to ensure we can host the application on different application platforms. However, sometimes we may have to determine if our applications are running inside a Docker container or not. This allows us to take particular actions at runtime without adding additional environment variables or configuration values (state). Every container has a &lt;code&gt;.dockerenv&lt;/code&gt; file in the file system&amp;rsquo;s root. That said, we can quickly check for the existence of that file to determine reliably if our application runs inside a container or not. For demonstration purposes, this post shows how to determine if the application is executed in a container using Go and Rust.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Distribute WebAssembly modules as OCI artifacts</title>
				<link>https://thorsten-hans.com/distribute-webassembly-modules-as-oci-artifacts/</link>
				<pubDate>Tue, 02 Nov 2021 14:19:39 +0000</pubDate>
				<guid>https://thorsten-hans.com/distribute-webassembly-modules-as-oci-artifacts/</guid>
				<description>&lt;p&gt;When using WebAssembly (Wasm) on platforms different than the browser, we have to care about distribution. How can we securely transfer our Wasm modules to desired environments? How can we verify integrity to ensure Wasm modules were not compromised during distribution?&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s take a look at the container world. Container registries (those that implement the Docker Registry 2.0 standard (or to be more precise, the &lt;a href=&#34;https://github.com/opencontainers/distribution-spec&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;OCI distribution spec&lt;/a&gt;&#xA;)) are a trusted distribution channel that addresses all the questions raised before. This does not mean that we have to package our Wasm modules as containers! Container registries can store and distribute more than just containers. Container registries can store any OCI compliant artifact. And that&amp;rsquo;s exactly what we will create from our Wasm modules to leverage container registries as a trusted distribution channel.&lt;/p&gt;</description>
			</item>
			<item>
				<title>How to Build CLIs in Rust with StructOpt</title>
				<link>https://thorsten-hans.com/how-to-build-clis-in-rust-with-structopt/</link>
				<pubDate>Mon, 11 Oct 2021 10:03:31 +0000</pubDate>
				<guid>https://thorsten-hans.com/how-to-build-clis-in-rust-with-structopt/</guid>
				<description>&lt;p&gt;As my journey on learning Rust continues, I looked at several options for building Command-Line Interfaces (CLIs) in Rust. There are several crates available you can use to craft tailored CLIs in Rust. At some point, &lt;a href=&#34;https://github.com/TeXitoi/structopt&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;StructOpt&lt;/a&gt;&#xA; got my attention, and I saw a couple of people tweeting and writing about it. That said, this article helps you understanding &lt;em&gt;StructOpt&lt;/em&gt; and gives you a head-start when it comes to building custom CLIs in Rust.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Calling HTTP APIs in Rust with reqwest</title>
				<link>https://thorsten-hans.com/calling-http-apis-in-rust-with-reqwest/</link>
				<pubDate>Wed, 15 Sep 2021 11:31:00 +0000</pubDate>
				<guid>https://thorsten-hans.com/calling-http-apis-in-rust-with-reqwest/</guid>
				<description>&lt;p&gt;As part of my Rust journey, I&amp;rsquo;m building a simple CLI to get rid of manual tasks I&amp;rsquo;ve to complete on regular basis. Some of those tasks can be automated by leveraging a HTTP client in Rust. A quick research led me to &lt;a href=&#34;https://github.com/seanmonstar/reqwest&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;reqwest (https://github.com/seanmonstar/reqwest)&lt;/a&gt;&#xA;, a simple HTTP client for Rust that fits my needs and let me get the job done quickly.&lt;/p&gt;&#xA;&lt;p&gt;You may ask yourself if &lt;code&gt;reqwest&lt;/code&gt; is the &lt;strong&gt;best HTTP client for Rust?&lt;/strong&gt; To be honest, I don&amp;rsquo;t know (yet). But I got my job done quickly, and I really enjoyed the API surface offered by &lt;code&gt;reqwest&lt;/code&gt;. That said let&amp;rsquo;s dive into &lt;code&gt;reqwest&lt;/code&gt; and see how it actually looks like.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Shadowing and Temporary Mutability in Rust</title>
				<link>https://thorsten-hans.com/shadowing-temporary-mutability-rust/</link>
				<pubDate>Tue, 07 Sep 2021 18:37:36 +0000</pubDate>
				<guid>https://thorsten-hans.com/shadowing-temporary-mutability-rust/</guid>
				<description>&lt;p&gt;Rust already amazes a lot when it comes to the basic language features. Let&amp;rsquo;s, for example, take a look at shadowing and temporary mutability. Both, fairly basic and simple language features, yet powerful and a real booster for robustness and correctness.&lt;/p&gt;&#xA;&lt;h2 id=&#34;shadowing-in-rust&#34;&gt;Shadowing in Rust&lt;/h2&gt;&#xA;&lt;p&gt;Shadowing is such a simple language feature. However, it has a significant effect on the code you write daily. Shadowing allows you to re-declare a variable in the same scope, using the same name. The re-declared variable differs from the original by having a different type. This is especially useful upon casting data from one type into another. In Rust, you can achieve this without adding unnecessary application-state.Take the following code as an example:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Working with Environment Variables in Rust</title>
				<link>https://thorsten-hans.com/working-with-environment-variables-in-rust/</link>
				<pubDate>Mon, 06 Sep 2021 15:51:19 +0000</pubDate>
				<guid>https://thorsten-hans.com/working-with-environment-variables-in-rust/</guid>
				<description>&lt;p&gt;Rust makes working with environment variables fairly easy. The standard library provides fundamental APIs as part of &lt;code&gt;std::env&lt;/code&gt; which we use to access environment variables inside of our application. If you&amp;rsquo;re expecting valid unicode values, you can use &lt;code&gt;env::var&lt;/code&gt; - which returns an &lt;code&gt;Result&amp;lt;String, VarError&amp;gt;&lt;/code&gt; - as shown here:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&#xA;  &lt;div class=&#34;code-toolbar&#34;&gt;&#xA;    &lt;span class=&#34;code-lang&#34;&gt;RUST&lt;/span&gt;&#xA;    &lt;button type=&#34;button&#34; class=&#34;code-copy-btn&#34; aria-label=&#34;Copy code to clipboard&#34;&gt;&#xA;      &lt;svg class=&#34;copy-icon&#34; viewBox=&#34;0 0 24 24&#34; width=&#34;14&#34; height=&#34;14&#34; fill=&#34;none&#34; stroke=&#34;currentColor&#34; stroke-width=&#34;2&#34; stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34; aria-hidden=&#34;true&#34;&gt;&#xA;        &lt;rect x=&#34;9&#34; y=&#34;9&#34; width=&#34;13&#34; height=&#34;13&#34; rx=&#34;2&#34; ry=&#34;2&#34;&gt;&lt;/rect&gt;&#xA;        &lt;path d=&#34;M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1&#34;&gt;&lt;/path&gt;&#xA;      &lt;/svg&gt;&#xA;      &lt;span class=&#34;copy-text&#34;&gt;Copy&lt;/span&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&#xA;  &lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-rust&#34; data-lang=&#34;rust&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;use&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;std&lt;/span&gt;::&lt;span class=&#34;n&#34;&gt;env&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;fn&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;verbose&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;let&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;USER&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;match&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;env&lt;/span&gt;::&lt;span class=&#34;n&#34;&gt;var&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;Ok&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;v&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;fm&#34;&gt;println!&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;{}&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;: &lt;/span&gt;&lt;span class=&#34;si&#34;&gt;{}&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;v&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;),&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;        &lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;Err&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;e&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;fm&#34;&gt;panic!&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;$&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;{}&lt;/span&gt;&lt;span class=&#34;s&#34;&gt; is not set (&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;{}&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;)&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;name&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;e&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;fn&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;short&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;    &lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;let&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;v&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;env&lt;/span&gt;::&lt;span class=&#34;n&#34;&gt;var&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;USER&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;).&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;expect&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;$USER is not set&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;In contrast, &lt;code&gt;env::var_os&lt;/code&gt; does not check if the value of the desired environment variable is valid unicode. &lt;code&gt;var_os&lt;/code&gt; has also a slightly different function signature, it returns an &lt;code&gt;Option&amp;lt;OsString&amp;gt;&lt;/code&gt;:&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
