sbp 6.4.0

Rust native implementation of SBP (Swift Binary Protocol) for communicating with devices made by Swift Navigation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
// Copyright (C) 2015-2021 Swift Navigation Inc.
// Contact: https://support.swiftnav.com
//
// This source is subject to the license found in the file 'LICENSE' which must
// be distributed together with this source. All other rights reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

//****************************************************************************
// Automatically generated from yaml/swiftnav/sbp/profiling.yaml
// with generate.py. Please do not hand edit!
//****************************************************************************/
//! Standardized profiling messages from Swift Navigation devices.
pub use msg_measurement_point::MsgMeasurementPoint;
pub use msg_profiling_queue_info::MsgProfilingQueueInfo;
pub use msg_profiling_resource_counter::MsgProfilingResourceCounter;
pub use msg_profiling_system_info::MsgProfilingSystemInfo;
pub use msg_profiling_thread_info::MsgProfilingThreadInfo;
pub use queue_info::QueueInfo;
pub use resource_bucket::ResourceBucket;

pub mod msg_measurement_point {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Profiling Measurement Point
    ///
    /// Tracks execution time of certain code paths in specially built products.
    /// This message should only be expected and processed on the direction of
    /// Swift's engineering teams.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgMeasurementPoint {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Total time spent in measurement point (microseconds)
        #[cfg_attr(feature = "serde", serde(rename = "total_time"))]
        pub total_time: u32,
        /// Number of times measurement point has executed
        #[cfg_attr(feature = "serde", serde(rename = "num_executions"))]
        pub num_executions: u16,
        /// Minimum execution time (microseconds)
        #[cfg_attr(feature = "serde", serde(rename = "min"))]
        pub min: u32,
        /// Maximum execution time (microseconds)
        #[cfg_attr(feature = "serde", serde(rename = "max"))]
        pub max: u32,
        /// Return address
        #[cfg_attr(feature = "serde", serde(rename = "return_addr"))]
        pub return_addr: u64,
        /// Unique ID
        #[cfg_attr(feature = "serde", serde(rename = "id"))]
        pub id: u64,
        /// CPU slice time (milliseconds)
        #[cfg_attr(feature = "serde", serde(rename = "slice_time"))]
        pub slice_time: u64,
        /// Line number
        #[cfg_attr(feature = "serde", serde(rename = "line"))]
        pub line: u16,
        /// Function name
        #[cfg_attr(feature = "serde", serde(rename = "func"))]
        pub func: SbpString<Vec<u8>, NullTerminated>,
    }

    impl ConcreteMessage for MsgMeasurementPoint {
        const MESSAGE_TYPE: u16 = 52992;
        const MESSAGE_NAME: &'static str = "MSG_MEASUREMENT_POINT";
    }

    impl SbpMessage for MsgMeasurementPoint {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgMeasurementPoint {
        fn friendly_name() -> &'static str {
            "MEAS POINT"
        }
    }

    impl TryFrom<Sbp> for MsgMeasurementPoint {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgMeasurementPoint(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgMeasurementPoint {
        const MIN_LEN: usize = <u32 as WireFormat>::MIN_LEN
            + <u16 as WireFormat>::MIN_LEN
            + <u32 as WireFormat>::MIN_LEN
            + <u32 as WireFormat>::MIN_LEN
            + <u64 as WireFormat>::MIN_LEN
            + <u64 as WireFormat>::MIN_LEN
            + <u64 as WireFormat>::MIN_LEN
            + <u16 as WireFormat>::MIN_LEN
            + <SbpString<Vec<u8>, NullTerminated> as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.total_time)
                + WireFormat::len(&self.num_executions)
                + WireFormat::len(&self.min)
                + WireFormat::len(&self.max)
                + WireFormat::len(&self.return_addr)
                + WireFormat::len(&self.id)
                + WireFormat::len(&self.slice_time)
                + WireFormat::len(&self.line)
                + WireFormat::len(&self.func)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.total_time, buf);
            WireFormat::write(&self.num_executions, buf);
            WireFormat::write(&self.min, buf);
            WireFormat::write(&self.max, buf);
            WireFormat::write(&self.return_addr, buf);
            WireFormat::write(&self.id, buf);
            WireFormat::write(&self.slice_time, buf);
            WireFormat::write(&self.line, buf);
            WireFormat::write(&self.func, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgMeasurementPoint {
                sender_id: None,
                total_time: WireFormat::parse_unchecked(buf),
                num_executions: WireFormat::parse_unchecked(buf),
                min: WireFormat::parse_unchecked(buf),
                max: WireFormat::parse_unchecked(buf),
                return_addr: WireFormat::parse_unchecked(buf),
                id: WireFormat::parse_unchecked(buf),
                slice_time: WireFormat::parse_unchecked(buf),
                line: WireFormat::parse_unchecked(buf),
                func: WireFormat::parse_unchecked(buf),
            }
        }
    }
}

pub mod msg_profiling_queue_info {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Messaging Queue Profiling Information
    ///
    /// Contains profiling information for swiftlet internal message queues. Refer
    /// to product documentation to understand the meaning and values in this
    /// message.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgProfilingQueueInfo {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Message number in complete sequence
        #[cfg_attr(feature = "serde", serde(rename = "seq_no"))]
        pub seq_no: u8,
        /// Length of message sequence
        #[cfg_attr(feature = "serde", serde(rename = "seq_len"))]
        pub seq_len: u8,
        /// List of queue stats
        #[cfg_attr(feature = "serde", serde(rename = "queues"))]
        pub queues: Vec<QueueInfo>,
    }

    impl ConcreteMessage for MsgProfilingQueueInfo {
        const MESSAGE_TYPE: u16 = 52996;
        const MESSAGE_NAME: &'static str = "MSG_PROFILING_QUEUE_INFO";
    }

    impl SbpMessage for MsgProfilingQueueInfo {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgProfilingQueueInfo {
        fn friendly_name() -> &'static str {
            "PROFILING QUEUE INFO"
        }
    }

    impl TryFrom<Sbp> for MsgProfilingQueueInfo {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgProfilingQueueInfo(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgProfilingQueueInfo {
        const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <Vec<QueueInfo> as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.seq_no)
                + WireFormat::len(&self.seq_len)
                + WireFormat::len(&self.queues)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.seq_no, buf);
            WireFormat::write(&self.seq_len, buf);
            WireFormat::write(&self.queues, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgProfilingQueueInfo {
                sender_id: None,
                seq_no: WireFormat::parse_unchecked(buf),
                seq_len: WireFormat::parse_unchecked(buf),
                queues: WireFormat::parse_unchecked(buf),
            }
        }
    }
}

pub mod msg_profiling_resource_counter {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Information about resource buckets
    ///
    /// Information about resource buckets. Refer to product documentation to
    /// understand the meaning and values in this message.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgProfilingResourceCounter {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Message number in complete sequence
        #[cfg_attr(feature = "serde", serde(rename = "seq_no"))]
        pub seq_no: u8,
        /// Length of message sequence
        #[cfg_attr(feature = "serde", serde(rename = "seq_len"))]
        pub seq_len: u8,
        /// List of resource buckets
        #[cfg_attr(feature = "serde", serde(rename = "buckets"))]
        pub buckets: Vec<ResourceBucket>,
    }

    impl ConcreteMessage for MsgProfilingResourceCounter {
        const MESSAGE_TYPE: u16 = 52995;
        const MESSAGE_NAME: &'static str = "MSG_PROFILING_RESOURCE_COUNTER";
    }

    impl SbpMessage for MsgProfilingResourceCounter {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgProfilingResourceCounter {
        fn friendly_name() -> &'static str {
            "PROFILING RESOURCE COUNTER"
        }
    }

    impl TryFrom<Sbp> for MsgProfilingResourceCounter {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgProfilingResourceCounter(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgProfilingResourceCounter {
        const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <Vec<ResourceBucket> as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.seq_no)
                + WireFormat::len(&self.seq_len)
                + WireFormat::len(&self.buckets)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.seq_no, buf);
            WireFormat::write(&self.seq_len, buf);
            WireFormat::write(&self.buckets, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgProfilingResourceCounter {
                sender_id: None,
                seq_no: WireFormat::parse_unchecked(buf),
                seq_len: WireFormat::parse_unchecked(buf),
                buckets: WireFormat::parse_unchecked(buf),
            }
        }
    }
}

pub mod msg_profiling_system_info {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// System Profiling Information
    ///
    /// Contains basic information about system resource usage. System is defined
    /// in terms of the source of this message and may vary from sender to sender.
    /// Refer to product documentation to understand the exact scope and meaning
    /// of this message.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgProfilingSystemInfo {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Total cpu time in microseconds consumed by this system
        #[cfg_attr(feature = "serde", serde(rename = "total_cpu_time"))]
        pub total_cpu_time: u64,
        /// Age of the producing system in microseconds
        #[cfg_attr(feature = "serde", serde(rename = "age"))]
        pub age: u64,
        /// Number of threads being tracked by this system
        #[cfg_attr(feature = "serde", serde(rename = "n_threads"))]
        pub n_threads: u8,
        /// Number of bytes allocated on the heap
        #[cfg_attr(feature = "serde", serde(rename = "heap_usage"))]
        pub heap_usage: u32,
    }

    impl ConcreteMessage for MsgProfilingSystemInfo {
        const MESSAGE_TYPE: u16 = 52993;
        const MESSAGE_NAME: &'static str = "MSG_PROFILING_SYSTEM_INFO";
    }

    impl SbpMessage for MsgProfilingSystemInfo {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgProfilingSystemInfo {
        fn friendly_name() -> &'static str {
            "PROFILING SYSTEM INFO"
        }
    }

    impl TryFrom<Sbp> for MsgProfilingSystemInfo {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgProfilingSystemInfo(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgProfilingSystemInfo {
        const MIN_LEN: usize = <u64 as WireFormat>::MIN_LEN
            + <u64 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u32 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.total_cpu_time)
                + WireFormat::len(&self.age)
                + WireFormat::len(&self.n_threads)
                + WireFormat::len(&self.heap_usage)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.total_cpu_time, buf);
            WireFormat::write(&self.age, buf);
            WireFormat::write(&self.n_threads, buf);
            WireFormat::write(&self.heap_usage, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgProfilingSystemInfo {
                sender_id: None,
                total_cpu_time: WireFormat::parse_unchecked(buf),
                age: WireFormat::parse_unchecked(buf),
                n_threads: WireFormat::parse_unchecked(buf),
                heap_usage: WireFormat::parse_unchecked(buf),
            }
        }
    }
}

pub mod msg_profiling_thread_info {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Thread Profiling Information
    ///
    /// Contains profiling information related to a single thread being tracked by
    /// the producing system. Refer to product documentation to understand the
    /// exact scope and meaning of this message.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgProfilingThreadInfo {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// Total cpu time in microseconds consumed by this thread
        #[cfg_attr(feature = "serde", serde(rename = "total_cpu_time"))]
        pub total_cpu_time: u64,
        /// Age of the thread in microseconds
        #[cfg_attr(feature = "serde", serde(rename = "age"))]
        pub age: u64,
        /// Thread state
        #[cfg_attr(feature = "serde", serde(rename = "state"))]
        pub state: u8,
        /// Stack size in bytes
        #[cfg_attr(feature = "serde", serde(rename = "stack_size"))]
        pub stack_size: u32,
        /// Stack high water usage in bytes
        #[cfg_attr(feature = "serde", serde(rename = "stack_usage"))]
        pub stack_usage: u32,
        /// Thread name
        #[cfg_attr(feature = "serde", serde(rename = "name"))]
        pub name: SbpString<Vec<u8>, NullTerminated>,
    }

    impl MsgProfilingThreadInfo {
        /// Gets the [ThreadState][self::ThreadState] stored in the `state` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `ThreadState` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `ThreadState` were added.
        pub fn thread_state(&self) -> Result<ThreadState, u8> {
            get_bit_range!(self.state, u8, u8, 1, 0).try_into()
        }

        /// Set the bitrange corresponding to the [ThreadState][ThreadState] of the `state` bitfield.
        pub fn set_thread_state(&mut self, thread_state: ThreadState) {
            set_bit_range!(&mut self.state, thread_state, u8, u8, 1, 0);
        }
    }

    impl ConcreteMessage for MsgProfilingThreadInfo {
        const MESSAGE_TYPE: u16 = 52994;
        const MESSAGE_NAME: &'static str = "MSG_PROFILING_THREAD_INFO";
    }

    impl SbpMessage for MsgProfilingThreadInfo {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }
    }

    impl FriendlyName for MsgProfilingThreadInfo {
        fn friendly_name() -> &'static str {
            "PROFILING THREAD INFO"
        }
    }

    impl TryFrom<Sbp> for MsgProfilingThreadInfo {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgProfilingThreadInfo(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgProfilingThreadInfo {
        const MIN_LEN: usize = <u64 as WireFormat>::MIN_LEN
            + <u64 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u32 as WireFormat>::MIN_LEN
            + <u32 as WireFormat>::MIN_LEN
            + <SbpString<Vec<u8>, NullTerminated> as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.total_cpu_time)
                + WireFormat::len(&self.age)
                + WireFormat::len(&self.state)
                + WireFormat::len(&self.stack_size)
                + WireFormat::len(&self.stack_usage)
                + WireFormat::len(&self.name)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.total_cpu_time, buf);
            WireFormat::write(&self.age, buf);
            WireFormat::write(&self.state, buf);
            WireFormat::write(&self.stack_size, buf);
            WireFormat::write(&self.stack_usage, buf);
            WireFormat::write(&self.name, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgProfilingThreadInfo {
                sender_id: None,
                total_cpu_time: WireFormat::parse_unchecked(buf),
                age: WireFormat::parse_unchecked(buf),
                state: WireFormat::parse_unchecked(buf),
                stack_size: WireFormat::parse_unchecked(buf),
                stack_usage: WireFormat::parse_unchecked(buf),
                name: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// Thread state
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum ThreadState {
        /// External
        External = 0,

        /// Running
        Running = 1,

        /// Stopped
        Stopped = 2,
    }

    impl std::fmt::Display for ThreadState {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                ThreadState::External => f.write_str("External"),
                ThreadState::Running => f.write_str("Running"),
                ThreadState::Stopped => f.write_str("Stopped"),
            }
        }
    }

    impl TryFrom<u8> for ThreadState {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(ThreadState::External),
                1 => Ok(ThreadState::Running),
                2 => Ok(ThreadState::Stopped),
                i => Err(i),
            }
        }
    }
}

pub mod queue_info {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Stats for a single message queue type
    ///
    /// Profiling information for a single swiftlet internal message queue type.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct QueueInfo {
        /// Timestamp in milliseconds
        #[cfg_attr(feature = "serde", serde(rename = "timestamp"))]
        pub timestamp: u64,
        /// Queue type name
        #[cfg_attr(feature = "serde", serde(rename = "name"))]
        pub name: SbpString<[u8; 40], NullTerminated>,
        /// Total number of slots in the queue
        #[cfg_attr(feature = "serde", serde(rename = "size"))]
        pub size: u16,
        /// Number of slots currently in use
        #[cfg_attr(feature = "serde", serde(rename = "current_fill"))]
        pub current_fill: u16,
        /// Peak number of slots used since init
        #[cfg_attr(feature = "serde", serde(rename = "peak_fill"))]
        pub peak_fill: u16,
        /// Number of messages dropped since init
        #[cfg_attr(feature = "serde", serde(rename = "drop_count"))]
        pub drop_count: u16,
    }

    impl WireFormat for QueueInfo {
        const MIN_LEN: usize = <u64 as WireFormat>::MIN_LEN
            + <SbpString<[u8; 40], NullTerminated> as WireFormat>::MIN_LEN
            + <u16 as WireFormat>::MIN_LEN
            + <u16 as WireFormat>::MIN_LEN
            + <u16 as WireFormat>::MIN_LEN
            + <u16 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.timestamp)
                + WireFormat::len(&self.name)
                + WireFormat::len(&self.size)
                + WireFormat::len(&self.current_fill)
                + WireFormat::len(&self.peak_fill)
                + WireFormat::len(&self.drop_count)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.timestamp, buf);
            WireFormat::write(&self.name, buf);
            WireFormat::write(&self.size, buf);
            WireFormat::write(&self.current_fill, buf);
            WireFormat::write(&self.peak_fill, buf);
            WireFormat::write(&self.drop_count, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            QueueInfo {
                timestamp: WireFormat::parse_unchecked(buf),
                name: WireFormat::parse_unchecked(buf),
                size: WireFormat::parse_unchecked(buf),
                current_fill: WireFormat::parse_unchecked(buf),
                peak_fill: WireFormat::parse_unchecked(buf),
                drop_count: WireFormat::parse_unchecked(buf),
            }
        }
    }
}

pub mod resource_bucket {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// A bucket containing various resources
    ///
    /// Information about allocation of various resources grouped by buckets.
    /// Refer to product documentation to understand the meaning and values in
    /// this message.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct ResourceBucket {
        /// Bucket name
        #[cfg_attr(feature = "serde", serde(rename = "name"))]
        pub name: SbpString<[u8; 21], NullTerminated>,
        /// Number of threads
        #[cfg_attr(feature = "serde", serde(rename = "thread"))]
        pub thread: u8,
        /// Number of mutexes
        #[cfg_attr(feature = "serde", serde(rename = "mutex"))]
        pub mutex: u8,
        /// Number of condition variables
        #[cfg_attr(feature = "serde", serde(rename = "cv"))]
        pub cv: u8,
        /// Number of IO handles
        #[cfg_attr(feature = "serde", serde(rename = "io"))]
        pub io: u8,
        /// Number of bytes allocated on the heap
        #[cfg_attr(feature = "serde", serde(rename = "heap_bytes_alloc"))]
        pub heap_bytes_alloc: u32,
        /// Number of bytes freed on the heap
        #[cfg_attr(feature = "serde", serde(rename = "heap_bytes_free"))]
        pub heap_bytes_free: u32,
        /// Number of bytes written to IO handles
        #[cfg_attr(feature = "serde", serde(rename = "io_write"))]
        pub io_write: u32,
        /// Number of bytes read from IO handles
        #[cfg_attr(feature = "serde", serde(rename = "io_read"))]
        pub io_read: u32,
    }

    impl WireFormat for ResourceBucket {
        const MIN_LEN: usize = <SbpString<[u8; 21], NullTerminated> as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u32 as WireFormat>::MIN_LEN
            + <u32 as WireFormat>::MIN_LEN
            + <u32 as WireFormat>::MIN_LEN
            + <u32 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.name)
                + WireFormat::len(&self.thread)
                + WireFormat::len(&self.mutex)
                + WireFormat::len(&self.cv)
                + WireFormat::len(&self.io)
                + WireFormat::len(&self.heap_bytes_alloc)
                + WireFormat::len(&self.heap_bytes_free)
                + WireFormat::len(&self.io_write)
                + WireFormat::len(&self.io_read)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.name, buf);
            WireFormat::write(&self.thread, buf);
            WireFormat::write(&self.mutex, buf);
            WireFormat::write(&self.cv, buf);
            WireFormat::write(&self.io, buf);
            WireFormat::write(&self.heap_bytes_alloc, buf);
            WireFormat::write(&self.heap_bytes_free, buf);
            WireFormat::write(&self.io_write, buf);
            WireFormat::write(&self.io_read, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            ResourceBucket {
                name: WireFormat::parse_unchecked(buf),
                thread: WireFormat::parse_unchecked(buf),
                mutex: WireFormat::parse_unchecked(buf),
                cv: WireFormat::parse_unchecked(buf),
                io: WireFormat::parse_unchecked(buf),
                heap_bytes_alloc: WireFormat::parse_unchecked(buf),
                heap_bytes_free: WireFormat::parse_unchecked(buf),
                io_write: WireFormat::parse_unchecked(buf),
                io_read: WireFormat::parse_unchecked(buf),
            }
        }
    }
}