Skip to content

Commit

Permalink
pw_rpc: Expose PacketMeta::payload
Browse files Browse the repository at this point in the history
Change-Id: Ideb24994cabdd3140187f1350f4a9ab8e1a15443
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/112712
Reviewed-by: Wyatt Hepler <[email protected]>
Commit-Queue: Taylor Cramer <[email protected]>
  • Loading branch information
cramertj authored and CQ Bot Account committed Sep 30, 2022
1 parent 339dadf commit ccd351b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pw_rpc/public/pw_rpc/packet_meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,20 @@ class PacketMeta {
constexpr bool destination_is_server() const {
return destination_ == internal::Packet::kServer;
}
// Note: this `payload` is only valid so long as the original `data` buffer
// passed to `PacketMeta::FromBuffer` remains valid.
constexpr ConstByteSpan payload() const { return payload_; }

private:
constexpr explicit PacketMeta(const internal::Packet packet)
: channel_id_(packet.channel_id()),
service_id_(internal::WrapServiceId(packet.service_id())),
destination_(packet.destination()) {}
destination_(packet.destination()),
payload_(packet.payload()) {}
uint32_t channel_id_;
ServiceId service_id_;
internal::Packet::Destination destination_;
ConstByteSpan payload_;
};

} // namespace pw::rpc

0 comments on commit ccd351b

Please sign in to comment.