7

Getting started with Rust 🦀 2021: 7b. Building a GUI app in Rust [Part B]

 2 years ago
source link: https://www.youtube.com/watch?v=SvFPdgGwzTQ
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.
neoserver,ios ssh client

Getting started with Rust 🦀 2021: 7b. Building a GUI app in Rust [Part B]

1,141 views
Oct 19, 2021

671 subscribers

In part B of episode 7, let's make our app come alive by fetching real news data and also add events to our control buttons. We'll learn to use threads, channels and how to manage threads in an immediate mode GUI environment. There's also a lot of tidbits about refactoring Rust code sprinkled in between.

Link to previous video: https://www.youtube.com/watch?v=NtUkr... (Part A of Ep7)

There's also an exercise at the end for you to be involved in adding features to headlines. Make sure you check the repository for source code:

Code repository (git tag: ep7b): https://github.com/creativcoder/headl...

Fork it and try implementing the feature.

This is in continuation of exploratory style videos that am making on Rust. We'll start a new series after this, where we'll start with the language from the very basics.

For context on the newsapi crate watch the last 4 videos in the channel.

This video wouldn't have been possible without the amazing people in the Rust community building high quality libraries. So a big thanks!

Timecode:

0:00 - Overview 1:18 - Adding dark mode using state object 5:42 - Custom color for light theme 6:48 - Adding state persistence using confy

9:25 - Adding an API KEY config window 14:26 - Adding input text widget to config window

16:30 - Making config window exclusive to other UI widgets

18:20 - Integrating newsapi crate 22:12 - Fixing the render lag using threads and channels

28:57 - Reading news from child thread in UI thread 30:28 - Modifying repaint frequency in egui 31:29 - RCA and fixing the first time launch edge case 35:47 - Closing notes and an exercise for you

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

Crates:

iced: https://github.com/iced-rs/iced

egui: https://github.com/emilk/egui sixtyfps: https://github.com/sixtyfpsui/sixtyfps confy: https://github.com/rust-cli/confy tracing: https://github.com/tokio-rs/tracing serde: https://github.com/serde-rs/serde

Good to know resources: egui docs: https://docs.rs/egui/0.14.2/egui/ Rust channels: https://doc.rust-lang.org/rust-by-exa...

Rust threads: https://doc.rust-lang.org/std/thread/ Rust lifetimes: https://doc.rust-lang.org/rust-by-exa...

Immediate vs retained mode API: https://docs.microsoft.com/en-us/wind... The elm architecture: https://guide.elm-lang.org/architecture/ ImGui: https://github.com/ocornut/imgui Cow type: https://doc.rust-lang.org/std/borrow/... cargo workspaces: https://doc.rust-lang.org/book/ch14-0... rust-analyzer: https://rust-analyzer.github.io/ Range type which implements Iterator trait: https://doc.rust-lang.org/std/ops/str... BTreeMap: https://doc.rust-lang.org/std/collect...

---------------------------------------------------------------- This series is aimed at programmers who already have some experience with at least one imperative language such as Python or C/C++, but 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

Support:

Patreon: https://www.patreon.com/creativcoder Ko-fi: https://ko-fi.com/creativcoder

Your support is very much appreciated!

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/

Have a great day :)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK