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.h b/common/utils.h
index 0f8da22..874d0af 100644
--- a/common/utils.h
+++ b/common/utils.h
@@ -545,6 +545,17 @@
return base::HexEncode(blob.data(), blob.size());
}
+[[nodiscard]] std::string_view ToStringView(
+ const std::vector<unsigned char>& blob) noexcept;
+
+constexpr std::string_view ToStringView(
+ const std::vector<char>& blob) noexcept {
+ return std::string_view{blob.data(), blob.size()};
+}
+
+[[nodiscard]] std::string_view ToStringView(const void* data,
+ size_t size) noexcept;
+
} // namespace chromeos_update_engine
#define TEST_AND_RETURN_FALSE_ERRNO(_x) \