Skip to content

Commit

Permalink
nng_pipe_ev to const and update bindings
Browse files Browse the repository at this point in the history
- Mixing of C and Rust enums is potentially undefined
- rustfmt
  • Loading branch information
jeikabu committed Jan 1, 2020
1 parent 9da0032 commit 62b7a54
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nng-sys"
version = "1.1.1-rc.2"
version = "1.2.3-rc.1"
authors = ["Nathan Kent <[email protected]>", "Jake W <[email protected]>"]

description = "Bindings to NNG (Nanomsg-Next-Generation) aka Nanomsg2"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Rust FFI bindings to [NNG](https://github.com/nanomsg/nng):

Version of this crate tracks NNG: `<NNG_version>-rc.<crate_version>` (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:
Expand Down
5 changes: 4 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 4 additions & 7 deletions src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
>;
Expand Down

0 comments on commit 62b7a54

Please sign in to comment.