SoftbearStudios / SoftbearStudios/bitcode

Support zero-allocation encoding into user-provided containers (for compatibility with runtimes like Monoio)

Open
#77 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
671
Forks
61
PR merge metrics
No merged PRs in 30d

Description

It would be very helpful to have the ability to encode data directly into a user-provided, owned container, rather than being limited to buffer.encode(…) -> &'_ [u8].

Reasoning:
Some async runtimes, such as monoio, require owned containers for I/O operations. Currently, code like the following does not work because buffer.encode returns a borrowed slice:

let data = buffer.encode(&my_data);
let (res, _) = socket.send(data).await;

It would be ideal if the API allowed encoding directly into a user-provided buffer, for example:

let mut my_buf = Vec::with_capacity(1024);
…
bitcode::encode_to(&my_data, &mut my_buf);
let (res, ret_my_buf) = socket.send(my_buf).await;
my_buf = ret_my_buf;

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing buffer.encode(...) API and the ownership of its returned slice. Compare that path with the issue's proposed bitcode::encode_to(&my_data, &mut my_buf) usage and determine the API and encoding behavior needed for an owned container. Done means callers can encode into a user-provided buffer and retain ownership for an operation such as Monoio socket.send.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.