20struct Topic::PackedDataHeader
25 uint32_t topic_name_crc32;
27 uint8_t timestamp_us_raw[6];
30 uint8_t pack_header_crc8;
36 void SetDataLen(uint32_t len);
42 uint32_t GetDataLen()
const;
48 void SetTimestamp(MicrosecondTimestamp timestamp);
54 MicrosecondTimestamp GetTimestamp()
const;
57static_assert(
sizeof(Topic::PackedDataHeader) == 16);
58static_assert(offsetof(Topic::PackedDataHeader, prefix) == 0);
59static_assert(offsetof(Topic::PackedDataHeader, data_len_raw) == 1);
60static_assert(offsetof(Topic::PackedDataHeader, topic_name_crc32) == 4);
61static_assert(offsetof(Topic::PackedDataHeader, timestamp_us_raw) == 8);
62static_assert(offsetof(Topic::PackedDataHeader, version) == 14);
63static_assert(offsetof(Topic::PackedDataHeader, pack_header_crc8) == 15);
74template <
typename Data>
75class Topic::PackedData
77 static_assert(TopicPayload<Data>);
86 PackedDataHeader header_;
87 uint8_t data_[
sizeof(Data)];
97 MicrosecondTimestamp GetTimestamp()
const {
return raw.header_.GetTimestamp(); }
111template <
typename Data>
116 ASSERT(
block_ !=
nullptr);
118 ASSERT(
block_->
data_.payload_size ==
sizeof(Data));
只读原始数据视图 / Immutable raw data view
微秒时间戳 / Microsecond timestamp
Data data_
存储的数据 (Stored data).
可写原始数据视图 / Mutable raw data view
static void PackBytes(uint32_t topic_name_crc32, RawData buffer, MicrosecondTimestamp timestamp, ConstRawData data)
将一段 payload 字节和 topic 元数据拼成 packet / Pack one payload byte range together with topic metadata into on...
ErrorCode PackData(const Data &data, PackedData< Data > &packet)
将一个精确类型消息打包成 packet / Pack one exact-typed message into one packet using the topic's runtime contract...
static ID GetID()
获取类型的唯一标识符 / Get a unique identifier for type T
@ OK
操作成功 | Operation successful
constexpr void CheckTopicPayload()
在模板上下文里断言 payload 类型满足 topic 契约 / Assert in template context that one payload type satisfies the topi...