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;
}
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:
- high latency, no packet loss
- low latency but high packet loss
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
Learning Rust by building Tetris: my favorite childhood game
2023-10-03

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.
Quan Tong