Skip to content
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

Thoughts on implementing bytes::BufMut and friends for reducing/eliminating memory moves? #131

Open
korken89 opened this issue Mar 4, 2024 · 0 comments

Comments

@korken89
Copy link

korken89 commented Mar 4, 2024

Hi!

While working on postcard-rpc I noticed that all APIs assume that we work with slices.
However buffers are often created on the stack or in some pool, where the initial value is MaybeUninit::uninit(), and then we initialize the uninitialized data only to later again overwrite it.
Or we first crate a local array on the stack that is initialized, fill it, and the copy it into a channel or pool for shipment.

This is a solved problem in std land, e.g. in tokio::net::xSocket that have buffered operations (e.g. https://docs.rs/tokio/latest/tokio/net/struct.TcpStream.html#method.try_read_buf ).
Checking the underlying trait that is used, bytes, it seems like it would be straight forward to add support for this instead of reinventing the wheel like an old PR of mine here for MaybeUninit support.

What are your thoughts? Would it be worth implementing?
Another PR to heapless would also be needed, but it also looks simple to do.

BR Emil

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

No branches or pull requests

1 participant