Joey9801 / igc-rs

MIT License
6 stars 4 forks source link

Parsing an entire IGC file #29

Open dbrgn opened 5 years ago

dbrgn commented 5 years ago

The docs state:

This crate provides a minimal, fast parser for IGC files.

But from the docs, it also seems that it only provides a line/record parser. Or did I overlook something?

I'm aware that I can parse a file by mapping the parsing function on a line iterator, but it would be cool if there were a function to do that in this library (e.g. a parser that can process any type that implements std::io::Read). What do you think?

Turbo87 commented 5 years ago

it is certainly possible to build a parser on top of this library that implements that, but I'm not sure if igc-rs should provide that by itself. we currently use lifetime annotations in a lot of places to avoid unnecessary memory copies, but when parsing a whole life that gets a lot more tricky. you would need to read the whole file in memory first, but then the advantage of std::io::Read is gone.

a parser that reads complete files also might want to task the I/J records into account a little better than what we do here so far, and couldn't be stateless due to that.

dbrgn commented 5 years ago

That's true, and I only realized the difficulty with the lifetimes once I ran into that myself :slightly_smiling_face:

Maybe the goal of the library should be re-worded to "This crate provides a minimal, fast parser for IGC records".