Commit Graph
44 Commits
Author SHA1 Message Date
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
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
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 96268a80d4 Move "extra" methods to extension traits (#306) 2019-10-31 09:39:58 -07:00
Sean McArthurandGitHub 2ac72333fa Change BufMut methods that expose maybe-uninitialized bytes (#305)
- The return type of `BufMut::bytes_mut` is now
  `&mut [MaybeUninit<u8>]`.
- The argument type of `BufMut::bytes_vectored_mut` is now
  `&mut [bytes::buf::IoSliceMut]`.
- `bytes::buf::IoSliceMut` is a `repr(transparent)` wrapper around an
  `std::io::IoSliceMut`, but does not expose the inner bytes with a safe
  API, since they might be uninitialized.
- `BufMut::bytesMut` and `BufMut::bytes_vectored_mut` are no longer
  `unsafe fn`, since the types encapsulate the unsafety instead.
2019-10-24 14:40:45 -07:00
Chris BeckandCarl Lerche c17e40115f 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
DoumanandCarl Lerche 4f5ed82b3c Fix clippy (#285) 2019-08-27 14:19:44 -07:00
DoumanandCarl Lerche b6cb346adf 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
YetAnotherMinionandSean McArthur d8134903de feat: remove impl IntoBuf for Cursor<Self>, impl Buf for Bytes, BytesMut, refactor iterators 2019-06-06 16:59:44 -07:00
Michal 'vorner' VanerandCarl Lerche 0e8b440650 Implementation of Buf for VecDeque (#249) 2019-03-06 11:46:42 -08:00
Carl Lerche 06b94c55b0 Remove buf::Source in favor of buf::IntoBuf
The `Source` trait was essentially covering the same case as `IntoBuf`,
so remove it.

While technically a breaking change, this should not have any impact due
to:

1) There are no reverse dependencies that currently depend on `bytes`
2) Source was not supposed to be implemented externally
3) IntoBuf provides the same implementations as `Source`

Given these points, the change should be safe to apply.
2017-03-07 11:30:08 -08:00
Carl Lerche 94396162b2 Implement chain combinator for Buf 2017-03-01 14:22:53 -08:00
Carl Lerche 4462056e26 Move stray impls into appropriate file 2017-03-01 13:15:11 -08:00
Carl Lerche 30c0e4e9c8 Merge remote-tracking branch 'alexcrichton/more-object-safe' 2017-03-01 10:44:22 -08:00
Alex Crichton d19c929018 Expand object-safe impls slightly
Add `?Sized` bounds to work for DST objects and also add impls for `Box` as well
as `&mut`
2017-03-01 10:37:30 -08:00
Carl Lerche 8fec8a92ad Implement iterator adapter for Buf 2017-03-01 10:03:28 -08:00
Carl Lerche 4f8c565111 Implement FromBuf and Buf::collect
Enables collecting the contents of a `Buf` value into a relevant
concrete buffer implementation.
2017-03-01 09:30:13 -08:00
Carl Lerche f7f8d6c9ef Don't re-export everything from buf module 2017-02-28 17:09:43 -08:00
Carl Lerche 4466b75ae4 Split buf.rs into separate files 2017-02-28 15:21:20 -08:00
Carl Lerche 646624c130 Polish API surface 2017-02-16 16:44:38 -08:00
Carl Lerche bababa8797 Remove Take/TakeMut 2017-02-16 10:36:00 -08:00
Carl Lerche 0e0066e8a0 Write docs and remove unecessary fns and types 2017-02-16 10:26:48 -08:00
Carl Lerche 57e84f267b Restructure and trim down the library
This commit is a significant overhaul of the library in an effort to head
towards a stable API. The rope implementation as well as a number of buffer
implementations have been removed from the library and will live at
https://github.com/carllerche/bytes-more while they incubate.

**Bytes / BytesMut**

`Bytes` is now an atomic ref counted byte slice. As it is contigous, it offers
a richer API than before.

`BytesMut` is a mutable variant. It is safe by ensuring that it is the only
handle to a given byte slice.

**AppendBuf -> ByteBuf**

`AppendBuf` has been replaced by `ByteBuf`. The API is not identical, but is
close enough to be considered a suitable replacement.

**Removed types**

The following types have been removed in favor of living in bytes-more

* RingBuf
* BlockBuf
* `Bytes` as a rope implementation
* ReadExt
* WriteExt
2016-11-02 14:23:45 -07:00
Carl Lerche 98e0d954b5 Reorganize crate 2016-09-23 12:05:32 -07:00
Carl Lerche d05bfb6346 Add more Buf helpers 2016-09-23 07:53:17 -07:00
Carl Lerche 3c58b0c75c Add take fn to Buf & MutBuf 2016-09-21 20:41:21 -07:00
Stefan BühlerandCarl Lerche f693e038d9 Fix buffer overflow in Sink for Vec<u8>
Fixes #46
2016-09-03 13:25:40 -07:00
Carl Lerche 046c864543 Integrate with byteorder 2016-08-31 12:07:44 -07:00
Carl Lerche 04e0ac75e2 Huge overhaul of bytes
* Get rid of `ByteStr` trait
* `Bytes` is not a concrete type
* Add `BlockBuf`
* Delete lots of cruft
* Performance work
2016-08-10 15:45:31 -07:00
Carl Lerche b2efe63c70 Get rid of SliceBuf 2016-08-05 22:49:41 -07:00
Carl Lerche 16b4266c3c Improve Buf/MutBuf impl for Cursor 2016-08-05 22:19:37 -07:00
Carl Lerche b6a424d892 Get rid of BufError 2016-08-05 21:54:29 -07:00
Carl Lerche d650404bb8 Add an AppendBuf 2016-07-23 09:49:59 -07:00
Carl Lerche 3ca009577b Bytes reader should be Send 2016-06-19 21:32:18 +01:00
Carl Lerche 270d2e2844 Freshen up buf API 2016-06-08 14:48:49 -07:00
Carl Lerche 6b624b849a Make MutBuf::advance unsafe
Closes #38
2015-12-03 19:57:08 -08:00
Carl Lerche 531c77654c Merge branch 'v0.2.x' 2015-08-10 10:14:32 -07:00
Carl Lerche ed087be853 Provide Take decorator that limits Buf size 2015-07-28 12:51:24 -07:00
Carl Lerche b4abd1431a Mark MutBuf::mut_buf as unsafe
`MutBuf::mut_buf` allows access to uninitialized memory.
2015-07-26 11:02:46 -07:00
Carl Lerche 296cac263c Implement buffer traits on Vec<u8>, &[u8], Cursor 2015-07-24 16:52:19 -07:00
Felix Kronlage c17f16fdf2 no need to be marked mutable
allows code to compile with nightly again.
2015-07-07 17:38:12 +02:00
Florian HartwigandCarl Lerche e22415b416 Fix Buf and MutBuf documentation 2015-04-08 13:43:02 -07:00
Carl Lerche ac42766535 Group files as buf or byte str related 2015-04-07 23:40:00 -07:00