Skip to content
jayywasherePublic

About

a small run-length encoding and decoding CLI written in Rust because apparently i needed another excuse to make another command-line program. and i think my brain has mixed feelings about that!!

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RLE Tools

a small run-length encoding and decoding CLI written in Rust because apparently i needed another excuse to make a command-line program

About

rle-tools is a small interactive CLI for encoding and decoding text using run-length encoding (RLE).

i made this mainly to practice working with:

  • string processing
  • iterators and character handling
  • Result-based error handling
  • CLI input and control flow
  • splitting a Rust project into modules
  • writing and testing reusable encoding and decoding logic

the program provides separate modes for encoding and decoding, with input validation and recoverable errors for invalid input. . .

Features

  • run-length encoding (yes!)
  • run-length decoding (yes!)
  • interactive CLI (eh??)
  • input validation (uhuh...)
  • error handling (erm...)

How It Works

run-length encoding represents consecutive repeated characters using a count followed by the character!!

for example:

aaabbccccdaa

     ↓

3a2b4c1d2a

decoding reverses the process:

3a2b4c1d2a

     ↓

aaabbccccdaa

another example:

beepboop

     ↓

1b2e1p1b2o1p

Example

a normal session looks like this:

Select:
1. Encode
2. Decode
3. Exit
--> 1

Enter '__exit' to exit.
Enter anything else to proceed with encoding.

Enter something: beepboop
The encoded result is: 1b2e1p1b2o1p

Enter something: __exit
Exiting...

Select:
1. Encode
2. Decode
3. Exit
--> 2

Enter '__exit' to exit.
Enter anything else to proceed with decoding.

Enter something: 1b2e1p1b2o1p
The decoded result is: beepboop

Enter something: __exit
Exiting...

Select:
1. Encode
2. Decode
3. Exit
--> 3

Goodbye!

invalid input is handled without terminating the program:

Enter something: b1pweo
[Error]: Raw input string for encoding must not contain digits.

Enter something: aaaaaa
The encoded result is: 6a

Why I Made This

i wanted a relatively small Rust project that still required me to think about how to structure an actual application instead of putting everything inside main.rs

it also gave me an excuse to work with Result and error propagation while implementing both the encoder and decoder myself !

Requirements

  • Rust
  • Cargo

Running

clone the repository and enter the project directory:

git clone https://github.com/jayywashere/rle-tools
cd rle-tools

run the program:

cargo run

run the tests:

cargo test

License

See LICENSE.

About

a small run-length encoding and decoding CLI written in Rust because apparently i needed another excuse to make another command-line program. and i think my brain has mixed feelings about that!!

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages