aboutsummaryrefslogtreecommitdiff
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-07-19Fix amortized asymptotics of `BytesMut` (#555)Gravatar Jiahao XU 2-15/+67
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> Co-authored-by: Frank Steffahn <frank.steffahn@stu.uni-kiel.de>
2022-07-13Add conversion from Bytes to Vec<u8> (#547)Gravatar Jiahao XU 2-0/+112
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> Co-authored-by: Alice Ryhl <aliceryhl@google.com>
2022-07-13Fix: `From<BytesMut> fo Vec<u8>` implementation (#554)Gravatar Jiahao XU 1-5/+6
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-10Add conversion from BytesMut to Vec<u8> (#543)Gravatar Jiahao XU 1-0/+37
2022-07-09miri: don't use int2ptr casts for invalid pointers (#553)Gravatar Alice Ryhl 1-9/+21
2022-06-11Fix chain remaining_mut(), allowing to chain growing buffer (#488)Gravatar Zettroke 2-2/+5
2022-05-10Add `UninitSlice::as_uninit_slice_mut()` (#548)Gravatar Erick Tryzelaar 1-0/+26
This adds an unsafe method to convert a `&mut UninitSlice` into a `&mut [MaybeUninit<u8>]`. This method is unsafe because some of the bytes in the slice may be initialized, and the caller should not overwrite them with uninitialized bytes. This came about when auditing [tokio-util's udp frame], where they want to pass the unitialized portion of a `BytesMut` to [ReadBuf::uninit]. They need to do this unsafe pointer casting in a few places, which complicates audits. This method lets us document the safety invariants the caller needs to maintain when doing this conversion. [tokio-util's udp frame]: https://github.com/tokio-rs/tokio/blob/master/tokio-util/src/udp/frame.rs#L87 [ReadBuf::uninit]: https://docs.rs/tokio/latest/tokio/io/struct.ReadBuf.html#method.uninit
2022-04-29Only avoid pointer casts when using miri (#545)Gravatar Alice Ryhl 1-2/+19
2022-04-29Revert accidental push directly to masterGravatar Alice Ryhl 1-13/+2
This reverts commit 89061c323861c4e9555881fef940836f1cd132cc. Why am I even able to push to master?
2022-04-29Only avoid pointer casts when using miriGravatar Alice Ryhl 1-2/+13
2022-04-28Fix bugs in `BytesMut::reserve_inner` (#544)Gravatar Jiahao XU 1-1/+1
2022-04-16Make strict provenance compatible (#542)Gravatar Alice Ryhl 1-18/+28
2022-04-15Add TSAN support (#541)Gravatar Alice Ryhl 3-6/+12
2022-04-06Fix aliasing in Clone by using a raw pointer (#523)Gravatar Ben Kimock 1-5/+18
Previously, this code produced a &mut[u8] and a Box<[u8]> to the shared allocation upon cloning it. If the underlying allocation were actually shared, such as through a &[u8] from the Deref impl, creating either of these types incorrectly asserted uniqueness of the allocation. This fixes the example in #522, but Miri still does not pass on this test suite with -Zmiri-tag-raw-pointers because Miri does not currently understand int to pointer casts.
2022-04-06Clarify `BytesMut::unsplit` docs (#535)Gravatar Evan Cameron 1-4/+5
2022-03-25docs: redraw layout diagram with box drawing characters. (#539)Gravatar Anthony Deschamps 1-10/+10
I find this diagram very helpful, but a little hard to distinguish between the boxes and the lines that connect them. This commit redraws the boxes with line drawing characters so that the boxes appear a little more solid, and stand out from the other lines.
2022-03-16Optimize BytesMut::reserve: Reuse vec if possible (#529)Gravatar Jiahao XU 1-12/+28
* Optimize `BytesMut::reserve`: Reuse vec if possible If the `BytesMut` holds a unqiue reference to `KIND_ARC` while the capacity of the `Vec` is not big enough , reuse the existing `Vec` instead of allocating a new one. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-01-24Implement `Extend<Bytes>` for `BytesMut` (#527)Gravatar Rob Ede 1-0/+11
2022-01-24Address various clippy warnings (#528)Gravatar Rob Ede 3-19/+19
2021-11-24Add `BytesMut::zeroed` (#517)Gravatar Donough Liu 1-0/+17
2021-11-09`const`-ify `Bytes::len` and `Bytes::is_empty` (#514)Gravatar Cyborus04 1-2/+2
2021-08-24Clarifying actions of clear and truncate. (#508)Gravatar Christopher Hotchkiss 1-1/+3
2021-08-24impl From<Box<[u8]>> for Bytes (#504)Gravatar Ian Jackson 1-3/+9
2021-08-09BufMut::put_bytes(self, val, cnt) (#487)Gravatar Stepan Koltsov 2-0/+57
Equivalent to ``` for _ in 0..cnt { self.put_u8(val); } ``` but may work faster. Name and signature is chosen to be consistent with `ptr::write_bytes`. Include three specializations: * `Vec<u8>` * `&mut [u8]` * `BytesMut` `BytesMut` and `&mut [u8]` specializations use `ptr::write`, `Vec<u8>` specialization uses `Vec::resize`.
2021-08-09Clarify BufPut::put_int behavior (#486)Gravatar Stepan Koltsov 1-6/+6
* writes low bytes, discards high bytes * panics if `nbytes` is greater than 8
2021-08-07Clarify BufMut allocation guarantees (#501)Gravatar Alice Ryhl 1-1/+9
2021-08-07Remove doc URLs (#498)Gravatar Taiki Endo 1-1/+0
2021-07-05Keep capacity when unsplit on empty other buf (#502)Gravatar Gbillou 1-1/+1
2021-04-11Fully inline BytesMut::new (#493)Gravatar Noah 1-0/+2
2021-04-11Specialize copy_to_bytes for Chain and Take (#481)Gravatar Stepan Koltsov 2-2/+28
Avoid allocation when `Take` or `Chain` is composed of `Bytes` objects. This works now for `Take`. `Chain` it works if the requested bytes does not cross boundary between `Chain` members.
2021-04-11Add inline tags to UninitSlice methods (#443)Gravatar Dan Burkert 1-0/+7
This appears to be the primary cause of significant performance regressions in the `prost` test suite in the 0.5 to 0.6 transition. See danburkert/prost#381.
2021-02-16Panic on integer overflow in Chain::remaining (#482)Gravatar Stepan Koltsov 1-2/+5
Make it safer.
2021-02-15override put_slice for &mut [u8] (#483)Gravatar Zettroke 1-0/+8
2021-01-23Make bytes_mut -> chunk_mut rename more easily discoverable (#471)Gravatar Alice Ryhl 2-0/+6
2021-01-20docs: fix broken Take link (#466)Gravatar Christopher Bunn 1-1/+1
2021-01-11prepare 1.0.1 release (#460)v1.0.1Gravatar Alice Ryhl 1-1/+1
2020-12-31use Box::into_raw instead of mem-forget-in-disguise (#458)Gravatar Ralf Jung 1-2/+1
2020-12-31add inline for Vec::put_slice (#459)Gravatar laizy 1-1/+1
2020-12-29Fix deprecation warning (#457)Gravatar Alice Ryhl 1-23/+25
2020-12-18Rename Buf/BufMut, methods to chunk/chunk_mut (#450)Gravatar Carl Lerche 11-70/+70
The `bytes()` / `bytes_mut()` name implies the method returns the full set of bytes represented by `Buf`/`BufMut`. To rectify this, the methods are renamed to `chunk()` and `chunk_mut()` to reflect the partial nature of the returned byte slice. `bytes_vectored()` is renamed `chunks_vectored()`. Closes #447
2020-12-16remove unused Buf implementation. (#449)Gravatar Carl Lerche 1-29/+0
The implementation of `Buf` for `Option<[u8; 1]>` was added to support `IntoBuf`. The `IntoBuf` trait has since been removed. Closes #444
2020-12-12chore: prepare for v1.0.0 work (#448)Gravatar Carl Lerche 1-1/+1
2020-10-20Add `Buf::copy_to_bytes(len)` (#439)Gravatar Carl Lerche 4-16/+30
This method replaces `Buf::to_bytes()`, providing a method that copies a subset of the remaining buffer into a `Bytes` value. As this is strictly more flexible, `to_bytes()` is removed. Fixes: #129, #398
2020-10-20use checked addition with range (#438)Gravatar Carl Lerche 1-1/+1
2020-10-19Switch `BufMut::bytes_mut` to`&mut UninitSlice` (#433)Gravatar Carl Lerche 6-44/+210
The way BufMut uses MaybeUninit can lead to unsoundness. This replaces MaybeUnit with a type owned by bytes so we can ensure the usage patterns are sound. Refs: #328
2020-10-19De-emphasize `Arc` implementation in `Bytes` description (#436)Gravatar Matthias Einwag 1-9/+32
The previous description focussed a lot on the `Arc` based implementation of `Bytes`. Given the vtable based implemetation, this is however not the only valid implementation. This changes the description a bit in order to de-emaphasize the `Arc` part, and to describe that other implementations are possible. This should also be necessary if the vtable gets public.
2020-10-18remove `new` fns from combinator structs (#434)Gravatar Carl Lerche 2-4/+3
This is not idiomatic.
2020-10-16Make BufMut an unsafe trait (#432)Gravatar Carl Lerche 4-8/+8
Users of `BufMut` are unable to defend against incorrect implementations of `BufMut`, this makes the trait unsafe to implement. Fixes #329
2020-10-16remove ext traits (#431)Gravatar Carl Lerche 9-204/+195
2020-10-16Remove BufMut::bytes_vectored_mut() (#430)Gravatar Carl Lerche 3-102/+0
There are issues with regard to uninitialized memory. We are avoiding stabilizing this function for now.