Skip to content
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

read_all attribute #230

Closed
Ayrx opened this issue Jun 27, 2021 · 4 comments · Fixed by #387
Closed

read_all attribute #230

Ayrx opened this issue Jun 27, 2021 · 4 comments · Fixed by #387
Labels
enhancement New feature or request

Comments

@Ayrx
Copy link

Ayrx commented Jun 27, 2021

Currently there are the count, bytes_read, bits_read and until attributes you can apply to a Vec to tell deku how much to read.

A read_all (name undecided) attribute that tells deku to parse till the end of the input would be very handy and could be used to avoid some ugly math in the bytes_read attribute.

@sharksforarms sharksforarms added the enhancement New feature or request label Jun 29, 2021
@dullbananas
Copy link
Contributor

dullbananas commented Nov 26, 2022

You don't need bytes_read

#[deku(until = "|_| false")]

Edit: actually that doesn't work because it tries to read beyond the last byte and throws an error. Instead you need bits_read = "deku::rest.len()". I think read_all would be better.

@mmun
Copy link

mmun commented Jul 22, 2023

It seems like bits_read = "deku::rest.len()" mostly works except that it cannot handle an empty vec.

@duskmoon314
Copy link

The new implementation based on reader no longer supports deku::rest. Currently, I cannot find a way to read all remaining bytes to a Vec.

I think adding a read_all attribute lets reader_vec_with_predicate check reader.end() instead of predicate can solve the problem. I hope @wcampbell0x2a can share some ideas.

@wcampbell0x2a
Copy link
Collaborator

Hey @duskmoon314, does #387 solve your use case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants