Skip to content

Consider iterate over bencoded string bytes #17

@josecelano

Description

@josecelano

Relates to: #12 (comment)

In the new tokenizer, I decided:

  • To use only byte vectors for integer and string tokens.
  • Not to limit the size of the integer.
  • Not to iterate over integer and string bytes in the new tokenizer. No nested iterators.

I wanted to keep this first tokenizer version as simple as possible, but we can discuss other @da2ce7's proposals like:

#[derive(Debug)]
pub enum Bencode<'a, R: BufRead + 'a> {
    Integer(BigInt),
    ByteString(Vec<u8>),
    List(BencodeListIterator<'a, R>),
    Dictionary(BencodeDictIterator<'a, R>),
}

to

#[derive(Debug)]
pub enum Bencode<'a, R: BufRead + 'a> {
    Integer(BigInt),
    ByteString(BencodeStringIterator<'a, R>),
    List(BencodeListIterator<'a, R>),
    Dictionary(BencodeDictIterator<'a, R>),
}
  • The strings may also be tokenized progressively.
  • The implementation limits the Integer to 1024bit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions