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

Add helper function for chunked reads #5

Open
sosthene-nitrokey opened this issue Apr 26, 2023 · 1 comment
Open

Add helper function for chunked reads #5

sosthene-nitrokey opened this issue Apr 26, 2023 · 1 comment

Comments

@sosthene-nitrokey
Copy link
Collaborator

sosthene-nitrokey commented Apr 26, 2023

A read_to_end function in streaming::utils.

I don't want to do a method that takes or return a Bytes<N> because the whole point of the streaming API is for file that are too large and for which we don't want to have large stack allocations.

What I think we may want to have a function that reads a file and insert it to a &mut Vec, but I was not sure which type should be used?

In opcard and PIV we have a Reply wrapper type around Bytes which are themselves a wrapper around heapless::Vec<u8,N>.

Maybe we could have something like read_to_end(path, location, buffer: &mut impl Write) but I'm not sure which Write trait we should use (std::io::Write is not available in core). Maybe we should come up with our own?

@sosthene-nitrokey
Copy link
Collaborator Author

Also there are many cases where we want to have the length of the file before we begin writing stuff to the output. This is for example the case when dealing with TLV data.

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

No branches or pull requests

1 participant