saphyr-rs / saphyr

A set of crates dedicated to parsing YAML.
58 stars 5 forks source link

Add "load_from_read" for io:Read #17

Open tliron opened 6 days ago

tliron commented 6 days ago

The current API supports char iterators, but why not io::Read? This make Saphyr difficult to use in many environments.

If the maintainers are interested in this feature I can attempt a PR.

davvid commented 5 days ago

This sounds like a good idea to me.

Ethiraric commented 4 days ago

The reason is mostly I haven't had the need of it nor the idea. A PR is welcome, otherwise I'll add it when I'm cleaning issues :)

tliron commented 4 days ago

Thanks for the feedback! I'm busy with some other things right now but will update here if I start working on it.

BTW, might be worth pointing out that streaming directly from a file will likely result in worse performance than reading the whole file into a string and then parsing it. See similar discussion for serde-json. They ended up documenting this potential issue, which I think is a great idea. We can just copy that documentation verbatim for Saphyr.

It doesn't mean it's still not useful, for example for generic programs that allow for parsing YAML from arbitrary stream sources (like mine).