bmp-client

Crates.iobmp-client
lib.rsbmp-client
version0.1.1
sourcesrc
created_at2020-06-22 12:56:19.888226
updated_at2020-06-29 16:08:34.690279
descriptionTokio-based BMP client
homepagehttps://github.com/ccakes/bmp-client-rs
repositoryhttps://github.com/ccakes/bmp-client-rs
max_upload_size
id256720
size30,512
Cameron Daniel (ccakes)

documentation

https://docs.rs/bmp-client

README

bmp-client

This is a simple BMP (BGP Monitoring Protocol) client for Rust. The heavy lifting is done within the bmp-protocol crate, this just provides a simple wrapper with some convenience functions.

Usage

# Cargo.toml

[dependencies]
bmp-client = "^0.1"
#[tokio::main]
async fn main() {
    let mut tcp = TcpListener::bind("0.0.0.0:1790").await.unwrap();

    loop {
        let (stream, peer) = tcp.accept().await.unwrap();
        println!("Client {} connected", peer);

        tokio::spawn(async move {
            let mut client = BmpClient::new(stream);

            while let Some(message) = client.recv().await {
                match message {
                    Ok(message) => println!("Received a {} message", message.kind),
                    Err(error) => {
                        eprintln!("{}", error);
                        std::process::exit(1);
                    }
                };
            }
        });
    }
}

Contributing

Contributions are welcome, the library is still very barebones.

Commit count: 7

cargo fmt