Rust crates: custom serde deserializers (Twitch live stream 2023-02-13)

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



Duration: 1:09:12
112 views
1


In this video, we continued our exploration of the serde and the serde-json crates. In particular, we improved our deserialization logic by adding some custom deserializers.

- Previous episode in the series: https://youtu.be/rqUH1Dnz8Ho
- Serde & Serde JSON (to parse JSON data): https://serde.rs/

The code is available here: https://github.com/lmammino/rust-lastfm

Chapters:

00:00:00 Intro & Recap from the last stream
00:03:40 Defining a custom ImageSet struct
00:06:00 Refactoring code into submodules
00:07:35 Custom deserialization function using serde deserialize_with
00:20:30 Handling missing fields with serde errors
00:29:16 Writing a test for our custom deserializer
00:31:40 Using the serde json!() macro
00:35:00 Debugging our test
00:38:00 Deserializing by implementing the Deserialize trait directly
00:41:13 Cleaning up and adding more tests
00:50:10 Adding support for now_playing field using deserialize_with
00:58:00 Using serde rename annotation
01:02:55 Testing our solution
01:03:20 Using the serde default annotation
01:05:30 Making the date field optional
01:07:10 Committing and wrapping up

Huge thanks to WGaffa & Altos__ for all the help given during this stream :)

To see the next episodes live check out our Twitch channel: https://twitch.tv/loige
Chat with me on Twitter at https://twitter.com/loige

#rust #json #serde




Other Videos By Luciano Mammino (loige)


2023-07-03Fixing Fullstackbulletin.com part 4 - Twitch Live Stream
2023-06-26Fixing Fullstackbulletin.com part 3 - Twitch Live Stream
2023-06-19Fixing Fullstackbulletin.com part 2 - Twitch Live Stream
2023-06-12Fixing Fullstackbulletin.com part 1 - Twitch Live Stream
2023-05-08Creating Node.js libraries with Rust using Neon (Twitch live stream)
2023-04-18Using Zig from Python 😱 (Twitch Live Stream)
2023-04-03πŸ¦€ Calling Rust from Python 🐍 with PyO3 (Twitch live stream)
2023-03-22πŸ¦€ Exploring Rust crates zip & image (Twitch live stream)
2023-02-27πŸ¦€ Learning Rust web servers with Axum & SQLx (Twitch live stream)
2023-02-21Rust crates: async_stream (Twitch live stream 2023-02-20)
2023-02-13Rust crates: custom serde deserializers (Twitch live stream 2023-02-13)
2023-02-09Rust crates: dotenv, reqwest, url, serde, serde-json (Twitch live stream 2023-02-08)
2023-01-23πŸ¦€ Learning Rust web servers with Axum (Twitch live stream)
2023-01-09πŸ¦€ Learning nom, a Rust parser combinator library (Twitch stream)
2022-11-30Building a Tic Tac Toe game in Solid.js (Twitch Live Stream 2022-11-30)
2022-11-28πŸ¦€ Building a 2D starship game in Rust with Bevy - PART 5 (asteroids)
2022-11-21πŸ¦€ Building a 2D starship game in Rust with Bevy - PART 4 (collisions)
2022-11-14πŸ¦€ Building a 2D starship game in Rust with Bevy - PART 3 (migrating to Bevy 0.9)
2022-11-10πŸ¦€ Building a 2D starship game in Rust with Bevy - PART 2
2022-11-07πŸ¦€ Building a 2D starship game in Rust with Bevy - PART 1
2022-11-02Introduction to Bevy, Rust game engine (Twitch Live 2022-11-02)



Tags:
rust
json
serde
deserialization
custom deserializers
serde-json
parse JSON data
code
Github
Intro
live streaming
coding
live coding
learning
Rust
programming
software development
JSON
tech tutorials
tech talks
tech education
tech community
computer science
software engineering
web development
data structures
algorithms
problem solving
learning to code
coding for beginners
programming basics