Skip to content

Better support protobuf's ByteString in ByteArray. #1763

Description

@buchgr

The ByteArray type uses protobuf's ByteString under the hood, but doesn't allow an outside user to turn a ByteString into a ByteArray (or vice versa) without making an explicit copy. Given that both ByteString and ByteArray are immutable, I can't see a reason why this should not be possible. For example, a ByteArray.wrap(ByteString) and ByteArray.asByteString() method seem appropriate. Those would come in very handy when using the client libraries within a gRPC service.

Could someone please explain why this is the case? If there is no reason, I would be happy to open a PR. Thanks!

P.S. I did notice that the class is non-final and by subclassing one can expose the protected constructor and getByteString() method, but that seems silly.

Activity

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

Metadata

Metadata

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions