use sampi::{SampiData, SampiKeyPair}; fn main() -> anyhow::Result<()> { let kp = SampiKeyPair::new(); let data = "Hello World! http://example.com ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html".to_string(); let sampi = kp.new_sampi().build(vec![ SampiData::Null, SampiData::String("User 1".to_string()), SampiData::String(data), ])?; dbg!(sampi.to_base64()); dbg!(sampi.to_bytes().len()); dbg!(&sampi.data); let reply_data = vec![ SampiData::Array32Byte(sampi.get_hash()), SampiData::String("User 2".to_string()), SampiData::String("This is a reply to the original message".to_string()), SampiData::SampiDataPair(( Box::new(SampiData::Bytes(vec![44, 44])), Box::new(SampiData::Bytes(vec![44, 44])), )), ]; let reply_sampi = kp.new_sampi().build(reply_data)?; dbg!(reply_sampi.to_base64()); dbg!(reply_sampi.to_bytes().len()); dbg!(&reply_sampi.data); for s in &[sampi, reply_sampi] { match s.data.as_slice() { [SampiData::Array32Byte(a), SampiData::String(b), SampiData::String(c)] => { println!("{:?} - {} - {}", a, b, c); } [SampiData::Null, SampiData::String(b), SampiData::String(c)] => { println!("{} - {}", b, c); } _ => println!("no match"), } } Ok(()) }