Commit Graph

377 Commits

Author SHA1 Message Date
Matthias Einwag 79842672f4 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 Lerche 003543a312 remove new fns from combinator structs (#434)
This is not idiomatic.
2020-10-18 09:55:19 -07:00
Carl Lerche 16c888fbea 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 Lerche ad16e65c28 remove ext traits (#431) 2020-10-16 15:16:23 -07:00
Carl Lerche 69b7e70509 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 Lerche 5133606f40 prepare for 0.6 work (#428) 2020-10-16 11:49:27 -07:00
Sean McArthur 8ec9733fc7 v0.5.6 2020-07-13 17:58:36 -07:00
Sean McArthur 6c9664f09f Move loom to dev-dependencies (#416) 2020-07-13 16:55:47 -07:00
Taiki Endo 04b732a082 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 Endo 63c9265f3c Change default lint level to warning and deny warnings in CI (#397) 2020-07-09 09:12:39 -07:00
Sean Leather 6ccbcdfbc0 docs: Clarify what BytesMut is (#375) 2020-07-09 09:11:45 -07:00
Bryan Donlan b83ea40780 BytesMut: Reuse buffer when data fully consumed via Buf
Closes #412
2020-07-08 15:28:36 -07:00
Tomasz Miąsko 1e82681d16 Use ThreadSanitizer CI setup that avoids false positives (#406) 2020-07-07 01:28:47 +09:00
Juan Aguilar 2e16777240 Add inline attribute to BytesMut::as_mut (#410) 2020-07-05 17:43:26 -07:00
Juan Aguilar e81e1c3c4e Add inline attribute to BytesMut::set_len (#408) 2020-07-03 16:47:32 -07:00
Tomasz Miąsko 3d28557ac0 Remove unnecessary synchronization when cloning shared representation (#404) 2020-07-02 18:55:16 -07:00
Sean McArthur 7e158a1f92 v0.5.5 2020-06-18 14:30:11 -07:00
Mikhail Zabaluev c5fe74761d 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 Endo 0218965db5 Migrate CI to GitHub Actions (#392) 2020-05-25 01:41:45 +09:00
Taiki Endo 7c29088aa4 Deny warnings for doc tests (#391) 2020-05-24 06:30:50 +09:00
Kirill Fomichev 0142960b4e Fix reference in Take docs (#383) 2020-05-22 14:33:06 +09:00
Taiki Endo 9a2e275ae3 Format with rustfmt (#389)
* Format with rustfmt

* Add rustfmt check to CI
2020-05-22 13:17:30 +09:00
Sean McArthur e186368e5b Update to loom v0.3 (#381) 2020-05-22 11:23:22 +09:00
Cheng XU 9e4da2b6cc 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 XU 90581d7f26 Fix tests for no_std build (#384)
This fixes `cargo test --no-default-features`.
2020-05-22 11:18:20 +09:00
Taiki Endo ce1d504c17 Fix CI failure on MacOS (#388)
macOS-10.13 has been removed.
2020-05-22 10:54:52 +09:00
Tim Hambourger f9e9196d20 Fix #354 -- Make advance_mut impl of BufMut for Vec<u8> panic if cnt > remaining 2020-03-25 12:30:15 -07:00
Tim Hambourger 90775ac26f Fix #352 -- Make freeze respect the start offset for BytesMuts in Vec mode 2020-03-24 11:14:16 -07:00
Sean McArthur 24b159c016 v0.5.4 2020-01-23 10:41:50 -08:00
Stepan Koltsov a4b63406c7 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 McArthur 3861bf1217 Disable loom on Windows (#366) 2020-01-23 10:10:15 -08:00
南浦月 f812a9f70e merge hex & debug into fmt (#357) 2020-01-23 10:08:40 -08:00
Nikhil Benesch 5a5bb9ed2a 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-Jones 5369a989a4 Fix reversed arguments in PartialOrd impls (#358) 2020-01-23 10:06:00 -08:00
John-John Tedro 1efd9958a3 Assert that the alignment of Shared is appropriate (#362) 2020-01-23 10:05:20 -08:00
Stepan Koltsov ab3934634c 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 McArthur 952158eeb2 Fix Bytes::truncate losing the original Vec's capacity (#361) 2020-01-22 16:37:53 -08:00
Stepan Koltsov ec0825fe19 Make Bytes::new const fn (#356) 2020-01-09 14:27:28 -08:00
Sean McArthur 4efc6a7663 Improve assertion messages (#349) 2020-01-07 21:29:36 -08:00
Thayne McCombs 7974f2d645 Re-add impl From<BytesMut> for Bytes (#348) 2019-12-19 11:09:14 -08:00
Sean McArthur 419e36e67c 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 0e01f51584 v0.5.3 2019-12-12 12:00:21 -08:00
Sean McArthur 0a99d22ed6 Assert the LSB is 0 when converting Vec into Bytes 2019-12-12 11:46:51 -08:00
Steven Fackler 14222d5a9a Fix conversion of empty vectors to Bytes
Closes #340
2019-12-12 08:33:07 -08:00
Sean McArthur f9a0419036 Make Deref impls of Buf and BufMut forward more methods 2019-12-10 13:35:26 -08:00
Sean McArthur 3a14876f84 Optimize BufMut for Vec and BytesMut (#338) 2019-12-10 13:30:49 -08:00
Sean McArthur bdd6975e08 Add must_use to split, split_off, and split_to 2019-12-04 12:39:48 -08:00
Mikhail Zabaluev bad4e1b3ab Fix regression in Bytes::truncate (#333)
When the length to truncate is greater than the buffer's current
length, do nothing instead of clearing the contents.
2019-12-01 14:00:42 -08:00
Sean McArthur 5012a86462 v0.5.2 2019-11-27 12:59:28 -08:00
Steven Fackler 5c1a59b5c0 Update README.md (#320) 2019-11-27 12:06:33 -08:00