use libratman::{
api::{default_api_bind, RatmanIpc, RatmanIpcExtV1, RatmanStreamExtV1},
tokio,
types::{LetterheadV1, Recipient},
Result,
};
#[tokio::main]
async fn main() -> Result<()> {
let ipc = RatmanIpc::start(default_api_bind()).await?;
let (addr, auth) = ipc.addr_create(Some(&"my-name".to_owned())).await?;
let peers = ipc.peers_list().await?;
let friend = peers
.first()
.expect("You need to have a friend to talk to :(");
ipc.addr_up(auth, addr).await?;
let mut stdin = tokio::io::stdin();
ipc.send_to(
auth,
LetterheadV1::send(addr, Recipient::Address(friend.addr)),
&mut stdin,
)
.await?;
Ok(())
}