Add bytes
dependency
Instead of using Vec<u8>
, the Mini-Redis crate uses Bytes
from the bytes
crate. The goal of Bytes
is to provide a robust byte array structure for network programming. The biggest feature it adds over Vec<u8>
is shallow cloning. In other words, calling clone()
on a Bytes
instance does not copy the underlying data. Instead, a Bytes
instance is a reference-counted handle to some underlying data. The Bytes
type is roughly an Arc<Vec<u8>>
but with some added capabilities.
To depend on bytes
, add the following to your Cargo.toml
in the [dependencies]
section:
bytes = "1"