Commit Graph
383 Commits
Author SHA1 Message Date
Artem Vorotnikov 2a66700a94 BytesMut::unsplit: rename to join 2020-11-29 06:33:09 +03:00
Ibraheem AhmedandGitHub 39c6d7a512 Upgrade bytes version from 0.5 to 0.6.0 in README (#441) 2020-11-02 00:10:51 +09:00
Carl LercheandGitHub b7f75829ab prepare v0.6.0 release (#440) v0.6.0 2020-10-20 16:08:25 -07:00
Carl LercheandGitHub 39de065a1e Add Buf::copy_to_bytes(len) (#439)
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-20 11:00:35 -07:00
Carl LercheandGitHub 5866839e45 use checked addition with range (#438) 2020-10-20 10:26:38 -07:00
Carl LercheandGitHub e0d8413d53 Switch BufMut::bytes_mut to&mut UninitSlice (#433)
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-19 15:48:23 -07:00
Matthias EinwagandGitHub 5a11c783ec De-emphasize Arc implementation in Bytes description (#436)
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-19 12:32:20 -07:00
Carl LercheandGitHub 4724c7e8a0 remove new fns from combinator structs (#434)
This is not idiomatic.
2020-10-18 09:55:19 -07:00
Carl LercheandGitHub ced050730c Make BufMut an unsafe trait (#432)
Users of `BufMut` are unable to defend against incorrect implementations
of `BufMut`, this makes the trait unsafe to implement.

Fixes #329
2020-10-16 15:45:38 -07:00
Carl LercheandGitHub 94c543f74b remove ext traits (#431) 2020-10-16 15:16:23 -07:00
Carl LercheandGitHub 447530b8a6 Remove BufMut::bytes_vectored_mut() (#430)
There are issues with regard to uninitialized memory. We are avoiding
stabilizing this function for now.
2020-10-16 11:56:03 -07:00
Carl LercheandGitHub 422048eb24 prepare for 0.6 work (#428) 2020-10-16 11:49:27 -07:00
Sean McArthur 6fdb7391ce v0.5.6 v0.5.6 2020-07-13 17:58:36 -07:00
Sean McArthurandGitHub 025bec2954 Move loom to dev-dependencies (#416) 2020-07-13 16:55:47 -07:00
Taiki EndoandGitHub 2d51809bd7 Fix CI failure on Windows (#415)
--no-self-update is necessary because the windows environment cannot
self-update rustup.exe.
2020-07-13 12:33:30 +09:00
Taiki EndoandGitHub 7daa7fe053 Change default lint level to warning and deny warnings in CI (#397) 2020-07-09 09:12:39 -07:00
Sean LeatherandGitHub 972f538b7e docs: Clarify what BytesMut is (#375) 2020-07-09 09:11:45 -07:00
Bryan DonlanandSean McArthur 81550da474 BytesMut: Reuse buffer when data fully consumed via Buf
Closes #412
2020-07-08 15:28:36 -07:00
Tomasz MiąskoandGitHub 90e7e650c9 Use ThreadSanitizer CI setup that avoids false positives (#406) 2020-07-07 01:28:47 +09:00
Juan AguilarandGitHub bc4a6d56f4 Add inline attribute to BytesMut::as_mut (#410) 2020-07-05 17:43:26 -07:00
Juan AguilarandGitHub 3603cec7c2 Add inline attribute to BytesMut::set_len (#408) 2020-07-03 16:47:32 -07:00
Tomasz MiąskoandGitHub 5cde647c29 Remove unnecessary synchronization when cloning shared representation (#404) 2020-07-02 18:55:16 -07:00
Sean McArthur 008d3e508e v0.5.5 v0.5.5 2020-06-18 14:30:11 -07:00
Mikhail ZabaluevandGitHub a3304e8b8b Remove outdated info on BytesMut::with_capacity (#394)
Remove a remark from the doc that pertained to the inline
layout and is no longer true.
2020-05-27 22:02:45 -07:00
Taiki EndoandGitHub 64fe7e10ab Migrate CI to GitHub Actions (#392) 2020-05-25 01:41:45 +09:00
Taiki EndoandGitHub e9877e7a3d Deny warnings for doc tests (#391) 2020-05-24 06:30:50 +09:00
Kirill FomichevandGitHub 08ec01d1e7 Fix reference in Take docs (#383) 2020-05-22 14:33:06 +09:00
Taiki EndoandGitHub 1fbf83816b Format with rustfmt (#389)
* Format with rustfmt

* Add rustfmt check to CI
2020-05-22 13:17:30 +09:00
Sean McArthurandGitHub 5e93fa4c6b Update to loom v0.3 (#381) 2020-05-22 11:23:22 +09:00
Cheng XUandGitHub 9f40abc12a Allow using serde feature in no_std environment (#385)
When `serde` is used, it would enable its default feature `std`.
This of course breaks no_std build.

Fix this by disabling serde's default features. This should work for
both serde + std and serde + no_std case.
2020-05-22 11:19:46 +09:00
Cheng XUandGitHub e8fa2511ff Fix tests for no_std build (#384)
This fixes `cargo test --no-default-features`.
2020-05-22 11:18:20 +09:00
Taiki EndoandGitHub fa464ca483 Fix CI failure on MacOS (#388)
macOS-10.13 has been removed.
2020-05-22 10:54:52 +09:00
Tim HambourgerandSean McArthur b4ebe8432e Fix #354 -- Make advance_mut impl of BufMut for Vec<u8> panic if cnt > remaining 2020-03-25 12:30:15 -07:00
Tim HambourgerandSean McArthur 8bbe9dd87b Fix #352 -- Make freeze respect the start offset for BytesMuts in Vec mode 2020-03-24 11:14:16 -07:00
Sean McArthur fe6e673864 v0.5.4 v0.5.4 2020-01-23 10:41:50 -08:00
Stepan KoltsovandSean McArthur f330ef6c4d Do not panic on Bytes::slice_ref on empty slice (#355)
Use case:

```
let bytes: Bytes = ...
let subbytes = bytes.slice(a..b); // where a == b
let slice = &subbytes[..];
let slice_bytes = bytes.slice_ref(slice);
```

Last line should not panic, because `slice` object is derived from
the original `Bytes` object.

Before this commit it panics, because `Bytes::slice` returns a fresh
`Bytes` object when `begin == end`.
2020-01-23 10:29:42 -08:00
Sean McArthurandGitHub 87b75cce16 Disable loom on Windows (#366) 2020-01-23 10:10:15 -08:00
南浦月andSean McArthur 3853a1fac4 merge hex & debug into fmt (#357) 2020-01-23 10:08:40 -08:00
Nikhil BeneschandSean McArthur f9ebf74091 Minor documentation fixes (#351)
* Remove incorrect comment about behavior of put_slice
* Improve grammar and clarity of BytesMut documentation
2020-01-23 10:06:49 -08:00
Andrew Tunnell-JonesandSean McArthur 939a5edf3d Fix reversed arguments in PartialOrd impls (#358) 2020-01-23 10:06:00 -08:00
John-John TedroandSean McArthur 788cb158ce Assert that the alignment of Shared is appropriate (#362) 2020-01-23 10:05:20 -08:00
Stepan KoltsovandSean McArthur ab028eb6a8 rebuild_boxed_slice instead of rebuild_boxed_vec (#364)
"Promotable" `Bytes` object is constructed from disassembling a
boxed slice object, not a vec.

Thus we should reassemble data into a boxed slice, not into a vec.

Although, it does not create any problems in practice (`Box<[u8]>`
is allocated exactly the same way as `Vec<u8>`), technically it is
a violation of `Vec::from_raw_parts` spec which says that a pointer
"needs to have been previously allocated via `String`/`Vec<T>`".
2020-01-23 10:04:13 -08:00
Sean McArthurandCarl Lerche e0eebde993 Fix Bytes::truncate losing the original Vec's capacity (#361) 2020-01-22 16:37:53 -08:00
Stepan KoltsovandSean McArthur 729bc7c208 Make Bytes::new const fn (#356) 2020-01-09 14:27:28 -08:00
Sean McArthurandCarl Lerche 8695c08bcc Improve assertion messages (#349) 2020-01-07 21:29:36 -08:00
Thayne McCombsandSean McArthur 39b6646e66 Re-add impl From<BytesMut> for Bytes (#348) 2019-12-19 11:09:14 -08:00
Sean McArthurandGitHub c7cf716180 Fix Bytes when Vec pointer's LSB is set (#346)
This separates the `SharedVtable` into 3:

- `PromotableEvenVtable`: The original `SharedVtable`, which will
  promote the `Vec` to `Shared` on the first clone, and is selected when
  the `Vec`'s pointer has the LSB unset.
- `PromotableOddVtable`: Similar to the `PromotableEvenVtable`, but
  selected when the `Vec`'s pointer has the LSB set. This vtable differs
  in the masking used when reconstructing the `Vec`.
- `SharedVtable`: This no longer checks if its current kind is `VEC` or
  `ARC`, and is only created by the "promotable" vtables.

This also adds a test using an "odd" global allocator that purposefully
bumps all pointers with alignment of 1.

Closes #343
2019-12-17 13:23:15 -08:00
Sean McArthur 8ae3bb2104 v0.5.3 v0.5.3 2019-12-12 12:00:21 -08:00
Sean McArthur 8733f74d59 Assert the LSB is 0 when converting Vec into Bytes 2019-12-12 11:46:51 -08:00
Steven FacklerandSean McArthur 17a8ac91e0 Fix conversion of empty vectors to Bytes
Closes #340
2019-12-12 08:33:07 -08:00