rustbag 0.1.1

A high-performance ROS 2 bag player
// Copyright 2025 Ivo Ivanov.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use anyhow::Result;
use clap::Parser;
use env_logger::Builder;
use log::LevelFilter;
mod args;
mod clock;
mod message_queue;
mod player;
mod qos;

fn main() -> Result<()> {
    let args = args::Args::parse();
    let level = match args.log_level {
        args::LogLevel::Error => LevelFilter::Error,
        args::LogLevel::Warn => LevelFilter::Warn,
        args::LogLevel::Info => LevelFilter::Info,
        args::LogLevel::Debug => LevelFilter::Debug,
        args::LogLevel::Trace => LevelFilter::Trace,
    };
    Builder::new().filter_level(level).init();
    let ctx = r2r::Context::create()?;
    let mut node = r2r::Node::create(ctx, "rustbag_player", "")?;
    let mut player = player::Player::new(args);
    player.play(&mut node)?;
    Ok(())
}