Skip to content

Rewrite using winnow and fixed parse_tar#1

Merged
NobodyXu merged 1 commit into
cargo-bins:mainfrom
NobodyXu:rewrite
Feb 11, 2024
Merged

Rewrite using winnow and fixed parse_tar#1
NobodyXu merged 1 commit into
cargo-bins:mainfrom
NobodyXu:rewrite

Conversation

@NobodyXu

Copy link
Copy Markdown
Member

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.

Why rewrite using winnow?

Related blog post:

@NobodyXu

Copy link
Copy Markdown
Member Author

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>
@passcod

passcod commented Jan 21, 2024

Copy link
Copy Markdown
Member

Looks good at first glance, will look more in depth later this week

@NobodyXu

Copy link
Copy Markdown
Member Author

cc @passcod in case you forgot this PR

@passcod

passcod commented Jan 31, 2024

Copy link
Copy Markdown
Member

Yeah I've been flat out at work, didn't even really have a weekend. I'll do it over waitangi (coming weekend)

@passcod passcod left a comment

Copy link
Copy Markdown
Member

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

Comment thread src/lib.rs
//! 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())?;

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Member Author

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.

@NobodyXu NobodyXu added this pull request to the merge queue Feb 11, 2024
@NobodyXu

Copy link
Copy Markdown
Member Author

Thank you for taking your time to review!

Merged via the queue into cargo-bins:main with commit 78285f4 Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants