* @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::
| 144 | * bounds checking capabilities and does not own the buffer data. |
| 145 | */ |
| 146 | struct 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 | |
| 168 | class MessageComposer { |
| 169 | public: |
nothing calls this directly
no outgoing calls
no test coverage detected