Skip to main content

dump_file/
dump_file.rs

1use mysql_replication::{Event, Result, file::BinlogFile, parser::ParserConfig};
2use std::{fs::File, io::BufReader};
3fn main() -> Result<()> {
4    let args: Vec<_> = std::env::args().collect();
5    if args.len() != 2 {
6        eprintln!("usage: cargo run -p mysql-replication --example dump_file -- BINLOG_FILE");
7        return Ok(());
8    }
9    let mut reader = BinlogFile::<_, mysql_replication::Minimal>::new(
10        BufReader::new(File::open(&args[1])?),
11        ParserConfig::default(),
12    )?;
13    let mut output = std::io::stdout().lock();
14    while let Some(event) = reader.next_event()? {
15        event.header.dump(&mut output)?;
16        event.event.dump(&mut output)?;
17    }
18    Ok(())
19}