Commit Graph

311 Commits

Author SHA1 Message Date
Sean McArthur c3f9cf1d72 Refactor Bytes to use an internal vtable (#298)
Bytes is a useful tool for managing multiple slices into the same region
of memory, and the other things it used to have been removed to reduce
complexity. The exact strategy for managing the multiple references is
no longer hard-coded, but instead backing by a customizable vtable.

- Removed ability to mutate the underlying memory from the `Bytes` type.
- Removed the "inline" (SBO) mechanism in `Bytes`. The reduces a large
  amount of complexity, and improves performance when accessing the
  slice of bytes, since a branch is no longer needed to check if the
  data is inline.
- Removed `Bytes` knowledge of `BytesMut` (`BytesMut` may grow that
  knowledge back at a future point.)
2019-10-16 09:53:36 -07:00
Taiki Endo 1af1de3e56 Fix build fail with serde feature (#293)
Verify no-std build and all features build
2019-09-08 22:10:46 +02:00
Taiki Endo 7ee37ca25c Remove a patch for cross 2019-09-08 17:58:32 +02:00
Chris Beck 79359b1526 Add no_std support, by adding an std feature (#281)
To make the library work as `no_std` we add an `std` feature which
is on by default. When it is off, we compile as `no_std` and make
parts of the API that require `std::io` conditional on the `std`
feature.
2019-09-05 14:00:23 -07:00
Taiki Endo cdb1ebff8c Fix one use of MaybeUninit (#291) 2019-09-01 01:33:10 +09:00
Ralf Jung 25214da03f use raw ptr for racy load and add comment (#289) 2019-08-28 14:41:04 -07:00
Douman def58d121a Fix clippy (#285) 2019-08-27 14:19:44 -07:00
Douman e7fe763e95 Make From only for static slices to Bytes 2019-08-27 22:17:26 +02:00
Douman d5a18356a0 Remove IntoBuf/FromBuf (#288)
As consequence Buf::collect is removed as well, which is replaced with `Buf::into_bytes`. The advantage of `Buf::into_bytes` is that it can be optimized in cases where converting a `T: Buf` into a `Bytes` instance is efficient.
2019-08-27 13:09:43 -07:00
nanpuyue d340e88f36 use mem::MaybeUninit instead of mem::uninitialized 2019-08-16 15:49:37 +02:00
nanpuyue bca82980e2 impl LowerHex/UpperHex for Bytes/BytesMut 2019-08-16 15:49:37 +02:00
Douman ede02c0e16 Remove byteorder dependency (#280) 2019-08-11 10:16:03 -07:00
Taiki Endo 705d5005fc Remove i128 feature (#276) 2019-07-30 11:19:46 -07:00
Carl Lerche a485ab1a2f Set up CI with Azure Pipelines (#275) 2019-07-30 10:29:00 -07:00
Taiki Endo f817432278 Update Bytes to Rust 2018 (#274) 2019-07-26 05:01:22 +09:00
Taiki Endo 506c26d592 Update travis config to test on stable (#273) 2019-07-24 08:25:03 -07:00
Bruce Mitchener 48770ad686 Fix typos. 2019-07-16 11:18:49 -07:00
Bruce Mitchener d3df7bbb77 Remove merge conflict marker. 2019-07-16 11:18:49 -07:00
Sean McArthur 5d0fba0e97 Replace iovec with std::io::IoSlice
- Renames `bytes_vec` to `bytes_vectored` and `bytes_vec_mut` to
  `bytes_vectored_mut`.
2019-06-11 11:58:43 -07:00
Sean McArthur d38e1744fc Use RangeBounds trait for Bytes::slice
- Removes `slice_to` and `slice_from`.
2019-06-10 09:39:27 -07:00
Taiki Endo 0e145e5e87 Replace try! macro with ? operator 2019-06-10 09:05:11 -07:00
Sean McArthur 3db678e258 fix benches after cursor removal 2019-06-07 15:09:06 -07:00
Sean McArthur 4b63faa97e Make serde module private (#262) 2019-06-07 12:31:44 -07:00
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