use base64::{encode_config, URL_SAFE_NO_PAD}; use dns_stamp_parser::DnsStamp; use std::net::SocketAddr; fn main() { let a: SocketAddr = "[::1%1]:488".parse().unwrap(); println!("{:?}", a); let data = b"\x02\x07\x00\x00\x34\x3A\x00\x00\x00\x04\x3A\x34\x34\x33\xA0\x3E\x1A\x1A\x0F\x6C\ \x53\xF3\xE9\x7A\x49\x2D\x57\x08\x4B\x5B\x98\x07\x05\x9E\xE0\x57\xAB\x15\x05\x87\x6F\xD8\x3F\ \xDA\x3D\xB8\x38\xA0\x68\xA3\xEB\x01\xFA\x5F\x02\xC4\xD3\x5F\x3A\x11\xD0\x04\xCA\xF0\x8B\x22\ \x4B\xEE\xA7\xD7\x9C\x58\x8C\x7F\x13\xC8\x61\x33\x60\x2E\xA0\xEF\x47\x85\xAE\xE7\x0C\x9D\x57\ \x5F\xE7\x33\x83\x06\xD9\x37\x30\x39\x35\x35\x31\x35\x09\x53\x62\xDD\x66\xC9\x8B\x60\xBB\x2D\ \xBD\x20\x1C\x54\x36\xB6\x51\xA2\xB5\x41\x5C\x16\xCF\xD9\x6D\x1A\x97\x09\xFD\x9C\x8F\x27\xEE\ \xF7\x5C\xF9\x73\xD9\x82\xFF\xE6\x8E\x58\xF0\x1C\x64\x6E\x73\x2E\x64\x69\x67\x69\x74\x61\x6C\ \x65\x2D\x67\x65\x73\x65\x6C\x6C\x53\x63\x68\x61\x66\x74\x2E\x63\x68\x0A\x2F\x64\x6E\x73\x2D\ \x71\x75\x65\x72\x79"; let stamp_1_str = format!("sdns://{}", encode_config(data, URL_SAFE_NO_PAD)); if let Ok(stamp_1) = DnsStamp::decode(&stamp_1_str) { match stamp_1.encode() { Ok(stamp_2_str) => match DnsStamp::decode(&stamp_2_str) { Ok(stamp_2) => { if stamp_1 != stamp_2 { panic!( "Not equal: {:?} != {:?}: {} != {}", stamp_1, stamp_2, stamp_1_str, stamp_2_str ); } } Err(e) => panic!("Decode: {:?}: {}: {:?}", e, stamp_2_str, stamp_1), }, Err(e) => panic!("Encode: {:?}: {}", e, stamp_1_str), } } }