From 62b7a54d3f60316cf063aff22427c45add291b3d Mon Sep 17 00:00:00 2001 From: jeikabu Date: Wed, 1 Jan 2020 11:01:28 +0200 Subject: [PATCH] nng_pipe_ev to const and update bindings - Mixing of C and Rust enums is potentially undefined - rustfmt --- Cargo.toml | 2 +- README.md | 4 ++-- build.rs | 5 ++++- src/bindings.rs | 11 ++++------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1ed652e7..4601f693 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nng-sys" -version = "1.1.1-rc.2" +version = "1.2.3-rc.1" authors = ["Nathan Kent ", "Jake W "] description = "Bindings to NNG (Nanomsg-Next-Generation) aka Nanomsg2" diff --git a/README.md b/README.md index 2a1fdc92..7d09dc69 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ Rust FFI bindings to [NNG](https://github.com/nanomsg/nng): Version of this crate tracks NNG: `-rc.` (e.g. `1.1.1-rc.2`). -To use the __latest crate__ for the most recent __stable version of NNG__ (1.1.1), in `Cargo.toml`: +To use the __latest crate__ for the most recent __stable version of NNG__ (1.2.x), in `Cargo.toml`: ```toml -nng-sys = "1.1.1-rc" +nng-sys = "1.2.3-rc" ``` Requirements: diff --git a/build.rs b/build.rs index 90550b6a..9911bb79 100644 --- a/build.rs +++ b/build.rs @@ -93,10 +93,13 @@ fn build_bindgen() { // Generate `pub const NNG_UNIT_EVENTS` instead of `nng_unit_enum_NNG_UNIT_EVENTS` .prepend_enum_name(false) // Generate `pub enum ...` instead of multiple `pub const ...` - .default_enum_style(bindgen::EnumVariation::Rust { non_exhaustive: false }) + .default_enum_style(bindgen::EnumVariation::Rust { + non_exhaustive: false, + }) .constified_enum("nng_flag_enum") // NNG_ESYSERR and NNG_ETRANERR are used like flag .constified_enum("nng_errno_enum") + .constified_enum("nng_pipe_ev") .use_core() .parse_callbacks(Box::new(BindgenCallbacks::default())) // Layout tests are non-portable; 64-bit tests are "wrong" size on 32-bit and always fail. diff --git a/src/bindings.rs b/src/bindings.rs index a9388354..451518ab 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -463,13 +463,10 @@ extern "C" { arg3: *mut nng_sockaddr, ) -> ::std::os::raw::c_int; } -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum nng_pipe_ev { - NNG_PIPE_EV_ADD_PRE = 0, - NNG_PIPE_EV_ADD_POST = 1, - NNG_PIPE_EV_REM_POST = 2, -} +pub const NNG_PIPE_EV_ADD_PRE: nng_pipe_ev = 0; +pub const NNG_PIPE_EV_ADD_POST: nng_pipe_ev = 1; +pub const NNG_PIPE_EV_REM_POST: nng_pipe_ev = 2; +pub type nng_pipe_ev = u32; pub type nng_pipe_cb = ::core::option::Option< unsafe extern "C" fn(arg1: nng_pipe, arg2: nng_pipe_ev, arg3: *mut ::core::ffi::c_void), >;