Skip to content

RUST-2258 Use borrowed buffer in raw serializer #590

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LeWimbes
Copy link

@LeWimbes LeWimbes commented Aug 6, 2025

Similar to the idea in #328, raw::Serializer now takes a &mut Vec<u8>.
Because the Vec is borrowed, the same buffer can be reused for many serializations without reallocating.

  • added serialize_to_buffer: serialize &T straight into a caller-supplied Vec<u8>.
  • serialize_to_vec still exists. It just allocates a Vec<u8> and forwards it to serialize_to_buffer.

Breaking change: raw::Serializer::new() now expects &mut Vec<u8>.

@LeWimbes LeWimbes requested a review from a team as a code owner August 6, 2025 15:13
@LeWimbes LeWimbes requested a review from isabelatkinson August 6, 2025 15:13
@isabelatkinson isabelatkinson changed the title Borrow the buffer instead of owning it RUST-2258 Use borrowed buffer in raw serializer Aug 6, 2025
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

Successfully merging this pull request may close these issues.

1 participant