MCPcopy Create free account
hub / github.com/OpenImageDebugger/OpenImageDebugger / BufferBlock

Class BufferBlock

src/ipc/message_exchange.h:146–166  ·  view source on GitHub ↗

* @brief Message block that references an external buffer without owning it. * * @warning Lifetime Requirements: * - The buffer pointed to by `buffer_span` MUST remain valid for the entire * lifetime of this BufferBlock object. * - The buffer MUST NOT be deallocated or modified while this BufferBlock * exists. * - Typically, BufferBlock is used immediately in MessageComposer::

Source from the content-addressed store, hash-verified

144 * bounds checking capabilities and does not own the buffer data.
145 */
146struct BufferBlock final : MessageBlock {
147 /**
148 * @brief Construct a BufferBlock from a std::span.
149 *
150 * @param span Span over the buffer data (the span's underlying buffer must
151 * remain valid for the lifetime of this BufferBlock)
152 */
153 explicit BufferBlock(std::span<const std::byte> span)
154 : buffer_span_{span} {}
155
156 [[nodiscard]] std::size_t size() const noexcept override {
157 return buffer_span_.size();
158 }
159
160 [[nodiscard]] const std::byte* data() const noexcept override {
161 return buffer_span_.data();
162 }
163
164 private:
165 std::span<const std::byte> buffer_span_{};
166};
167
168class MessageComposer {
169 public:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected