Parsing the Redis Serialization Protocol (RESP) in Rust with nom (Part 2)

Subscribers:
950
Published on ● Video Link: https://www.youtube.com/watch?v=ZPdZBHKO4PM



Duration: 1:31:16
206 views
10


In this live coding session, we continue our project focused on parsing the Redis protocol in Rust using the nom library. We tackle various data types within the protocol, including integers, strings, arrays, and more complex structures like maps and sets.

We summarize our progress from the previous session, where we implemented parsers for simple data types and created a library exposing an enum called "value" representing different types of data.

The discussion covers addressing issues encountered with implementing more complex data types like maps and sets, parsing complete messages versus individual values within those messages, and optimizing parsing efficiency. We engage with viewers' questions and suggestions throughout the session, enhancing the collaborative learning experience.

Later, we implement a refactoring using the alt combinator to simplify and improve the code structure. We discuss parsing arrays in the Redis protocol and handle special cases like null values.

The conversation also explores parsing floating-point numbers, including positive and negative infinity and NaN. We discuss the nuances of handling these special values and consider potential improvements to the parsing functionality.

In the final segment, we patch the parsing functionality to handle special floating-point values and discuss plans for publishing our work on GitHub as a library. We invite feedback and contributions from viewers and express gratitude for their collaboration.


Chapters:


00:00:00 Intro
00:01:17 Recap of what we did in the previous stream
00:05:39 Solving the problem with unashable types for our recursive data structure
00:13:10 Creating a higher-level function to parse messages
00:25:10 Changing our first character matching structure with the nom `alt` combinator
00:29:34 Implementing parsing for the array data type
00:46:08 Implementing parsing for the NULL data type
00:50:40 Implementing parsing for the boolean data type
00:57:49 Implementing parsing for the double data type
01:29:20 Quick overview of the repository including our GitHub actions for testing and publishing the crate
01:30:52 Closing



⛓️ Links:

- Our previous session in the series: https://youtu.be/t9P_aOAP2s4
- Our repo (tinyresp): https://github.com/lmammino/tinyresp
- nom documentation: https://docs.rs/nom
- nom combinators cheatsheet: https://github.com/rust-bakery/nom/blob/main/doc/choosing_a_combinator.md
- nom error management cheatsheet: https://github.com/rust-bakery/nom/blob/main/doc/error_management.md
- nom official examples: https://github.com/rust-bakery/nom/tree/main/examples
- examples from this presentation: https://play.rust-lang.org/?
version=stable&mode=debug&edition=2021&gist=f2db795f7b887f9a2257f950863ee1f5
- The Redis Serialization Protocol (RESP) Spec: https://redis.io/docs/reference/protocol-spec/


➡️ Follow us on Twitch for more live streams at https://twitch.tv/loige

#Rust #Parsing #NOM #RedisProtocol #LiveStream #Twitch #LiveCoding




Other Videos By Luciano Mammino (loige)


2024-08-14Building Tinykit: a simple lead generation app on AWS Serverless with Rust - Part 6
2024-07-29Building Tinykit: a simple lead generation app on AWS Serverless with Rust - Part 5
2024-06-11Building Tinykit: a simple lead generation app on AWS Serverless with Rust - Part 4
2024-06-04Building Tinykit: a simple lead generation app on AWS Serverless with Rust - Part 3
2024-05-27Building Tinykit: a simple lead generation app on AWS Serverless with Rust - Part 2
2024-04-15Building Tinykit: a simple lead generation app on AWS Serverless with Rust - Part 1
2024-04-09Building Lambda functions in Rust - part 3
2024-03-19Building Lambda functions in Rust - part 2
2024-03-12Building Lambda functions in Rust
2024-02-27Parsing the Redis Serialization Protocol (RESP) in Rust with nom (Part 3)
2024-02-20Parsing the Redis Serialization Protocol (RESP) in Rust with nom (Part 2)
2024-02-05Exploring OramaSearch with Michele Riva - Indexing and searching blog posts
2024-01-30Intro to nom, a parser combinator library for Rust
2024-01-15Automating blog post descriptions and SEO metadata with Amazon Bedrock
2023-12-11Solving Advent Of Code 2023 day 11
2023-12-04Solving Advent Of Code 2023 day 1 to 3
2023-11-13Building a Twitch Chat Game in Rust part 5 - Twitch Live Stream
2023-11-06Building a Twitch Chat Game in Rust part 4 - Twitch Live Stream
2023-09-18Building a Twitch Chat Game in Rust part 3 - Twitch Live Stream
2023-09-11Building a Twitch Chat Game in Rust part 2 - Twitch Live Stream
2023-09-04Building a Twitch Chat Game in Rust part 1 - Twitch Live Stream



Tags:
rust
redis
nom
parsing
protocol
live coding
slides
parser combinator
regex
regular expression
string splitting
introduction
tech talk
twitch
live stream
pair programming
pairing
english
italian
twitch live coding
Rust
Redis Protocol
nom Library
Parsing Data Types
Data Structures
Protocol Implementation
Efficiency Optimization
Error Handling
Collaborative Learning
GitHub
Live Coding Session
Software Development
Rust Programming Language