Skip to content

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

Open

Description

@vmx

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.

Activity

  1. mriise commented on May 3, 2021

    @mriise

    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?

  2. vmx commented on May 10, 2021

    @vmx
    MemberAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions