Skip to content

Commit

Permalink
Update pin-box-rust article
Browse files Browse the repository at this point in the history
  • Loading branch information
nazmulidris committed Jul 17, 2024
1 parent eb84945 commit 74b4527
Show file tree
Hide file tree
Showing 22 changed files with 251 additions and 201 deletions.
18 changes: 10 additions & 8 deletions _posts/2023-02-20-guide-to-nom-parsing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ author: Nazmul Idris
date: 2023-02-20 15:00:00+00:00
update: 2024-06-19 15:00:00+00:00
excerpt: |
This tutorial is a comprehensive guide to parsing with nom. It covers the basics of parsing and
how to use nom to parse a string into a data structure. It also covers more complex topics like
human readable error reporting, and building up complex parsers. We will cover a variety of different
examples ranging from parsing simple CSS like syntax to a full blown Markdown parser.
This tutorial and video are a comprehensive guide to parsing with nom. We cover the basics
of parsing and how to use nom to parse a string into a data structure. And more complex
topics like human readable error reporting, and building up complex parsers. We will
create a variety of different examples ranging from parsing simple CSS like syntax to a
full blown Markdown parser.
layout: post
categories:
- Rust
Expand Down Expand Up @@ -43,10 +44,11 @@ categories:
## Introduction
<a id="markdown-introduction" name="introduction"></a>

This tutorial is a comprehensive guide to parsing with nom. It covers the basics of parsing and
how to use nom to parse a string into a data structure. It also covers more complex topics like
human readable error reporting, and building up complex parsers. We will cover a variety of different
examples ranging from parsing simple CSS like syntax to a full blown Markdown parser.
This tutorial and video are a comprehensive guide to parsing with nom. We cover the basics
of parsing and how to use nom to parse a string into a data structure. And more complex
topics like human readable error reporting, and building up complex parsers. We will
create a variety of different examples ranging from parsing simple CSS like syntax to a
full blown Markdown parser.

> For more information on general Rust type system design (functional approach rather than
> object oriented), please take a look at this [paper](https://arxiv.org/pdf/2307.07069.pdf)
Expand Down
7 changes: 5 additions & 2 deletions _posts/2024-05-28-typestate-pattern-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ excerpt: |
The Typestate Pattern in Rust is a way to manage objects that go through different states
in their lifecycle. It leverages Rust's powerful type system to enforce these states and
transitions between them, making your code safer and more predictable. Learn all about it
in this article and its video.
in this article, its video, and repo.
layout: post
categories:
- Rust
Expand All @@ -26,6 +26,7 @@ categories:
- [Example 1: Simple version of this is using enums to encapsulate states as variants](#example-1-simple-version-of-this-is-using-enums-to-encapsulate-states-as-variants)
- [Example 2: Slightly more complex versions are where one type + data = another type](#example-2-slightly-more-complex-versions-are-where-one-type--data--another-type)
- [Example 3: Best of both worlds, using generics and struct / enum with a marker trait](#example-3-best-of-both-worlds-using-generics-and-struct--enum-with-a-marker-trait)
- [Example 3.1: Using enum and PhantomData instead of struct](#example-31-using-enum-and-phantomdata-instead-of-struct)
- [Parting thoughts](#parting-thoughts)
- [Build with Naz video series on developerlife.com YouTube channel](#build-with-naz-video-series-on-developerlifecom-youtube-channel)

Expand All @@ -36,7 +37,8 @@ categories:

The Typestate Pattern in Rust is a way to manage objects that go through different states
in their lifecycle. It leverages Rust's powerful type system to enforce these states and
transitions between them, making your code safer and more predictable.
transitions between them, making your code safer and more predictable. Learn all about it
in this article, its video, and repo.

Here are the key ideas behind the Typestate Pattern:

Expand Down Expand Up @@ -647,6 +649,7 @@ response size: <span style="color:#81A1C1"><b>80 bytes</b></span>
</pre>

### Example 3.1: Using enum and PhantomData instead of struct
<a id="markdown-example-3.1%3A-using-enum-and-phantomdata-instead-of-struct" name="example-3.1%3A-using-enum-and-phantomdata-instead-of-struct"></a>

- You can use enums instead of structs if you have shared data (inner) that you move with
state transitions.
Expand Down
13 changes: 11 additions & 2 deletions _posts/2024-06-10-rust-miette-error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ date: 2024-06-10 15:00:00+00:00
excerpt: |
miette is an excellent crate that can make error handling in Rust powerful, flexible,
and easy to use. It provides a way to create custom error types, add context to errors,
and display errors in a user-friendly way. In this article, we'll explore how to use
miette to improve error handling in your Rust applications.
and display errors in a user-friendly way. In this article, video, and repo, we'll
explore how to use miette to improve error handling in your Rust applications.
layout: post
categories:
- Rust
Expand All @@ -18,6 +18,7 @@ categories:

<!-- TOC -->

- [Introduction](#introduction)
- [Rust error handling primer](#rust-error-handling-primer)
- [More resources on Rust error handling](#more-resources-on-rust-error-handling)
- [YouTube video for this article](#youtube-video-for-this-article)
Expand All @@ -29,6 +30,14 @@ categories:

<!-- /TOC -->

## Introduction
<a id="markdown-introduction" name="introduction"></a>

miette is an excellent crate that can make error handling in Rust powerful, flexible,
and easy to use. It provides a way to create custom error types, add context to errors,
and display errors in a user-friendly way. In this article, video, and repo, we'll
explore how to use miette to improve error handling in your Rust applications.

## Rust error handling primer
<a id="markdown-rust-error-handling-primer" name="rust-error-handling-primer"></a>

Expand Down
20 changes: 10 additions & 10 deletions _posts/2024-06-28-md-parser-rust-from-r3bl-tui.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ title: "Build with Naz : Markdown parser in Rust and nom from r3bl_tui"
author: Nazmul Idris
date: 2024-06-28 15:00:00+00:00
excerpt: |
This tutorial is a deep dive in a real Markdown parser written using nom in Rust.
This MD Parser is part of the r3bl_tui crate, which is part of the r3bl-open-core
repo. It goes over the architecture of thinking about building complex parsers
and the nitty gritty details the runtime nature and behavior when combining
nom parsers.
This tutorial and video are a deep dive in a real Markdown parser written using nom in Rust.
This MD Parser is part of the r3bl_tui crate, which is part of the r3bl-open-core
repo. It goes over the architecture of thinking about building complex parsers
and the nitty gritty details the runtime nature and behavior when combining
nom parsers.
layout: post
categories:
- Rust
Expand All @@ -32,11 +32,11 @@ categories:
## Introduction
<a id="markdown-introduction" name="introduction"></a>

This tutorial is a deep dive in a real Markdown parser written using nom in Rust. This MD
Parser is part of the [`r3bl_tui`](https://crates.io/crates/r3bl_tui) crate, which is part
of the `r3bl-open-core` repo. It goes over the architecture of thinking about building
complex parsers and the nitty gritty details the runtime nature and behavior when
combining nom parsers.
This tutorial, and video are a deep dive in a real Markdown parser written using nom in
Rust. This MD Parser is part of the [`r3bl_tui`](https://crates.io/crates/r3bl_tui) crate,
which is part of the `r3bl-open-core` repo. It goes over the architecture of thinking
about building complex parsers and the nitty gritty details the runtime nature and
behavior when combining nom parsers.

The [`r3bl_tui`](https://crates.io/crates/r3bl_tui) crate is a Text User Interface (TUI)
crate that is used in the [R3BL](https://r3bl.com) suite of products. It is a very
Expand Down
20 changes: 10 additions & 10 deletions _posts/2024-07-10-rust-async-cancellation-safety-tokio.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ title: "Build with Naz : Rust async in practice tokio::select!, actor pattern &
author: Nazmul Idris
date: 2024-07-10 15:00:00+00:00
excerpt: |
This tutorial is a deep dive into the concept of cancellation safety in async code using
Tokio and Rust. It affects the tokio::select! macro, and what happens to the racing
futures that don't win. The examples provided here, along with the video, will go over
both code that is is cancellation safe and code that is not. These examples reflect
real-world patterns, and are a generalized form of them.
This tutorial, video, and repo are a deep dive into the concept of cancellation safety in
async code using Tokio and Rust. It affects the `tokio::select!` macro, and what happens
to the racing `Future`s that don't win. The examples provided here, along with the video,
will go over both code that is is cancellation safe and code that is not. These examples
reflect real-world patterns, and are a generalized form of them.
layout: post
categories:
- Rust
Expand Down Expand Up @@ -35,11 +35,11 @@ categories:
## Introduction
<a id="markdown-introduction" name="introduction"></a>

This tutorial is a deep dive into the concept of cancellation safety in async code using
Tokio and Rust. It affects the `tokio::select!` macro, and what happens to the racing
`Future`s that don't win. The examples provided here, along with the video, will go over
both code that is is cancellation safe and code that is not. These examples reflect
real-world patterns, and are a generalized form of them.
This tutorial, video, and repo are a deep dive into the concept of cancellation safety in
async code using Tokio and Rust. It affects the `tokio::select!` macro, and what happens
to the racing `Future`s that don't win. The examples provided here, along with the video,
will go over both code that is is cancellation safe and code that is not. These examples
reflect real-world patterns, and are a generalized form of them.

`tokio::select!` might as well have been called `tokio::race!` (there's a [The Fast and
Furious : Tokyo
Expand Down
20 changes: 10 additions & 10 deletions _posts/2024-07-16-pin-box-dynamic-duo.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ title: "Build with Naz : Box and Pin exploration in Rust"
author: Nazmul Idris
date: 2024-07-16 15:00:00+00:00
excerpt: |
This tutorial is a deep dive into Rust `Pin` and `Box` types, along with concepts of
ownership and borrowing. We will also cover a lot of background information on the
concepts of operating system process, memory allocation and access, stack, and heap. The
examples we create are designed to demonstrate the different semantics around the use of
boxes and pinned boxes in Rust.
This tutorial, video, and repo are a deep dive into Rust `Pin` and `Box` types, along with
concepts of ownership and borrowing. We will also cover a lot of background information on
the concepts of operating system process, memory allocation and access, stack, and heap.
The examples we create are designed to demonstrate the different semantics around the use
of boxes and pinned boxes in Rust.
layout: post
categories:
- Rust
Expand Down Expand Up @@ -37,11 +37,11 @@ categories:
## Introduction
<a id="markdown-introduction" name="introduction"></a>

This tutorial is a deep dive into Rust `Pin` and `Box` types, along with concepts of
ownership and borrowing. We will also cover a lot of background information on the
concepts of operating system process, memory allocation and access, stack, and heap. The
examples we create are designed to demonstrate the different semantics around the use of
boxes and pinned boxes in Rust.
This tutorial, video, and repo are a deep dive into Rust `Pin` and `Box` types, along with
concepts of ownership and borrowing. We will also cover a lot of background information on
the concepts of operating system process, memory allocation and access, stack, and heap.
The examples we create are designed to demonstrate the different semantics around the use
of boxes and pinned boxes in Rust.

## Why do we need both Box and Pin?
<a id="markdown-why-do-we-need-both-box-and-pin%3F" name="why-do-we-need-both-box-and-pin%3F"></a>
Expand Down
15 changes: 8 additions & 7 deletions docs/2023/02/20/guide-to-nom-parsing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<meta property="og:title" content="Build with Naz : Comprehensive guide to nom parsing" />
<meta name="author" content="Nazmul Idris" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="This tutorial is a comprehensive guide to parsing with nom. It covers the basics of parsing and how to use nom to parse a string into a data structure. It also covers more complex topics like human readable error reporting, and building up complex parsers. We will cover a variety of different examples ranging from parsing simple CSS like syntax to a full blown Markdown parser." />
<meta property="og:description" content="This tutorial is a comprehensive guide to parsing with nom. It covers the basics of parsing and how to use nom to parse a string into a data structure. It also covers more complex topics like human readable error reporting, and building up complex parsers. We will cover a variety of different examples ranging from parsing simple CSS like syntax to a full blown Markdown parser." />
<meta name="description" content="This tutorial and video are a comprehensive guide to parsing with nom. We cover the basics of parsing and how to use nom to parse a string into a data structure. And more complex topics like human readable error reporting, and building up complex parsers. We will create a variety of different examples ranging from parsing simple CSS like syntax to a full blown Markdown parser." />
<meta property="og:description" content="This tutorial and video are a comprehensive guide to parsing with nom. We cover the basics of parsing and how to use nom to parse a string into a data structure. And more complex topics like human readable error reporting, and building up complex parsers. We will create a variety of different examples ranging from parsing simple CSS like syntax to a full blown Markdown parser." />
<link rel="canonical" href="http://developerlife.com/2023/02/20/guide-to-nom-parsing/" />
<meta property="og:url" content="http://developerlife.com/2023/02/20/guide-to-nom-parsing/" />
<meta property="og:site_name" content="developerlife.com" />
Expand All @@ -18,7 +18,7 @@
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Build with Naz : Comprehensive guide to nom parsing" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Nazmul Idris"},"dateModified":"2023-02-20T09:00:00-06:00","datePublished":"2023-02-20T09:00:00-06:00","description":"This tutorial is a comprehensive guide to parsing with nom. It covers the basics of parsing and how to use nom to parse a string into a data structure. It also covers more complex topics like human readable error reporting, and building up complex parsers. We will cover a variety of different examples ranging from parsing simple CSS like syntax to a full blown Markdown parser.","headline":"Build with Naz : Comprehensive guide to nom parsing","mainEntityOfPage":{"@type":"WebPage","@id":"http://developerlife.com/2023/02/20/guide-to-nom-parsing/"},"url":"http://developerlife.com/2023/02/20/guide-to-nom-parsing/"}</script>
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Nazmul Idris"},"dateModified":"2023-02-20T09:00:00-06:00","datePublished":"2023-02-20T09:00:00-06:00","description":"This tutorial and video are a comprehensive guide to parsing with nom. We cover the basics of parsing and how to use nom to parse a string into a data structure. And more complex topics like human readable error reporting, and building up complex parsers. We will create a variety of different examples ranging from parsing simple CSS like syntax to a full blown Markdown parser.","headline":"Build with Naz : Comprehensive guide to nom parsing","mainEntityOfPage":{"@type":"WebPage","@id":"http://developerlife.com/2023/02/20/guide-to-nom-parsing/"},"url":"http://developerlife.com/2023/02/20/guide-to-nom-parsing/"}</script>
<!-- End Jekyll SEO tag -->
<link rel="stylesheet" href="/assets/main.css" />

Expand Down Expand Up @@ -262,10 +262,11 @@ <h2 id="introduction">

<p><a id="markdown-introduction" name="introduction"></a></p>

<p>This tutorial is a comprehensive guide to parsing with nom. It covers the basics of parsing and
how to use nom to parse a string into a data structure. It also covers more complex topics like
human readable error reporting, and building up complex parsers. We will cover a variety of different
examples ranging from parsing simple CSS like syntax to a full blown Markdown parser.</p>
<p>This tutorial and video are a comprehensive guide to parsing with nom. We cover the basics
of parsing and how to use nom to parse a string into a data structure. And more complex
topics like human readable error reporting, and building up complex parsers. We will
create a variety of different examples ranging from parsing simple CSS like syntax to a
full blown Markdown parser.</p>

<blockquote>
<p>For more information on general Rust type system design (functional approach rather than
Expand Down
Loading

0 comments on commit 74b4527

Please sign in to comment.