Skip to content

Commit

Permalink
docs: add todo items and comment
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Sep 25, 2024
1 parent d279aa2 commit 022c603
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ echo "4:spam" | ./be2json

## TODO

- Return located errors with input and output positions and context.
- Counter for number of items in a list for debugging and errors.
- Return errors with position.
- Use Property-Based Testing. Generate random valid bencoded values.
- Refactor: Use only one tests with a data provider containing all cases.
- Install tracing crate. Add verbose mode that enables debugging.
- Option to store the JSON and check if it's valid at the end of the process.
- Option to check if the final JSON it's valid at the end of the process.
- Benchmarking for this implementation anc the original C implementation.

## Alternatives

Expand Down
14 changes: 13 additions & 1 deletion src/parsers/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ use std::io::{self, Read, Write};

use crate::io::{byte_reader::ByteReader, byte_writer::ByteWriter};

// todo: return errors instead of panicking in StringParser.
/* todo:
- Return errors instead of panicking in StringParser.
- Optimize UTF-8 conversion. Try to convert to string partially or parts and
stop converting if we reach a point when input is not valid UTF-8 anymore.
This way we don't consume more memory.
*/

use core::str;

Expand Down Expand Up @@ -46,6 +51,13 @@ struct Length {
}

impl Length {
/* todo: conversion from bytes to number can be done progressively like the
C implementation:
0. We need a "temp_length" var.
1. Convert first digit and assign it to the var: temp_length = digit as number.
2. Convert next digit and increase temp_length: temp_length = temp_length * 10 + new_digit.
*/

fn add_byte(&mut self, byte: u8) {
// todo: should we fail here is the byte is not a digit (0..9)?
// or we can wait until we try to convert all bytes in the into a number?
Expand Down

0 comments on commit 022c603

Please sign in to comment.