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

Make read_bytes() also return the number of bytes read #75

Open
vmx opened this issue Dec 4, 2020 · 2 comments
Open

Make read_bytes() also return the number of bytes read #75

vmx opened this issue Dec 4, 2020 · 2 comments

Comments

@vmx
Copy link
Member

vmx commented Dec 4, 2020

If you traverse a file containing CIDs, you might want to keep track of your current position. Currently read_bytes() only returns the new CID. As varints are involved, you cannot tell by how many bytes the reader was advanced. Hence I propose extending read_bytes() to also return the number of byte read.

@mriise
Copy link

mriise commented May 3, 2021

this would require api changes in both varint and multihash, and is a bit awkward as bytes read would have to be passed up in both cases somehow.

is there a specific usecase where this would be useful?

@vmx
Copy link
Member Author

vmx commented May 10, 2021

I was building an index on top of a file that stores CID + data tuples. I wanted to get the byte offset of the data without asking the reader about its current position after it read a CID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants