0

Getting started with Rust 🦀 2021: 6. Library API design overhaul, async and more

 2 years ago
source link: https://www.youtube.com/watch?v=J_yGWdgeGQM
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Getting started with Rust 🦀 2021: 6. Library API design overhaul, async and more

1,169 views
Sep 22, 2021

In this video, we’ll give an overhaul to newsapi in terms of the public API and remove a few rough edges and also integrate an async fetch method. This is in continuation of exploratory style videos that am making on Rust. Future videos will dive deeper into language features.

Previous video in the series: https://www.youtube.com/watch?v=LHPV3...

(Repository link)

Checkout tag `ep06` for changes so far: https://github.com/creativcoder/cline...

Timecodes: 0:00 - Prologue 0:50 - Overview 2:48 - A top level NewsAPI struct 5:27 - Builder pattern for methods 5:59 - A helper prepare_url method

9:00 - Implementing the ToString trait 9:28 - Match in Rust 10:48 - Add fetch method and pass API_KEY as authorization header 12:20 - Using #[from] for terse error type mapping 13:08 - Defining an error mapper 14:58 - Trying out the new API 17:13 - Implementing getters for Article aka encapsulation 18:11 - It works!! 18:27 - Adding fetch_async method

20:36 - Putting fetch_async behind feature flags 21:34 - Trying out fetch_async using tokio 24:07 - Outro

Target audience: Programmers who are new to Rust and want a bird’s eye overview of the development experience in Rust.

A few resources:

url: https://docs.rs/url/2.2.2/url/ reqwest: https://github.com/seanmonstar/reqwest

builder pattern: https://doc.rust-lang.org/1.0.0/style... authorization header: https://developer.mozilla.org/en-US/d...

Tokio: https://tokio.rs/ async-std: https://async.rs/ smol: https://github.com/smol-rs/smol thiserror: https://docs.rs/thiserror/1.0.29/this...

This series is aimed at programmers who already have some experience with at least one imperative language such as Python or C/C++, but who are new to Rust.

What is Rust and why should you invest time in learning it?

Rust is the most loved programming language according to the Stack Overflow survey for 6th year in a row (2016-2021). Read more in the following blog: https://stackoverflow.blog/2020/06/05...

Thanks for watching!

This channel is dedicated in helping people become better at programming.

Social Platforms: 🐤 Twitter: https://twitter.com/creativcoder 📒 GitHub: https://github.com/creativcoder 📗 Polywork: https://www.polywork.com/creativcoder 🕸️ Blog: https://creativcoder.dev

Free and open source software that I use: 🌐 Firefox: https://www.mozilla.org/en-US/exp/ 📽️ Open Broadcaster Software: https://obsproject.com 🎬 Kdenlive: https://kdenlive.org 🎨 GIMP: https://www.gimp.org/ 🔊 Audacity: https://www.audacityteam.org/ 🖌️ MyPaint: http://mypaint.org/

Your support is very much appreciated.

Have a great day!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK