use std::env::args; use log::info; use rsbag::{Bag, Result}; fn main() -> Result<()> { color_eyre::install()?; env_logger::init(); let args: Vec<_> = args().collect(); if args.len() != 2 { eprintln!("Usage: {} ", args[0]); return Ok(()); } let bag_path = &args[1]; let mut bag = Bag::open(bag_path)?; let chunk_positions = bag .index() .chunks .iter() .map(|chunk| chunk.pos) .collect::>(); let chunk_sizes = chunk_positions .windows(2) .map(|window| { if let &[last, next] = window { next - last } else { unreachable!(); } }) .collect::>(); let mean_chunk_size = chunk_sizes.iter().map(|s| *s as f64).sum::() / (chunk_sizes.len() as f64); info!("average chunk size: {}", mean_chunk_size); let info = bag.compute_info()?; info!("bag info: {:#?}", info); Ok(()) }