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

Add trait ExactSizeBuf as well as corresponding implementations #496

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

Conversation

regexident
Copy link

In many scenarios it is desirable to use abstract traits, such as Buf and BufMut in one's API, rather than explicitly use Bytes and BytesMut (let alone bare &[u8] or &mut [u8]).

In encoding/decoding scenarios an also rather common requirement is to be able to obtain the length of a buffer. Unfortunately neither Buf nor BufMut provide a fn len(&self) -> usize method to do so.

This PR aims to fill this gap without introducing a breaking change by adding a ExactSizeBuf trait alongside several implementations for types provided by this crate.

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.

None yet

1 participant