sub_converter/
lib.rs

1pub mod api;
2pub mod emit;
3pub mod error;
4pub mod formats;
5pub mod ir;
6pub mod merge;
7pub mod parse;
8pub mod template;
9
10pub use api::{InputFormat, InputItem, OutputFormat, convert, detect_format};
11pub use error::{Error, Result};
12pub use ir::*;
13pub use parse::Parser;
14
15#[cfg(test)]
16mod tests {
17    use crate::{
18        formats::{ClashConfig, SingBoxConfig},
19        template::Template,
20    };
21
22    use super::*;
23
24    #[test]
25    fn smoke_uri_to_clash_and_singbox() {
26        let uris = "trojan://pwd@a.com:443#A\nss://YWVzLTI1Ni1nY206cGFzczpQM0UjQCM=@b.com:123#B";
27        let inputs = vec![InputItem {
28            format: InputFormat::UriList,
29            content: uris.to_string(),
30        }];
31        let template = Template::Clash(ClashConfig::default());
32        let clash = convert(inputs.clone(), template).expect("clash output");
33        assert!(clash.contains("proxies"));
34
35        let template = Template::SingBox(SingBoxConfig::default());
36        let sb = convert(inputs, template).expect("sb output");
37        assert!(sb.contains("outbounds"));
38    }
39}