Skip to main content

sacd_rs/
lib.rs

1pub mod sacd_reader;
2pub mod scarletbook;
3
4pub mod sacd_ripper {
5    include!(concat!(env!("OUT_DIR"), "/libsacd.sacd_ripper.rs"));
6}
7
8#[cfg(test)]
9mod tests {
10    use indicatif::{ProgressBar, ProgressStyle};
11    use std::net::{IpAddr, Ipv4Addr};
12    use std::path::Path;
13
14    use super::*;
15
16    fn init() {
17        let _ = env_logger::builder().is_test(true).try_init();
18    }
19
20    #[test]
21    fn test_dump_iso() {
22        init();
23        let mut handle = sacd_reader::NetReader::open_network_reader(
24            IpAddr::V4(Ipv4Addr::new(192, 168, 1, 130)),
25            2002,
26        )
27        .expect("should init");
28
29        let pb = ProgressBar::new(0);
30        pb.set_style(
31            ProgressStyle::default_bar()
32                .template("{spinner:.green} [{bar:40.cyan/blue}] {pos}/{len} sectors ({percent}%)")
33                .unwrap()
34                .progress_chars("#>-"),
35        );
36
37        handle
38            .dump_iso(
39                Path::new("/var/home/bleggett/TEST.iso"),
40                scarletbook::consts::SACD_LSN_SIZE,
41                Some(|current, total| {
42                    if pb.length().unwrap_or(0) == 0 {
43                        pb.set_length(total as u64);
44                    }
45                    pb.set_position(current as u64);
46                }),
47            )
48            .expect("write success");
49        pb.finish_with_message("Complete!");
50    }
51}