#grpc #client #api #function #build #interface #github

bin+lib coreemu

Rust client library for gRPC interface of coreemu https://github.com/coreemu/core

6 releases

0.1.5 Sep 14, 2022
0.1.4 Jul 20, 2022
0.1.3 Oct 15, 2021
0.1.2 Jul 14, 2021

#144 in #grpc

43 downloads per month

MIT/Apache

4MB
59K SLoC

Python 33K SLoC // 0.2% comments TCL 21K SLoC // 0.2% comments C 3K SLoC // 0.1% comments Shell 545 SLoC // 0.2% comments Automake 326 SLoC // 0.2% comments Rust 261 SLoC // 0.1% comments Bitbake 218 SLoC // 0.6% comments Forge Config 8 SLoC

Contains (obscure autoconf code, 9KB) core/configure.ac

coreemu-rs

This is a client library to use the gRPC interface of coreemu from rust. All gRPC functions are exposed in their raw form as produced by tonic-build but there are is also a thin (and incomplete) wrapper to make the API a bit more usable.

The main branch of this repository and the version published on crates.io is build for coreemu 7.5.2, there is a branch coreemu8 which has support for the changed gRPC interface.

To use this library add the following dependency to your Cargo.toml:

coreemu = "*"

or just call:

cargo add coreemu

Example

The following example connects to the local coreemu instance and prints all node information from the first running instance found.

use coreemu::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut client = Client::connect("http://127.0.0.1:50051").await?;

    let response = client.get_sessions().await?;

    println!("RESPONSE={:?}", response);

    let session_id = response[0].id;

    let response = client.get_session(session_id).await?.unwrap();

    for n in response.nodes {
        if n.name.starts_with("n") {
            println!("RESPONSE={:#?}", n.position.unwrap());
        }
    }
    Ok(())
}

Dependencies

~10–22MB
~282K SLoC