"Life is all about sharing. If we are good at something, pass it on." - Mary Berry

Integration testing TUI applications in Rust

2024-01-21

In building games with any language, there will be a loop to handle the key events. In case of crossterm, it’s event::read:

 1if poll(Duration::from_millis(10))? {
 2    let event = read()?;
 3    match event {
 4        Event::Key(KeyEvent {
 5            code,
 6            state: _,
 7            kind,
 8            modifiers: _,
 9        }) => {
10            if kind == KeyEventKind::Press {
11                let mut tetromino = self.current_tetromino.clone();
12                match code {
13                    KeyCode::Char('h') | KeyCode::Left => {
14                        tetromino.move_left(self, stdout)?;
15                        self.current_tetromino = tetromino;
16                    }

Read More...


libp2p performance benchmarking

2023-10-27

I invested some time in studying QUIC and libp2p In this article, I will show you how to benchmark the network transfer using perf module for 2 scanerios:

Let’s print help first:

 1     Running `rust-libp2p/target/debug/perf -h`
 2Usage: perf [OPTIONS]
 3
 4Options:
 5      --server-address <SERVER_ADDRESS>
 6      --transport <TRANSPORT>
 7      --upload-bytes <UPLOAD_BYTES>
 8      --download-bytes <DOWNLOAD_BYTES>
 9      --run-server                       Run in server mode
10  -h, --help                             Print help  

Read More...


Learning Rust by building Tetris: my favorite childhood game

2023-10-03

Play tetris 2-player mode in the terminal

After completing the Rust book and working through rustlings, I found myself standing at the crossroads, wondering where to go next. It was then that I had an idea - a project that would allow me to apply my newfound knowledge and create something meaningful. My favorite childhood game, Tetris, became the inspiration for my next coding adventure.

Since I want it to be playable on Windows, I chose the TUI library crossterm.

Read More...