Skip to content

Commit 6c12dcf

Browse files
PayloadView syntactic sugar (#100)
* PayloadView syntactic sugar * Fix PayloadView constructor shadowing warning --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 22e1f04 commit 6c12dcf

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

pj_base/include/pj_base/buffer_anchor.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ using BufferAnchor = std::shared_ptr<const void>;
3939
struct PayloadView {
4040
Span<const uint8_t> bytes;
4141
BufferAnchor anchor;
42+
43+
PayloadView() = default;
44+
45+
PayloadView(Span<const uint8_t> bytes_, BufferAnchor anchor_) : bytes(bytes_), anchor(std::move(anchor_)) {}
46+
47+
PayloadView(std::shared_ptr<std::vector<uint8_t>> buffer)
48+
: bytes(buffer ? Span<const uint8_t>(buffer->data(), buffer->size()) : Span<const uint8_t>()),
49+
anchor(std::move(buffer)) {}
4250
};
4351

4452
} // namespace sdk

0 commit comments

Comments
 (0)