Skip to content

rust: Use Bytes instead of Vec<u8> in protobufs #272

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

Merged
merged 2 commits into from
Mar 5, 2025

Conversation

gasmith
Copy link
Contributor

@gasmith gasmith commented Mar 5, 2025

For bytes fields on protobufs, we should use Bytes instead of Vec<u8>. This enables zero-copy for buffers that are already Bytes of course, but also for types T: AsRef<[u8]> + Send + 'static (via Bytes::from_owner), such as you'd find for an Arc<Vec<u8>> or Mmap or other various memory views.

@gasmith gasmith self-assigned this Mar 5, 2025
@gasmith gasmith requested review from bryfox and eloff March 5, 2025 06:20
@gasmith gasmith marked this pull request as ready for review March 5, 2025 06:20
Copy link
Contributor

@bryfox bryfox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also end up being useful for #220.

@gasmith gasmith merged commit 94aea4d into main Mar 5, 2025
36 checks passed
@gasmith gasmith deleted the gasmith/rs-proto-bytes branch March 5, 2025 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants