birdc

Crates.iobirdc
lib.rsbirdc
version0.3.0
sourcesrc
created_at2022-04-30 18:43:16.999556
updated_at2023-06-12 18:32:48.814942
descriptionLibrary to talk to the BIRD BGP server for administrative and instrumentation purposes
homepagehttps://github.com/amodm/birdc-rs
repositoryhttps://github.com/amodm/birdc-rs
max_upload_size
id578297
size150,415
Amod Malviya (amodm)

documentation

https://docs.rs/birdc

README

birdc

Current Crates.io Version Build License

Rust library to talk to the Bird BGP server for administrative and instrumentation purposes.

Documentation

Examples

use birdc::*;

// create the client
let client = Client::for_unix_socket("/run/bird/bird.ctl");

// we can either use raw protocol
async fn show_interfaces_raw(client: &Client) -> Result<()> {
    let mut connection = client.connect().await?;

    // we can either use raw protocol
    let messages = connection.send_request("show interfaces").await?;
    for message in &messages {
        println!("received message: {:?}", message);
    }
    Ok(())
}

// or we can use structured exchange
async fn show_interfaces(client: &Client) -> Result<()> {
    let mut connection = client.connect().await?;

    // let's make a semantic call now
    match connection.show_interfaces().await {
        Ok(entries) => {
            for e in &entries {
                println!("received entry: {:?}", e);
            }
        }
        Err(Error::ParseError(messages)) => {
            // we can still go through the raw response
            // even though semantic parsing failed
            for msg in &messages {
                println!("raw message: {:?}", msg);
            }
        }
        Err(e) => {
            return Err(e);
        }
    }
    Ok(())
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 22

cargo fmt