aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-01-08Update loom to 0.7 (#651)Gravatar Taiki Endo 1-1/+1
2024-01-03readme: add security policy (#649)Gravatar Alice Ryhl 1-0/+9
2023-12-28Use `self.` instead of `Self::` (#642)Gravatar Brad Dunbar 1-6/+6
I was a little confused about these calls using `Self::` instead of `self.` here. Is there a reason to use the former instead of the latter?
2023-12-28Simplify UninitSlice::as_uninit_slice_mut() logic (#644)Gravatar Luca Bruno 1-1/+1
This reworks `UninitSlice::as_uninit_slice_mut()` using equivalent simpler logic.
2023-11-16docs: fix broken links (#639)Gravatar Gabriel Goller 9-25/+9
Fixed a few broken links and converted a lot of them from the html-link to intra-doc links.
2023-10-19docs: typo fix (#637)Gravatar DanielB 1-2/+2
Co-authored-by: Daniel Bauman <danielbauman@Daniels-MacBook-Pro.local>
2023-10-02Various cleanup (#635)Gravatar Alice Ryhl 8-137/+351
2023-09-25docs: fix some spelling mistakes (#633)Gravatar mxsm 2-2/+2
2023-09-11Move comment to correct constant (#629)Gravatar Lucas Kent 1-1/+1
2023-09-07doc: fix changelog typo (#628)Gravatar Alice Ryhl 1-1/+1
2023-09-07chore: prepare bytes v1.5.0 (#627)v1.5.0Gravatar Alice Ryhl 2-1/+12
2023-06-20Rename UninitSlice constructors for consistency with ReadBuf (#599)Gravatar Michal Nazarewicz 2-24/+24
tokio::io::ReadBuf uses names `new` and `uninit` for its constructors. For consistency with that, rename recently introduced UninitSlice constructors to match those names.
2023-06-05Fix CI failure (#616)Gravatar Taiki Endo 2-0/+2
2023-02-10Implement BufMut for `&mut [MaybeUninit<u8>]` (#597)Gravatar Michal Nazarewicz 2-13/+145
2023-02-09Add a safe way to create UninitSlice from slices (#598)Gravatar Michal Nazarewicz 2-7/+51
Introduce UninitSlice::from_slice and UninitSlice::from_uninit_slice methods which safely create Uninit slice from provided slice of maybe uninitialised or initialised memory. In addition, add `From<&mut [T]>` implementations (for `T=u8` and `T=MaybeUninit<u8>`) which do conversion from slice to UninitSlice. Closes: #552
2023-02-04Mark BytesMut::extend_from_slice as inline (#595)Gravatar Paa Kojo Samanpa 1-0/+1
This function can be hot in applications that do a lot of encoding. Ideally would do the same for `<BytesMut as BufMut>::put_slice` and `<BytesMut as BufMut::put_u8`.
2023-01-31chore: prepare bytes v1.4.0 (#593)v1.4.0Gravatar Alice Ryhl 2-1/+16
2023-01-31Avoid large reallocations when freezing BytesMut (#592)Gravatar brian m. carlson 2-2/+75
When we freeze a BytesMut, we turn it into a Vec, and then convert that to a Bytes. Currently, this happen using Vec::into_boxed_slice, which reallocates to a slice of the same length as the Vev if the length and the capacity are not equal. This can pose a performance problem if the Vec is large or if this happens many times in a loop. Instead, let's compare the length and capacity, and if they're the same, continue to handle this using into_boxed_slice. Otherwise, since we have a type of vtable which can handle a separate capacity, the shared vtable, let's turn our Vec into that kind of Bytes. While this does not avoid allocation altogether, it performs a fixed size allocation and avoids any need to memcpy.
2023-01-31Document which functions require `std` (#591)Gravatar 0xc0001a2040 5-1/+14
2022-12-20Fix duplicate "the the" typos (#585)Gravatar Nicolae Mihalache 1-2/+2
Co-authored-by: Nicolae Mihalache <nicolae.mihalache@spaceapplications.com>
2022-11-25make IntoIter constructor public (#581)Gravatar Matthijs van Otterdijk 1-3/+1
2022-11-21chore: prepare bytes v1.3.0 (#579)v1.3.0Gravatar Sean Lynch 2-1/+16
2022-11-14Implement native-endian get and put functions for Buf and BufMut (#576)Gravatar Sean Lynch 2-0/+664
Fixes #549
2022-11-14Update nightly snapshot to the current one (#577)Gravatar Sean Lynch 1-1/+1
2022-10-04Rename and expose `BytesMut::spare_capacity_mut` (#572)Gravatar Yotam Ofek 2-8/+41
2022-08-24docs: Bytes::new etc should return Self not Bytes (#568)Gravatar Adam Chalmers 1-8/+8
2022-08-12Don't have important data in unused capacity when calling reserve (#563)Gravatar Alice Ryhl 1-0/+9
2022-07-30chore: prepare bytes v1.2.1 (#561)v1.2.1Gravatar Alice Ryhl 2-1/+7
2022-07-30Fix reserve over allocating underlying buffer (#560)Gravatar Matt Schulte 2-1/+32
Fixes calls to `reserve` when the underlying shared buffer was already big enough to fit the requested capacity. Previously a new even larger buffer was created anyways. This could eventually lead to an OOM condition.
2022-07-19chore: prepare bytes v1.2.0 (#556)v1.2.0Gravatar Alice Ryhl 2-1/+28
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 5-0/+240
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 2-0/+74
2022-07-09miri: don't use int2ptr casts for invalid pointers (#553)Gravatar Alice Ryhl 2-10/+31
2022-06-23chore: Fix unused warnings (#551)Gravatar Lucio Franco 1-2/+2
2022-06-11Fix chain remaining_mut(), allowing to chain growing buffer (#488)Gravatar Zettroke 3-2/+27
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-05-01Update actions/checkout action to v3 (#546)Gravatar Taiki Endo 1-10/+10
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 2-1/+20
2022-04-16Make strict provenance compatible (#542)Gravatar Alice Ryhl 2-18/+30
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 2-13/+29
* 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-03-09update Miri CI config (#534)Gravatar Ralf Jung 1-5/+3