unpack: Support std::span as package arguments

Change-Id: Iae594c0d1b10e96dd4fd1a83cdf60c0757f9f3bd
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/include/ipmid/message/pack.hpp b/include/ipmid/message/pack.hpp
index 9f42494..00fcf46 100644
--- a/include/ipmid/message/pack.hpp
+++ b/include/ipmid/message/pack.hpp
@@ -21,6 +21,7 @@
 #include <array>
 #include <memory>
 #include <optional>
+#include <span>
 #include <string_view>
 #include <tuple>
 #include <utility>
@@ -269,6 +270,22 @@
     }
 };
 
+/** @brief Specialization of PackSingle for std::span<const uint8_t> */
+template <>
+struct PackSingle<std::span<const uint8_t>>
+{
+    static int op(Payload& p, const std::span<const uint8_t>& t)
+    {
+        if (p.bitCount != 0)
+        {
+            return 1;
+        }
+        p.raw.reserve(p.raw.size() + t.size());
+        p.raw.insert(p.raw.end(), t.begin(), t.end());
+        return 0;
+    }
+};
+
 /** @brief Specialization of PackSingle for std::string_view */
 template <>
 struct PackSingle<std::string_view>