Commit Graph

288 Commits

Author SHA1 Message Date
Sean McArthur e3de5089d6 Remove io::Cursor, and implement Buf/BufMut for slices instead (#261) 2019-06-07 12:31:10 -07:00
YetAnotherMinion 5b6fa9cea2 feat: remove impl IntoBuf for Cursor<Self>, impl Buf for Bytes, BytesMut, refactor iterators 2019-06-06 16:59:44 -07:00
Sean McArthur 5dfd2177cf bump CI minimum Rust to 1.27 for 'dyn' keyword 2019-06-06 14:29:35 -07:00
Sean McArthur 8413c1cf7a Merge branch 'v0.4.x' into uplift-0.4-commits 2019-06-06 14:08:29 -07:00
Sean McArthur 207b8c47f4 set publish to false, update meta links (#258) 2019-06-06 13:58:22 -07:00
Pavel Strakhov ec1e70f44e Panic in BytesMut::split_to when out of bounds (#252) (#253) 2019-04-02 16:24:30 -07:00
南浦月 b2c5c88732 Fix a typo in CHANGELOG.md (#251) 2019-03-29 13:54:25 -07:00
Carl Lerche 3881a8a158 Bump version to v0.4.12 (#250) 2019-03-06 12:42:20 -08:00
Michal 'vorner' Vaner 505e96e458 Implementation of Buf for VecDeque (#249) 2019-03-06 11:46:42 -08:00
Sangguk Lee 334c2fcd07 Use constants in bytes.rs test code (#247) 2019-02-27 10:41:11 -08:00
南浦月 f6ee7a1d09 Impl FromIterator<&'a u8> for BytesMut/Bytes (#244) 2019-01-30 11:05:15 -08:00
Dax Huiberts 0b90945f6b Fix typo in bytes.rs (#243) 2019-01-28 10:06:28 -08:00
Ralf Jung a624a275d4 use raw ptr for potentially racy load (#240) 2018-12-21 11:07:20 -08:00
Ralf Jung be26124797 Be clear about Inner::kind being deliberate UB (#236) 2018-11-25 22:49:35 -08:00
Carl Lerche 20e16e359f Bump version to v0.4.11 (#235) 2018-11-17 14:33:25 -08:00
Ralf Jung 87c9f5cb96 Use raw pointers for potentially racy loads (#233)
Shared references assert immutability, so any concurrent access would be UB
disregarding data race concerns.
2018-11-17 07:51:50 -08:00
Michal 'vorner' Vaner fe8b9606c4 The Reader can implement BufReader naturally (#232)
There's no reason the user should be forced to wrap it in BufReader in
case the trait is needed, because the Reader has all the bits for
supporting it naturally.
2018-11-17 07:51:41 -08:00
Michal 'vorner' Vaner 09f35cb09d Bring more attention to short reads/slices on Buff/BuffMut (#231)
The property the Buff and BuffMut can return shorter slice is quite an
important detail. Nevertheless, while it is mentioned in the
documentation, the wording makes it relatively easy to overlook. This
tries to bring more attention to it.
2018-11-17 07:51:28 -08:00
Carl Lerche c34a9f5083 Whitelist false positive std (#234) 2018-11-17 07:27:00 -08:00
Carl Lerche 000d406453 Bump version to v0.4.10 (#227) 2018-09-04 13:31:26 -07:00
Carl Lerche af6d2b0eaf White list allocation (#226) 2018-09-03 13:36:13 -07:00
Carl Lerche 39ad7920f2 implement Buf and BufMut for Either (#225) 2018-09-03 10:23:00 -07:00
Federico Mena Quintero ae519ed318 Add a subslice function for Bytes (#198) (#208)
This lets us take Bytes and a &[u8] slice that is contained in it, and
create a new Bytes that corresponds to that subset slice.

Closes #198
2018-09-01 19:57:31 -07:00
Carl Lerche 234a77b026 Bump version to v0.4.9 (#220) 2018-07-22 19:30:41 -07:00
Carl Lerche a76ca641c7 Merge branch 'v0.4.x' 2018-07-12 20:19:56 -07:00
Sean McArthur 3e69a8146b inline Bytes::len and Bytes::is_empty (#211) 2018-07-12 20:17:27 -07:00
Rafael Ávila de Espíndola 63bebaa8c0 Implement IntoBuf for mut slices. (#214)
With this if foo is a mutable slice, it is possible to do

foo.into_buf().put_u32_le(42);

Before this patch into_buf would create a Cursor<&'a [u8]> and it
would not be possible to write into it.
2018-07-12 20:16:08 -07:00
Roman 95d64d6ab7 Fix cargo doc error on nightly caused by broken link to footnote (#218) 2018-07-12 20:15:53 -07:00
Carl Lerche cd8d69c8f4 Merge branch 'v0.4.x' 2018-07-12 20:11:51 -07:00
Sean McArthur fbb7272cba inline Bytes::len and Bytes::is_empty (#211) 2018-07-12 19:05:35 -07:00
Geoffry Song 26b507855e Put type names in backticks. (#212)
I noticed that the bare `[u8]` made rustdoc nightly unhappy.
2018-07-12 19:05:02 -07:00
Rafael Ávila de Espíndola d2cbd452e7 Implement IntoBuf for mut slices. (#214)
With this if foo is a mutable slice, it is possible to do

foo.into_buf().put_u32_le(42);

Before this patch into_buf would create a Cursor<&'a [u8]> and it
would not be possible to write into it.
2018-07-12 19:03:47 -07:00
Roman 8180993218 Fix cargo doc error on nightly caused by broken link to footnote (#218) 2018-07-05 10:13:01 -07:00
Sean McArthur 1f03ad7fd3 Optimize Inner::shallow_clone (#217)
- Clones when the kind is INLINE or STATIC are sped up by over double.
- Clones when the kind is ARC are spec up by about 1/3.
2018-07-03 15:21:26 -07:00
luben karavelov 43854b9a8e Fix documentation (#219) 2018-07-02 12:10:16 -07:00
Ashley Mannix 732b949e5e add support for 128bit numbers (#209) 2018-06-18 17:37:51 -07:00
Carl Lerche 9e3b7692bf Merge branch 'v0.4.x' 2018-06-18 12:52:00 -07:00
Carl Lerche 9b939c59b3 Clarify license as MIT (#216)
The intent of the license was to dual license MIT & Apache 2.0. However,
the messaging was copy / pasted from rust-lang.

Clarify the license as exclusively MIT.

Fixes #215
2018-06-18 12:49:34 -07:00
Carl Lerche 817cc6f081 Merge branch 'v0.4.x' 2018-05-25 16:56:31 -07:00
Carl Lerche 8bedd043e2 Bump version to v0.4.8 (#206) 2018-05-25 16:50:42 -07:00
Carl Lerche 31c18918e9 Filter out tsan warnings in test harness (#205) 2018-05-25 15:54:13 -07:00
Carl Lerche a9bc43899e Filter out tsan warnings in test harness (#205) 2018-05-25 15:32:39 -07:00
Carl Lerche 2b10290b5d Merge branch 'v0.4.x' 2018-05-25 14:15:00 -07:00
Luke Horsley 3c717b9e31 Added a resize function for BytesMut (#203) 2018-05-25 13:54:32 -07:00
Carl Lerche 40ebcd1cfe Use sanitizers in CI (#204) 2018-05-25 12:40:37 -07:00
Noah Zentzis 2491e5102d Recycle space when reserving from Vec-backed Bytes (#197)
* Recycle space when reserving from Vec-backed Bytes

BytesMut::reserve, when called on a BytesMut instance which is backed by
a non-shared Vec<u8>, would previously just delegate to Vec::reserve
regardless of the current location in the buffer. If the Bytes is
actually the trailing component of a larger Vec, then the unused space
won't be recycled. In applications which continually move the pointer
forward to consume data as it comes in, this can cause the underlying
buffer to get extremely large.

This commit checks whether there's extra space at the start of the
backing Vec in this case, and reuses the unused space if possible
instead of allocating.

* Avoid excessive copying when reusing Vec space

Only reuse space in a Vec-backed Bytes when doing so would gain back
more than half of the current capacity. This avoids excessive copy
operations when a large buffer is almost (but not completely) full.
2018-05-24 16:37:13 -07:00
Noah Zentzis 2cd2cd2b4b Recycle space when reserving from Vec-backed Bytes (#197)
* Recycle space when reserving from Vec-backed Bytes

BytesMut::reserve, when called on a BytesMut instance which is backed by
a non-shared Vec<u8>, would previously just delegate to Vec::reserve
regardless of the current location in the buffer. If the Bytes is
actually the trailing component of a larger Vec, then the unused space
won't be recycled. In applications which continually move the pointer
forward to consume data as it comes in, this can cause the underlying
buffer to get extremely large.

This commit checks whether there's extra space at the start of the
backing Vec in this case, and reuses the unused space if possible
instead of allocating.

* Avoid excessive copying when reusing Vec space

Only reuse space in a Vec-backed Bytes when doing so would gain back
more than half of the current capacity. This avoids excessive copy
operations when a large buffer is almost (but not completely) full.
2018-05-24 14:50:31 -07:00
Carl Lerche 13aaeee345 Fix panic in FromIterator for BytesMut 2018-05-11 08:45:04 -07:00
Carl Lerche a8e62dfc7a Bump version to v0.4.7 2018-04-27 10:51:09 -07:00
Carl Lerche 5868e441ee Merge branch 'v0.4.x' 2018-04-27 10:42:00 -07:00