example: Add grpc client deps

This commit is contained in:
Eishun Kondoh 2018-10-10 17:45:18 +09:00
parent e8a02cdd9d
commit b9f353809d
8 changed files with 142 additions and 5 deletions

View file

@ -0,0 +1,2 @@
target
Cargo.lock

View file

@ -0,0 +1,17 @@
[package]
name = "gobgp"
version = "0.1.0"
authors = ["HansiHE <hansihe@hansihe.com>"]
[lib]
name = "gobgp"
path = "src/lib.rs"
crate-type = ["dylib"]
[package.metadata.release]
[dependencies]
rustler = { git = "https://github.com/hansihe/rustler", branch = "remove_nif_from_types"}
rustler_codegen = { git = "https://github.com/hansihe/rustler", branch = "remove_nif_from_types"}
bufstream = "0.1.2"
lazy_static = "1.0.0"

View file

@ -0,0 +1,3 @@
fn main() {
println!("cargo:rustc-link-search=native=../../vendor/libgobgp.so");
}

View file

@ -0,0 +1,40 @@
/* automatically generated by rust-bindgen */
#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
#[repr(C)]
pub struct __BindgenComplex<T> {
pub re: T,
pub im: T,
}
pub type wchar_t = ::std::os::raw::c_int;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct max_align_t {
pub __clang_max_align_nonce1: ::std::os::raw::c_longlong,
pub __bindgen_padding_0: u64,
pub __clang_max_align_nonce2: f64,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _GoString_ {
pub p: *const ::std::os::raw::c_char,
pub n: isize,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct buf {
pub value: *mut ::std::os::raw::c_char,
pub len: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct path_t {
pub nlri: buf,
pub path_attributes: *mut *mut buf,
pub path_attributes_len: ::std::os::raw::c_int,
pub path_attributes_cap: ::std::os::raw::c_int,
}

View file

@ -0,0 +1,27 @@
#![allow(bad_style, missing_copy_implementations, improper_ctypes)]
pub mod gobgp_utils;
#[macro_use] extern crate rustler;
#[macro_use] extern crate lazy_static;
use rustler::{Env, Term, NifResult, Encoder};
mod atoms {
rustler_atoms! {
atom ok;
}
}
rustler_export_nifs!(
"Elixir.EvpnRouter.GoBGP.NativeUtils",
[("get_route_family", 2, get_route_family)],
None
);
fn get_route_family<'a>(env: Env<'a>, args: &[Term<'a>]) -> NifResult<Term<'a>> {
let num1: i64 = args[0].decode()?;
let num2: i64 = args[1].decode()?;
Ok((atoms::ok(), num1 + num2).encode(env))
}