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.)
This commit is contained in:
Sean McArthur
2019-10-16 09:53:36 -07:00
committed by GitHub
parent ebe96021b0
commit 43ac8e5494
17 changed files with 2165 additions and 2818 deletions
+1
View File
@@ -28,4 +28,5 @@ serde = { version = "1.0", optional = true }
either = { version = "1.5", default-features = false, optional = true }
[dev-dependencies]
loom = "0.2.10"
serde_test = "1.0"