Add streaming support to LZ4 compress routine

In preparation to enable lz4diff streaming mode.
Instead of append data to std::vector, lz4diff APIs
now accept a sink function which we send computed data
to. This way, caller can choose to cache data in memory,
or stream writes to disk as data comes.

Bug: 206729162
Test: th
Change-Id: Ib1aea5c1b730d30a1b4814f8d5dd8ce3a8b43826
diff --git a/common/utils.cc b/common/utils.cc
index 794b832..8ea398f 100644
--- a/common/utils.cc
+++ b/common/utils.cc
@@ -1117,4 +1117,15 @@
   return base::HexEncode(blob.data(), blob.size());
 }
 
+[[nodiscard]] std::string_view ToStringView(
+    const std::vector<unsigned char>& blob) noexcept {
+  return std::string_view{reinterpret_cast<const char*>(blob.data()),
+                          blob.size()};
+}
+
+[[nodiscard]] std::string_view ToStringView(const void* data,
+                                            size_t size) noexcept {
+  return std::string_view(reinterpret_cast<const char*>(data), size);
+}
+
 }  // namespace chromeos_update_engine