Move byte_buffer types from cluster and storage into util

This commit is contained in:
Tim Wojtulewicz 2025-04-04 13:22:53 -07:00
parent 40b75cb809
commit 1169fcf2a2
15 changed files with 59 additions and 70 deletions

View file

@ -6,7 +6,6 @@
#include <optional>
#include <string>
#include <vector>
#include "zeek/Span.h"
#include "zeek/logging/Types.h"
@ -15,13 +14,8 @@ namespace zeek::cluster {
namespace detail {
class Event;
using byte_buffer = std::vector<std::byte>;
using byte_buffer_span = Span<const std::byte>;
} // namespace detail
/**
* This class handles encoding of events into byte buffers and back.
*
@ -40,7 +34,7 @@ public:
*
* @returns True on success, false in exceptional cases (e.g. unsupported serialization).
*/
virtual bool SerializeEvent(detail::byte_buffer& buf, const detail::Event& event) = 0;
virtual bool SerializeEvent(byte_buffer& buf, const detail::Event& event) = 0;
/**
* Unserialize an event from a given byte buffer.
@ -49,7 +43,7 @@ public:
*
* @returns The event, or std::nullopt on error.
*/
virtual std::optional<cluster::detail::Event> UnserializeEvent(detail::byte_buffer_span buf) = 0;
virtual std::optional<cluster::detail::Event> UnserializeEvent(byte_buffer_span buf) = 0;
/**
* @returns The name of this event serializer instance.
@ -85,7 +79,7 @@ public:
* @param header The log batch header.
* @param records The actual log writes.
*/
virtual bool SerializeLogWrite(detail::byte_buffer& buf, const logging::detail::LogWriteHeader& header,
virtual bool SerializeLogWrite(byte_buffer& buf, const logging::detail::LogWriteHeader& header,
zeek::Span<logging::detail::LogRecord> records) = 0;
/**
@ -93,7 +87,7 @@ public:
*
* @param buf The span representing received log writes.
*/
virtual std::optional<logging::detail::LogWriteBatch> UnserializeLogWrite(detail::byte_buffer_span buf) = 0;
virtual std::optional<logging::detail::LogWriteBatch> UnserializeLogWrite(byte_buffer_span buf) = 0;
/**
* @returns The name of this log serializer instance.