Skip to main content

rosbag2_rs/
metadata.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(Serialize, Deserialize)]
5pub struct StartingTime {
6    pub nanoseconds_since_epoch: i64,
7}
8
9#[derive(Serialize, Deserialize)]
10pub struct BagDuration {
11    pub nanoseconds: i64,
12}
13
14#[derive(Serialize, Deserialize)]
15pub struct TopicMetadata {
16    pub name: String,
17
18    #[serde(rename = "type")]
19    pub type_: String, // `type` is a reserved keyword in Rust
20    pub serialization_format: String,
21    pub offered_qos_profiles: String,
22    // pub type_description_hash: String // TODO: humble rosbag2 does not need this field
23}
24
25#[derive(Serialize, Deserialize)]
26pub struct TopicWithMessageCount {
27    pub message_count: i32,
28    pub topic_metadata: TopicMetadata,
29}
30
31#[derive(Serialize, Deserialize)]
32pub struct FileInformation {
33    pub path: String,
34    pub starting_time: StartingTime,
35    pub duration: BagDuration,
36    pub message_count: i32,
37}
38
39#[derive(Serialize, Deserialize)]
40pub struct Metadata {
41    pub version: i32,
42    pub storage_identifier: String,
43    pub relative_file_paths: Vec<String>,
44    pub starting_time: StartingTime,
45    pub duration: BagDuration,
46    pub message_count: i32,
47    pub compression_format: String,
48    pub compression_mode: String,
49    pub topics_with_message_count: Vec<TopicWithMessageCount>,
50    pub files: Vec<FileInformation>,
51    pub custom_data: HashMap<String, String>,
52    pub ros_distro: String,
53}
54
55#[derive(Serialize, Deserialize)]
56pub struct BagFileInfo {
57    pub rosbag2_bagfile_information: Metadata,
58}