@@ -18,7 +18,9 @@ constexpr std::size_t VersionSymbolCstrLen(std::uint8_t version) {
1818}
1919
2020using InstrumentDefMsgV2 = InstrumentDefMsg;
21+ using ErrorMsgV2 = ErrorMsg;
2122using SymbolMappingMsgV2 = SymbolMappingMsg;
23+ using SystemMsgV2 = SystemMsg;
2224
2325// DBN version 1 instrument definition.
2426struct InstrumentDefMsgV1 {
@@ -111,6 +113,21 @@ struct InstrumentDefMsgV1 {
111113static_assert (sizeof (InstrumentDefMsgV1) == 360 , " Size must match Rust" );
112114static_assert (alignof (InstrumentDefMsgV1) == 8 , " Must have 8-byte alignment" );
113115
116+ // An error message from the Live Subscription Gateway (LSG). This will never
117+ // be present in historical data.
118+ struct ErrorMsgV1 {
119+ static bool HasRType (RType rtype) { return rtype == RType::Error; }
120+
121+ ErrorMsgV2 ToV2 () const ;
122+ UnixNanos IndexTs () const { return hd.ts_event ; }
123+ const char * Err () const { return err.data (); }
124+
125+ RecordHeader hd;
126+ std::array<char , 64 > err;
127+ };
128+ static_assert (sizeof (ErrorMsgV1) == 80 , " ErrorMsg size must match Rust" );
129+ static_assert (alignof (ErrorMsgV1) == 8 , " Must have 8-byte alignment" );
130+
114131// / A symbol mapping message.
115132struct SymbolMappingMsgV1 {
116133 static bool HasRType (RType rtype) { return rtype == RType::SymbolMapping; }
@@ -130,11 +147,33 @@ struct SymbolMappingMsgV1 {
130147static_assert (sizeof (SymbolMappingMsgV1) == 80 , " Size must match Rust" );
131148static_assert (alignof (SymbolMappingMsgV1) == 8 , " Must have 8-byte alignment" );
132149
150+ struct SystemMsgV1 {
151+ static bool HasRType (RType rtype) { return rtype == RType::System; }
152+
153+ SystemMsgV2 ToV2 () const ;
154+ UnixNanos IndexTs () const { return hd.ts_event ; }
155+ const char * Msg () const { return msg.data (); }
156+ bool IsHeartbeat () const {
157+ return std::strncmp (msg.data (), " Heartbeat" , 9 ) == 0 ;
158+ }
159+
160+ RecordHeader hd;
161+ std::array<char , 64 > msg;
162+ };
163+ static_assert (sizeof (SystemMsgV1) == 80 , " SystemMsg size must match Rust" );
164+ static_assert (alignof (SystemMsgV1) == 8 , " Must have 8-byte alignment" );
165+
133166bool operator ==(const InstrumentDefMsgV1& lhs, const InstrumentDefMsgV1& rhs);
134167inline bool operator !=(const InstrumentDefMsgV1& lhs,
135168 const InstrumentDefMsgV1& rhs) {
136169 return !(lhs == rhs);
137170}
171+ inline bool operator ==(const ErrorMsgV1& lhs, const ErrorMsgV1& rhs) {
172+ return std::tie (lhs.hd , lhs.err ) == std::tie (rhs.hd , rhs.err );
173+ }
174+ inline bool operator !=(const ErrorMsgV1& lhs, const ErrorMsgV1& rhs) {
175+ return !(lhs == rhs);
176+ }
138177inline bool operator ==(const SymbolMappingMsgV1& lhs,
139178 const SymbolMappingMsgV1& rhs) {
140179 return std::tie (lhs.hd , lhs.stype_in_symbol , lhs.stype_out_symbol ,
@@ -146,10 +185,20 @@ inline bool operator!=(const SymbolMappingMsgV1& lhs,
146185 const SymbolMappingMsgV1& rhs) {
147186 return !(lhs == rhs);
148187}
188+ inline bool operator ==(const SystemMsgV1& lhs, const SystemMsgV1& rhs) {
189+ return std::tie (lhs.hd , lhs.msg ) == std::tie (rhs.hd , rhs.msg );
190+ }
191+ inline bool operator !=(const SystemMsgV1& lhs, const SystemMsgV1& rhs) {
192+ return !(lhs == rhs);
193+ }
149194std::string ToString (const InstrumentDefMsgV1& instr_def_msg);
150195std::ostream& operator <<(std::ostream& stream,
151196 const InstrumentDefMsgV1& instr_def_msg);
197+ std::string ToString (const ErrorMsgV1& err_msg);
198+ std::ostream& operator <<(std::ostream& stream, const ErrorMsgV1& err_msg);
152199std::string ToString (const SymbolMappingMsgV1& symbol_mapping_msg);
153200std::ostream& operator <<(std::ostream& stream,
154201 const SymbolMappingMsgV1& symbol_mapping_msg);
202+ std::string ToString (const SystemMsgV1& sys_msg);
203+ std::ostream& operator <<(std::ostream& stream, const SystemMsgV1& sys_msg);
155204} // namespace databento
0 commit comments