42 using packet_id_t =
typename packet_id_type<PacketIdBytes>::type;
51 std::vector<suback_return_code>
params
53 : fixed_header_{make_fixed_header(control_packet_type::suback, 0b0000)},
54 entries_{force_move(
params)},
57 endian_store(
packet_id, packet_id_.data());
59 remaining_length_buf_ = val_to_variable_bytes(boost::numeric_cast<std::uint32_t>(remaining_length_));
67 "v3_1_1::suback_packet fixed_header doesn't exist"
70 fixed_header_ =
static_cast<std::uint8_t
>(buf.front());
72 auto cpt_opt = get_control_packet_type_with_check(
static_cast<std::uint8_t
>(fixed_header_));
76 "v3_1_1::suback_packet fixed_header is invalid"
81 if (
auto vl_opt = insert_advance_variable_length(buf, remaining_length_buf_)) {
82 remaining_length_ = *vl_opt;
85 throw make_error(errc::bad_message,
"v3_1_1::suback_packet remaining length is invalid");
87 if (remaining_length_ != buf.size()) {
88 throw make_error(errc::bad_message,
"v3_1_1::suback_packet remaining length doesn't match buf.size()");
92 if (!copy_advance(buf, packet_id_)) {
95 "v3_1_1::suback_packet packet_id doesn't exist"
99 if (remaining_length_ == 0) {
100 throw make_error(errc::bad_message,
"v3_1_1::suback_packet doesn't have entries");
103 while (!buf.empty()) {
108 "v3_1_1::suback_packet suback_return_code doesn't exist"
112 entries_.emplace_back(rc);
113 buf.remove_prefix(1);
117 constexpr control_packet_type type()
const {
118 return control_packet_type::suback;
127 std::vector<as::const_buffer>
ret;
130 ret.emplace_back(as::buffer(&fixed_header_, 1));
132 ret.emplace_back(as::buffer(remaining_length_buf_.data(), remaining_length_buf_.size()));
134 ret.emplace_back(as::buffer(packet_id_.data(), packet_id_.size()));
136 ret.emplace_back(as::buffer(entries_.data(), entries_.size()));
148 remaining_length_buf_.size() +
176 std::vector<suback_return_code>
const&
entries()
const {
181 std::uint8_t fixed_header_;
182 std::vector<suback_return_code> entries_;
184 std::size_t remaining_length_;