-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite using winnow and fixed parse_tar
#1
Conversation
Original PR: Berrysoft#2 |
`parse_tar` now break the iteration once it encounters `None` from `parse_entry` instead of using `Iterator::flatten`, which keeps going instead of breaking the loop. It also fixed `parse_entry_streaming` to treat eof as end of the archive file as per the spec. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Looks good at first glance, will look more in depth later this week |
cc @passcod in case you forgot this PR |
Yeah I've been flat out at work, didn't even really have a weekend. I'll do it over waitangi (coming weekend) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I took so long. This all looks good, so i'm happy to stamp
@@ -4,30 +4,31 @@ | |||
//! ```no_run | |||
//! # fn main() -> Result<(), Box<dyn std::error::Error>> { | |||
//! let file = std::fs::read("foo.tar")?; | |||
//! # fn parse(file: &[u8]) -> Result<(), Box<dyn std::error::Error + '_>> { | |||
//! let (_, entries) = tar_parser2::parse_tar(&file[..])?; | |||
//! let entries = tar_parser2::parse_tar(&mut &file[..]).map_err(|err| err.into_inner().unwrap())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given this is a fairly significant rewrite that we're not upstreaming, maybe we should rename to tar_parser3? or to binstall-tar-parser?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think tar-parser3 is a good name, having binstall- prefix makes it looks like a project only binstall can use.
Thank you for taking your time to review! |
parse_tar
now break the iteration once it encountersNone
fromparse_entry
instead of usingIterator::flatten
, which keeps going instead of breaking the loop.It also fixed
parse_entry_streaming
to treat eof as end of the archive file as per the spec.Why rewrite using
winnow
?Located
andStateful
Stream
and any incomplete stream viaStreamPartial
simply by using genericsRelated blog post: