Async Rust example
Road to the asynchronous Rust
Table of Contents
About the Project
Screenshots
Tech Stack
Features
Notification daemon
- usign D-Bus for catching notifications.
- using tokio for async.
- draw simple but stylish boxes around notifications.
- supports window resizing.
- supports immortal notifications as well as mortal.
- supports all apps using D-Bus interface.
Web server
- serving requests concurrently.
Getting Started
Prerequisites
rustup
:
Install Read "Installation" from 'The Rust Programming Language' book.
Clone and run
$ git clone https://github.com/khadievedem/rust_async.git
$ cd rust_async
Run notification daemon project with
$ cargo run --bin notification_daemon
or web server
$ cargo run --bin web_server
Usage
Web Server
localhost:7878/
hello world page
./web_server/src/hello.html
localhost:7878/sleep
sleep for a 10 seconds (in order to test concurrency)
localhost:7878/smthfkwejfllkdk
Ooops! :-)
./web_server/src/404.html
Notification daemon
Run the app according to Clone & Run section.
press 'q' to exit.
Roadmap
Zero stage
- Huge absorption of information about programming in Rust.
- Read Rust async-book.
First stage
- Create web-server following guide in the Rust async-book.
- Migrate from async-std to
tokio
(web-server
) - Brainstorm on example project topics.
- Decide which project will best demonstrate async working (under Linux)
See more about my decision at: FAQ section
Second stage
- Read how communication between apps works in Linux.
- Study the D-Bus Notifications Specification.
- Create simple application using
zbus
(crate for D-Bus) - Write an interface for catching notifications.
- Brainstorm on showing notifications to the user.
- Unsafe
QT
drawing attempts. -
GTK
drawing attempts.
See about problems with GUI at: FAQ section
- TUI drawing using
console-engine
.
Third stage
- Brainstorm on concurrent connection of drawing and catching notifications.
- Async notification catching.
- Async notification boxes drawing.
- Set up communication between catcher and drawer using
tokio mspc
channel.
FAQ
Why did you choose the notification daemon?
My very first idea was to implement my own Windows Manager. But there was one major problem - asynchronous Windows Manager sounds really weird, it must use multithreading. So I started looking for other interesting ideas to implement.
Notification daemon was selected, because in addition to async programming I learn in detail D-Bus, as well as writing an application that interacts with other programs.
Why didn't you implement the GUI? The TUI doesn't look very useful.
As you can see in qt-notifications branch I've tried to implement graphical notificaitons using
qt
as well asgtk
. But I faced a problem connected with my Windows Manage (I use 'sway' BTW). Tiling WMs can't draw a pop-up window in the corner. Instead they draw it right in the center. To draw notifications in the corner, I would have to work withwinit
, but that would take a very long time. After all, the main goal of the project -> learn async Rust, not to work with graphics. That's why I chose the Terminal application.