toByteString package:byteslice

O(n) when unpinned, O(1) when pinned. Create a ByteString from a byte sequence. This only copies the byte sequence if it is not pinned.
Convert a pinned Bytes to a ByteString O(1) Precondition: bytes are pinned. Behavior is undefined otherwise.