use std::io; use std::collections::HashSet; use rpki_rtr::payload::{Action, Payload, Timing}; use rpki_rtr::client::{Client, VrpError, VrpTarget}; use tokio::net::TcpStream; #[derive(Clone, Default)] pub struct Store { payload: HashSet, } impl VrpTarget for Store { type Update = Vec<(Action, Payload)>; fn start(&mut self, reset: bool) -> Self::Update { println!("Starting update (reset={})", reset); Vec::new() } fn apply( &mut self, update: Self::Update, reset: bool, _timing: Timing ) -> Result<(), VrpError> { println!("Update complete: {} entries", update.len()); if reset { self.payload.clear(); } for (action, payload)in update { match action { Action::Announce => { println!("Adding {:?}", payload); let _ = self.payload.insert(payload); } Action::Withdraw => { println!("Removing {:?}", payload); let _ = self.payload.remove(&payload); } } } Ok(()) } } #[tokio::main] async fn main() -> Result<(), io::Error> { let sock = TcpStream::connect("127.0.0.1:9001").await?; let mut client = Client::new(sock, Store::default(), None); client.run().await }