LibQuicR
message_serialisation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) 2024 Cisco Systems
2 // SPDX-License-Identifier: BSD-2-Clause
3 
4 #pragma once
5 
9 #include "quicr/track_name.h"
10 
11 #include <map>
12 #include <string>
13 #include <vector>
14 
15 namespace quicr::messages {
22  Bytes& operator<<(Bytes& buffer, const std::optional<Extensions>& extensions);
23 
30  Bytes& operator<<(Bytes& buffer, const Extensions& extensions);
31 
38  BytesSpan operator>>(BytesSpan buffer, Extensions& extensions);
39 
47  void SerializeExtensions(Bytes& buffer,
48  const std::optional<Extensions>& extensions,
49  const std::optional<Extensions>& immutable_extensions);
50 
67  template<class StreamBufferType>
68  bool ParseExtensions(StreamBufferType& buffer,
69  std::optional<std::size_t>& extension_headers_length,
70  std::optional<Extensions>& extensions,
71  std::optional<Extensions>& immutable_extensions,
72  std::size_t& extension_bytes_remaining,
73  std::optional<std::uint64_t>& current_header,
74  std::uint64_t& prev_extension_type);
75 
79  enum class DatagramHeaderType : uint8_t
80  {
89  };
90 
94  enum class DatagramStatusType : uint8_t
95  {
96  kNoExtensions = 0x20,
97  kWithExtensions = 0x21
98  };
99 
103  enum class FetchHeaderType : uint8_t
104  {
105  kFetchHeader = 0x05
106  };
107 
111  enum class SubgroupIdType : std::uint8_t
112  {
113  kIsZero = 0b00,
114  kSetFromFirstObject = 0b01,
115  kExplicit = 0b10,
116  kReserved = 0b11
117  };
118 
123  {
124  const bool extensions;
126  const bool end_of_group;
127  const bool default_priority;
128  const bool first_object;
129 
130  static constexpr std::uint8_t kExtensionsBit = 0x01;
131  static constexpr std::uint8_t kSubgroupIdMask = 0x06;
132  static constexpr std::uint8_t kEndOfGroupBit = 0x08;
133 
135  static constexpr std::uint8_t kTypeBit = 0x10;
136  static constexpr std::uint8_t kDefaultPriorityBit = 0x20;
137  static constexpr std::uint8_t kFirstObjectBit = 0x40;
138 
140  static constexpr std::uint64_t kAllowedBitsMask =
142 
148  explicit constexpr StreamHeaderProperties(const std::uint64_t type)
149  : extensions(type & kExtensionsBit)
150  , subgroup_id_mode(static_cast<SubgroupIdType>((type & kSubgroupIdMask) >> 1))
151  , end_of_group(type & kEndOfGroupBit)
153  , first_object(type & kFirstObjectBit)
154  {
155  if (!IsValid(type)) {
156  throw ProtocolViolationException("Invalid stream header type");
157  }
158  }
159 
169  constexpr StreamHeaderProperties(const bool extensions,
171  const bool end_of_group,
172  const bool default_priority,
173  const bool first_object)
179  {
181  throw ProtocolViolationException("Subgroup ID mode cannot be kReserved");
182  }
183  }
184 
186  constexpr std::uint64_t GetType() const
187  {
188  std::uint64_t type = kTypeBit;
189  if (extensions) {
190  type |= kExtensionsBit;
191  }
192  type |= static_cast<std::uint64_t>(subgroup_id_mode) << 1;
193  if (end_of_group) {
194  type |= kEndOfGroupBit;
195  }
196  if (default_priority) {
197  type |= kDefaultPriorityBit;
198  }
199  if (first_object) {
200  type |= kFirstObjectBit;
201  }
202  return type;
203  }
204 
207  static constexpr bool IsValid(const std::uint64_t type) noexcept
208  {
209  return (type & ~kAllowedBitsMask) == 0 && (type & kTypeBit) != 0 &&
210  (type & kSubgroupIdMask) != kSubgroupIdMask;
211  }
212  };
213 
218  {
219  const bool extensions;
220  const bool end_of_group;
221  const bool zero_object_id;
222  const bool default_priority;
223  const bool status;
224 
225  static constexpr std::uint8_t kExtensionsBit = 0x01;
226  static constexpr std::uint8_t kEndOfGroupBit = 0x02;
227  static constexpr std::uint8_t kZeroObjectIdBit = 0x04;
228  static constexpr std::uint8_t kDefaultPriorityBit = 0x08;
229  static constexpr std::uint8_t kStatusBit = 0x20;
230 
235  constexpr explicit DatagramHeaderProperties(const std::uint8_t type)
236  : extensions(type & kExtensionsBit)
237  , end_of_group(type & kEndOfGroupBit)
240  , status(type & kStatusBit)
241  {
242  if (!IsValid(type)) {
243  throw ProtocolViolationException("Invalid Datagram type");
244  }
245  }
246 
255  constexpr DatagramHeaderProperties(const bool extensions,
256  const bool end_of_group,
257  const bool zero_object_id,
258  const bool default_priority,
259  const bool status) noexcept
264  , status(status)
265  {
266  }
267 
272  constexpr std::uint8_t GetType() const noexcept
273  {
274  std::uint8_t type = 0;
275  if (extensions) {
276  type |= kExtensionsBit;
277  }
278  if (end_of_group) {
279  type |= kEndOfGroupBit;
280  }
281  if (zero_object_id) {
282  type |= kZeroObjectIdBit;
283  }
284  if (default_priority) {
285  type |= kDefaultPriorityBit;
286  }
287  if (status) {
288  type |= kStatusBit;
289  }
290  return type;
291  }
292 
298  static constexpr bool IsValid(const std::uint8_t type) noexcept
299  {
300  if (type & 0xD0) {
301  return false;
302  }
303  if (type & kEndOfGroupBit && type & kStatusBit) {
304  return false;
305  }
306  return true;
307  }
308  };
309 
313  enum class StreamMessageType
314  {
315  kFetchHeader,
317  };
318 
325  [[maybe_unused]] [[nodiscard]] static StreamMessageType GetStreamMessageType(const std::uint64_t type)
326  {
327  if (type == static_cast<std::uint64_t>(FetchHeaderType::kFetchHeader)) {
329  }
332  }
333  throw ProtocolViolationException("Invalid stream header type");
334  }
335 
337  struct FetchHeader
338  {
341  uint64_t request_id;
342 
351  template<class StreamBufferType>
352  friend bool operator>>(StreamBufferType& buffer, FetchHeader& msg);
353 
354  private:
355  uint64_t current_pos{ 0 };
356  bool parse_completed{ false };
357  };
358 
367 
374  Bytes& operator<<(Bytes& buffer, const FetchHeader& msg);
375 
378  {
380  enum class EndOfRange
381  {
382  kNonExistent,
383  kUnknown,
384  };
385 
387  enum class SubgroupIdMode : std::uint8_t
388  {
389  kZero = 0x00,
390  kPrior = 0x01,
391  kNext = 0x02,
392  kExplicit = 0x03,
393  };
394 
395  std::optional<EndOfRange> end_of_range;
396 
398  std::optional<SubgroupIdMode> subgroup_id_mode;
403  bool datagram;
404 
405  static constexpr std::uint8_t kSubgroupMask = 0x03;
406  static constexpr std::uint8_t kObjectIdDeltaBit = 0x04;
407  static constexpr std::uint8_t kGroupIdDeltaBit = 0x08;
408  static constexpr std::uint8_t kPriorityBit = 0x10;
409  static constexpr std::uint8_t kPropertiesBit = 0x20;
410  static constexpr std::uint8_t kDatagramBit = 0x40;
411  static constexpr std::uint64_t kEndOfNonExistentRange = 0x8C;
412  static constexpr std::uint64_t kEndOfUnknownRange = 0x10C;
413 
419  explicit FetchSerializationProperties(std::uint64_t value);
420 
433  bool priority_present,
434  bool properties_present,
435  bool datagram) noexcept;
436 
438  [[nodiscard]] std::uint64_t GetType() const noexcept;
439  };
440 
442  struct FetchObject
443  {
445  std::optional<FetchSerializationProperties> properties;
446  std::optional<std::uint64_t>
448 
450  std::optional<std::uint64_t> subgroup_id;
451  std::optional<std::uint64_t>
453 
455  std::optional<std::uint8_t> publisher_priority;
456  std::optional<Extensions> extensions;
457  std::optional<Extensions>
459 
461  uint64_t payload_len{ 0 };
462 
465 
474  template<class StreamBufferType>
475  friend bool operator>>(StreamBufferType& buffer, FetchObject& msg);
476 
477  private:
478  std::optional<std::size_t> extension_headers_length;
479  std::size_t extension_bytes_remaining{ 0 };
480  std::optional<uint64_t> current_tag{};
481  std::uint64_t prev_extension_type{ 0 };
482  uint64_t current_pos{ 0 };
483  bool parse_completed{ false };
484  };
485 
488  {
490 
493  };
494 
497  {
498  public:
500  explicit FetchObjectSerializationState(GroupOrder group_order) noexcept
501  : group_order_(group_order)
502  {
503  }
504 
514  FetchObject Encode(const ObjectHeaders& headers, std::uint8_t priority, BytesSpan payload);
515 
523  std::optional<ResolvedFetchObject> Decode(FetchObject&& object);
524 
525  private:
526  GroupOrder group_order_;
527  std::optional<std::uint64_t> prior_group_id_;
528  std::optional<std::uint64_t> prior_object_id_;
529  std::optional<std::uint64_t> prior_subgroup_id_;
530  std::optional<std::uint8_t> prior_priority_;
531  };
532 
540  bool operator>>(Bytes& buffer, FetchObject& msg);
541 
551  Bytes& operator<<(Bytes& buffer, const FetchObject& msg);
552 
553  //
554  // Data Streams
555  //
556 
559  {
560  std::uint64_t track_alias;
561  std::uint64_t group_id;
562 
564  std::uint64_t object_id;
565  std::optional<std::uint8_t> priority;
566  std::optional<Extensions> extensions;
567  std::optional<Extensions> immutable_extensions;
568 
570  uint64_t payload_len{ 0 };
571 
575  bool end_of_group{ false };
576 
586  template<class StreamBufferType>
587  friend bool operator>>(StreamBufferType& buffer, ObjectDatagram& msg);
588 
593  std::uint8_t GetType() const { return GetProperties().GetType(); }
594 
600  {
601  return DatagramHeaderProperties(extensions.has_value() || immutable_extensions.has_value(),
602  end_of_group,
603  object_id == 0,
604  !priority.has_value(),
605  false);
606  }
607 
608  private:
609  std::optional<DatagramHeaderProperties> properties;
610  std::optional<std::size_t> extension_headers_length;
611  std::size_t extension_bytes_left{ 0 };
612  std::optional<uint64_t> current_tag{};
613  std::uint64_t prev_extension_type{ 0 };
614  uint64_t current_pos{ 0 };
615  bool parse_completed{ false };
616  };
617 
624  Bytes& operator<<(Bytes& buffer, const ObjectDatagram& msg);
625 
628  {
629  std::uint64_t track_alias;
630  std::uint64_t group_id;
631 
633  std::uint64_t object_id;
634  std::optional<std::uint8_t>
636  std::optional<Extensions> extensions;
637  std::optional<Extensions> immutable_extensions;
639 
647  template<class StreamBufferType>
648  friend bool operator>>(StreamBufferType& buffer, ObjectDatagramStatus& msg);
649 
651  std::uint64_t GetType() const
652  {
653  const auto properties = DatagramHeaderProperties(extensions.has_value() || immutable_extensions.has_value(),
654  false,
655  object_id == 0,
656  !publisher_priority.has_value(),
657  true);
658  return properties.GetType();
659  }
660 
661  private:
662  std::optional<DatagramHeaderProperties> properties;
663  std::optional<std::size_t> extension_headers_length;
664  std::size_t extension_bytes_left{ 0 };
665  std::optional<uint64_t> current_tag{};
666  std::uint64_t prev_extension_type{ 0 };
667  uint64_t current_pos{ 0 };
668  bool parse_completed{ false };
669  };
670 
678 
679  // SubGroups
682  {
684  std::optional<StreamHeaderProperties> properties;
685  std::uint64_t track_alias;
686  std::uint64_t group_id;
687  std::optional<std::uint64_t>
689 
691  std::optional<std::uint8_t> publisher_priority;
692 
700  template<class StreamBufferType>
701  friend bool operator>>(StreamBufferType& buffer, StreamHeaderSubGroup& msg);
702 
703  private:
704  uint64_t current_pos{ 0 };
705  bool parse_completed{ false };
706  };
707 
715  bool operator>>(Bytes& buffer, StreamHeaderSubGroup& msg);
716 
725 
728  {
729  std::uint64_t object_delta;
730 
732  uint64_t payload_len{ 0 };
733 
736  std::optional<Extensions> extensions;
737  std::optional<Extensions> immutable_extensions;
738 
741 
743  std::optional<StreamHeaderProperties> properties{};
744 
753  template<class StreamBufferType>
754  friend bool operator>>(StreamBufferType& buffer, StreamSubGroupObject& msg);
755 
756  private:
757  std::optional<std::size_t> extension_headers_length;
758  std::size_t extension_bytes_left{ 0 };
759  std::optional<uint64_t> current_tag{};
760  std::uint64_t prev_extension_type{ 0 };
761  uint64_t current_pos{ 0 };
762  bool parse_completed{ false };
763  };
764 
772  bool operator>>(Bytes& buffer, StreamSubGroupObject& msg);
773 
782 
783 } // end of namespace quicr::_messages
Fetch data-plane (de)serializer.
Definition: message_serialisation.h:497
FetchObject Encode(const ObjectHeaders &headers, std::uint8_t priority, BytesSpan payload)
FetchObjectSerializationState(GroupOrder group_order) noexcept
Definition: message_serialisation.h:500
std::optional< ResolvedFetchObject > Decode(FetchObject &&object)
Definition: ctrl_message_types.h:38
bool ParseExtensions(StreamBufferType &buffer, std::optional< std::size_t > &extension_headers_length, std::optional< Extensions > &extensions, std::optional< Extensions > &immutable_extensions, std::size_t &extension_bytes_remaining, std::optional< std::uint64_t > &current_header, std::uint64_t &prev_extension_type)
SubgroupIdType
Definition: message_serialisation.h:112
@ kSetFromFirstObject
ID comes from the first object and is omitted here.
@ kReserved
Reserved and rejected.
@ kIsZero
ID is zero and omitted from the wire.
@ kExplicit
ID is explicitly serialized.
void SerializeExtensions(Bytes &buffer, const std::optional< Extensions > &extensions, const std::optional< Extensions > &immutable_extensions)
Bytes & operator<<(Bytes &buffer, const Bytes &bytes)
DatagramStatusType
Definition: message_serialisation.h:95
@ kNoExtensions
Status datagram without extensions.
@ kWithExtensions
Status datagram with extensions.
StreamMessageType
Definition: message_serialisation.h:314
@ kFetchHeader
Fetch data stream.
@ kSubgroupHeader
Subgroup object stream.
BytesSpan operator>>(BytesSpan buffer, Bytes &value)
DatagramHeaderType
Definition: message_serialisation.h:80
@ kEndOfGroupWithExtensionsNoObjectId
End-of-group payload with implicit zero ID and extensions.
@ kEndOfGroupNoExtensionsObjectId
End-of-group payload with explicit object ID.
@ kNotEndOfGroupWithExtensionsObjectId
Payload, explicit object ID and extensions.
@ kNotEndOfGroupNoExtensionsObjectId
Payload, explicit object ID, no extensions.
@ kEndOfGroupWithExtensionsObjectId
End-of-group payload with extensions.
@ kNotEndOfGroupWithExtensionsNoObjectId
Payload with implicit zero ID and extensions.
@ kNotEndOfGroupNoExtensionsNoObjectId
Payload with implicit zero object ID.
@ kEndOfGroupNoExtensionsNoObjectId
End-of-group payload with implicit zero ID.
GroupOrder
Requested group traversal order.
Definition: ctrl_message_types.h:532
FetchHeaderType
Definition: message_serialisation.h:104
@ kFetchHeader
FETCH stream header.
std::vector< Byte > Bytes
Owning contiguous byte buffer.
Definition: bytes.h:18
std::span< const Byte > BytesSpan
Non-owning, read-only view of contiguous bytes.
Definition: bytes.h:21
ObjectStatus
Status of object as reported by the publisher.
Definition: object.h:35
std::map< uint64_t, std::vector< std::vector< uint8_t > >> Extensions
Definition: object.h:18
Object headers struct.
Definition: object.h:49
Definition: message_serialisation.h:218
static constexpr std::uint8_t kEndOfGroupBit
End-of-group bit.
Definition: message_serialisation.h:226
const bool status
Whether this is a status datagram rather than payload.
Definition: message_serialisation.h:223
static constexpr std::uint8_t kStatusBit
Status-datagram bit.
Definition: message_serialisation.h:229
static constexpr std::uint8_t kExtensionsBit
Extensions-present bit.
Definition: message_serialisation.h:225
const bool zero_object_id
Whether object ID is implicitly zero and omitted.
Definition: message_serialisation.h:221
const bool extensions
Whether an extension block is present.
Definition: message_serialisation.h:219
const bool default_priority
Whether priority is inherited and omitted.
Definition: message_serialisation.h:222
constexpr DatagramHeaderProperties(const std::uint8_t type)
Definition: message_serialisation.h:235
const bool end_of_group
Whether this payload object ends its group.
Definition: message_serialisation.h:220
static constexpr std::uint8_t kZeroObjectIdBit
Implicit-zero-object-ID bit.
Definition: message_serialisation.h:227
constexpr std::uint8_t GetType() const noexcept
Definition: message_serialisation.h:272
constexpr DatagramHeaderProperties(const bool extensions, const bool end_of_group, const bool zero_object_id, const bool default_priority, const bool status) noexcept
Definition: message_serialisation.h:255
static constexpr std::uint8_t kDefaultPriorityBit
Inherited-priority bit.
Definition: message_serialisation.h:228
static constexpr bool IsValid(const std::uint8_t type) noexcept
Definition: message_serialisation.h:298
Header opening a fetch data stream.
Definition: message_serialisation.h:338
uint64_t request_id
Request identifier associated with the fetch.
Definition: message_serialisation.h:341
FetchHeaderType type
Wire type; defaults to kFetchHeader.
Definition: message_serialisation.h:340
friend bool operator>>(StreamBufferType &buffer, FetchHeader &msg)
One wire-level object or end-of-range marker on a fetch stream.
Definition: message_serialisation.h:443
friend bool operator>>(StreamBufferType &buffer, FetchObject &msg)
std::optional< std::uint64_t > group_id_delta
Absolute first group ID or later group delta, as selected by flags.
Definition: message_serialisation.h:447
std::optional< Extensions > immutable_extensions
Immutable extensions extracted from the immutable container.
Definition: message_serialisation.h:458
std::optional< std::uint8_t > publisher_priority
Explicit publisher priority when the priority-present bit is set.
Definition: message_serialisation.h:455
std::optional< std::uint64_t > object_id_delta
Absolute first/new-group object ID or same-group object delta.
Definition: message_serialisation.h:452
std::optional< FetchSerializationProperties > properties
Parsed serialization flags; required for encoding and resolution.
Definition: message_serialisation.h:445
std::optional< Extensions > extensions
Mutable object extensions.
Definition: message_serialisation.h:456
std::optional< std::uint64_t > subgroup_id
Explicit subgroup ID when the selected mode requires one.
Definition: message_serialisation.h:450
Bytes payload
Owned payload bytes.
Definition: message_serialisation.h:464
Fetch data-plane serialization flag.
Definition: message_serialisation.h:378
static constexpr std::uint8_t kPropertiesBit
Extensions-field bit.
Definition: message_serialisation.h:409
SubgroupIdMode
Encoding used to reconstruct a normal stream object's subgroup ID.
Definition: message_serialisation.h:388
static constexpr std::uint8_t kSubgroupMask
Subgroup mode mask.
Definition: message_serialisation.h:405
bool object_id_delta_present
Whether an object-ID delta/absolute field follows.
Definition: message_serialisation.h:399
std::uint64_t GetType() const noexcept
static constexpr std::uint8_t kDatagramBit
Datagram-forwarding bit.
Definition: message_serialisation.h:410
bool priority_present
Whether publisher priority follows.
Definition: message_serialisation.h:401
static constexpr std::uint64_t kEndOfUnknownRange
End-of-unknown-range marker value.
Definition: message_serialisation.h:412
bool properties_present
Whether an extension block follows.
Definition: message_serialisation.h:402
std::optional< EndOfRange > end_of_range
End-of-range marker, or absent for a normal object.
Definition: message_serialisation.h:395
FetchSerializationProperties(SubgroupIdMode subgroup_id_mode, bool object_id_delta_present, bool group_id_delta_present, bool priority_present, bool properties_present, bool datagram) noexcept
static constexpr std::uint8_t kGroupIdDeltaBit
Group-ID-field bit.
Definition: message_serialisation.h:407
bool group_id_delta_present
Whether a group-ID delta/absolute field follows.
Definition: message_serialisation.h:400
std::optional< SubgroupIdMode > subgroup_id_mode
Subgroup mode for stream objects; absent for datagrams and end markers.
Definition: message_serialisation.h:398
EndOfRange
Special FETCH range-termination condition.
Definition: message_serialisation.h:381
@ kNonExistent
End location is known not to exist.
@ kUnknown
Existence of the end location is unknown.
static constexpr std::uint64_t kEndOfNonExistentRange
End-of-nonexistent-range marker value.
Definition: message_serialisation.h:411
static constexpr std::uint8_t kPriorityBit
Publisher-priority-field bit.
Definition: message_serialisation.h:408
static constexpr std::uint8_t kObjectIdDeltaBit
Object-ID-field bit.
Definition: message_serialisation.h:406
bool datagram
Whether the resolved object used datagram forwarding.
Definition: message_serialisation.h:403
Object-status datagram without payload.
Definition: message_serialisation.h:628
std::uint64_t group_id
Group identifier.
Definition: message_serialisation.h:630
friend bool operator>>(StreamBufferType &buffer, ObjectDatagramStatus &msg)
std::uint64_t track_alias
Track alias.
Definition: message_serialisation.h:629
std::uint64_t GetType() const
Definition: message_serialisation.h:651
std::optional< Extensions > immutable_extensions
Immutable extensions.
Definition: message_serialisation.h:637
std::optional< std::uint8_t > publisher_priority
Explicit publisher priority, or absent to inherit the default.
Definition: message_serialisation.h:635
ObjectStatus status
Reported object status encoded as UintVar.
Definition: message_serialisation.h:638
std::uint64_t object_id
Object identifier; omitted when zero.
Definition: message_serialisation.h:633
std::optional< Extensions > extensions
Mutable extensions.
Definition: message_serialisation.h:636
Payload-bearing object datagram.
Definition: message_serialisation.h:559
std::uint64_t track_alias
Track alias encoded as UintVar.
Definition: message_serialisation.h:560
DatagramHeaderProperties GetProperties() const
Definition: message_serialisation.h:599
ObjectStatus object_status
Not serialized by ObjectDatagram; payload datagrams imply available data.
Definition: message_serialisation.h:573
std::uint8_t GetType() const
Definition: message_serialisation.h:593
std::optional< std::uint8_t > priority
Explicit publisher priority, or absent to inherit the track default.
Definition: message_serialisation.h:565
std::uint64_t group_id
Group identifier encoded as UintVar.
Definition: message_serialisation.h:561
std::optional< Extensions > immutable_extensions
Immutable extensions nested in the immutable container.
Definition: message_serialisation.h:567
friend bool operator>>(StreamBufferType &buffer, ObjectDatagram &msg)
Bytes payload
Bytes occupying the remainder of this datagram.
Definition: message_serialisation.h:574
std::uint64_t object_id
Object identifier; omitted on wire when zero.
Definition: message_serialisation.h:564
std::optional< Extensions > extensions
Mutable object extensions.
Definition: message_serialisation.h:566
Exception indicating that received or constructed data violates the MoQ protocol.
Definition: ctrl_message_types.h:71
Fetch object after stateful delta resolution.
Definition: message_serialisation.h:488
ObjectHeaders headers
Absolute headers reconstructed from this object and prior state.
Definition: message_serialisation.h:489
Bytes payload
Owned payload moved from the wire object.
Definition: message_serialisation.h:492
Definition: message_serialisation.h:123
const SubgroupIdType subgroup_id_mode
Subgroup-ID omission/serialization mode.
Definition: message_serialisation.h:125
static constexpr std::uint8_t kExtensionsBit
Bit indicating extension lengths are present.
Definition: message_serialisation.h:130
constexpr std::uint64_t GetType() const
Definition: message_serialisation.h:186
static constexpr std::uint8_t kSubgroupIdMask
Two-bit subgroup-ID mode mask.
Definition: message_serialisation.h:131
static constexpr std::uint8_t kTypeBit
Required subgroup-stream type bit.
Definition: message_serialisation.h:135
const bool first_object
Whether this is the subgroup's original first object rather than a resumed stream.
Definition: message_serialisation.h:128
constexpr StreamHeaderProperties(const bool extensions, const SubgroupIdType subgroup_id_mode, const bool end_of_group, const bool default_priority, const bool first_object)
Definition: message_serialisation.h:169
static constexpr std::uint8_t kFirstObjectBit
Bit indicating the original first object.
Definition: message_serialisation.h:137
const bool extensions
Whether every subgroup object carries an extension-block length, possibly zero.
Definition: message_serialisation.h:124
static constexpr bool IsValid(const std::uint64_t type) noexcept
Definition: message_serialisation.h:207
static constexpr std::uint64_t kAllowedBitsMask
Mask of all recognized stream-header bits.
Definition: message_serialisation.h:140
const bool default_priority
Whether priority is omitted and inherited from the publisher.
Definition: message_serialisation.h:127
const bool end_of_group
Whether this subgroup contains the largest object in its group.
Definition: message_serialisation.h:126
constexpr StreamHeaderProperties(const std::uint64_t type)
Definition: message_serialisation.h:148
static constexpr std::uint8_t kEndOfGroupBit
Bit indicating end of group.
Definition: message_serialisation.h:132
static constexpr std::uint8_t kDefaultPriorityBit
Bit indicating inherited publisher priority.
Definition: message_serialisation.h:136
Header opening a subgroup object stream.
Definition: message_serialisation.h:682
std::optional< std::uint8_t > publisher_priority
Explicit priority, or absent when default_priority is set.
Definition: message_serialisation.h:691
std::optional< std::uint64_t > subgroup_id
Explicit/derived subgroup ID, or absent for set-from-first-object mode.
Definition: message_serialisation.h:688
std::uint64_t group_id
Group identifier.
Definition: message_serialisation.h:686
std::uint64_t track_alias
Track alias.
Definition: message_serialisation.h:685
friend bool operator>>(StreamBufferType &buffer, StreamHeaderSubGroup &msg)
std::optional< StreamHeaderProperties > properties
Parsed/selected stream-header flags; required for serialization.
Definition: message_serialisation.h:684
One object record carried after a StreamHeaderSubGroup.
Definition: message_serialisation.h:728
Bytes payload
Owned payload bytes.
Definition: message_serialisation.h:740
std::uint64_t object_delta
Object-ID delta from the stream's reference object.
Definition: message_serialisation.h:729
std::optional< Extensions > immutable_extensions
Immutable extensions.
Definition: message_serialisation.h:737
ObjectStatus object_status
Status serialized only when payload is empty.
Definition: message_serialisation.h:735
std::optional< Extensions > extensions
Mutable extensions.
Definition: message_serialisation.h:736
friend bool operator>>(StreamBufferType &buffer, StreamSubGroupObject &msg)