"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:

if poll(Duration::from_millis(10))? {
    let event = read()?;
    match event {
        Event::Key(KeyEvent {
            code,
            state: _,
            kind,
            modifiers: _,
        }) => {
            if kind == KeyEventKind::Press {
                let mut tetromino = self.current_tetromino.clone();
                match code {
                    KeyCode::Char('h') | KeyCode::Left => {
                        tetromino.move_left(self, stdout)?;
                        self.current_tetromino = tetromino;
                    }

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:

     Running `rust-libp2p/target/debug/perf -h`
Usage: perf [OPTIONS]

Options:
      --server-address <SERVER_ADDRESS>
      --transport <TRANSPORT>
      --upload-bytes <UPLOAD_BYTES>
      --download-bytes <DOWNLOAD_BYTES>
      --run-server                       Run in server mode
  -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...