# Bencode

A zero dependency bencode parsing library.

## Usage + Examples

check out `examples/ubuntu_torrent.rs`

```
cargo run --example ubuntu_torrent
```

```rust
// get your torrent file as bytes.
let ubuntu_torrent_file: Vec<u8> = std::fs::read("torrent_files/ubuntu.torrent").unwrap();

// Bencode::from_bytes will traverse the byte array and read it into a bencode object.
let ubuntu_torrent_bencode: Bencode = Bencode::from_bytes(ubuntu_torrent_file.as_slice())
    // it returns a Result<(Bencode, usize), BencodeError>
    .unwrap()
    // the first item is the Bencode tree, 
    // the second object is the index of the last parsed byte.
    .0;
```

## Roadmap

- Publish bencode lib as a standalone library on crates.
- Publish bien as a commandline tool.
- Optimize the bencode parser, (for fun and profit)
    - setup some sort of CI build with metrics.
- (Maybe) Try to get bien published into some sort of package manager ... ?
    - Investigate if this is a lot of work.

## Todo List

- [x] **Create File Structure**
- [x] **Create Parser Functions**
    - [x] Integer value parser
    - [x] ByteString value parser
    - [x] List parser
        - [x] Nested List support & tests
    - [x] Dictionary parser
        - [x] Nested Dict support & tests
- [x] **Implement proper errors, not just `panic!` AKA: _Don't Panic_**
  - [x] Add (un)happy path testing to assert proper error values.
  - [ ] Add useful messages and metadata to the error types.
- [ ] **Add a whole bunch of edge case tests**
    - [ ] then do a bug scrub
