Hello,
This is a, compared to last time, much more complete implementation of
Rust bindings for Libnbd. There is still no documentation and no
examples. And one does still need LLVM to build the bindings due to
[
rust-bindgen](https://github.com/rust-lang/rust-bindgen). But the
overall implementation is more or less complete, including integration
tests.
As you can see, there are 10 patches:
- The first is just a small tweek of the generator utils functions.
- The second implements the basic form of the Rust bindings.
- The third and fourth modifies generator/API.ml* a bit to enable some
of the more convenient features of the Rust bindings.
- The 5th and 6th patch implements some of those conveniences.
- The 7th and 8th implements tests for the Rust bindings as
created so far.
- The 9th patch is quite a large extention of the Rust bindings. It
implements another handle-type which makes use of rust's asynchronous
functions and the [Tokio runtime](https://tokio.rs) to make an
ergonomic and rusty asynchronous API for Libnbd.
- And the last patch implements integration tests for those asynchronous
bindings.
Please comment on anything from code to commit messages. The Rust
bindings are of course not complete with these patches. The goal is
still to get rid of the dependency on rust-bindgen and LLVM. And there
needs to be documentation and thoroughly tested examples.
Best regards,
Tage
Tage Johansson (10):
generator: Add copyright argument to `generate_header`
rust: create basic Rust bindings
generator: Add information about asynchronous handle calls
generator: Add information about the lifetime of closures
rust: Use FnOnce for callbacks which only will be used once
rust: Don't enforce 'static lifetimes on some closures
rust: Add a couple of integration tests
rust: Make it possible to run tests with Valgrind
rust: async: Create an async friendly handle type
rust: async: Add a couple of integration tests
.gitignore | 8 +
.ocamlformat | 4 +
Makefile.am | 1 +
configure.ac | 13 +
generator/API.ml | 43 +
generator/API.mli | 24 +
generator/Makefile.am | 2 +
generator/Rust.ml | 835 ++++++++++++++++++
generator/Rust.mli | 22 +
generator/generator.ml | 3 +
generator/utils.ml | 5 +-
generator/utils.mli | 3 +-
rust/Cargo.toml | 55 ++
rust/Makefile.am | 65 ++
rust/libnbd-sys/Cargo.toml | 30 +
rust/libnbd-sys/build.rs | 60 ++
rust/libnbd-sys/src/lib.rs | 24 +
rust/libnbd-sys/wrapper.h | 18 +
rust/run-tests.sh | 30 +
rust/src/async_handle.rs | 222 +++++
rust/src/error.rs | 118 +++
rust/src/handle.rs | 67 ++
rust/src/lib.rs | 32 +
rust/src/types.rs | 20 +
rust/src/utils.rs | 23 +
rust/tests/nbdkit_pattern/mod.rs | 28 +
rust/tests/test_100_handle.rs | 25 +
rust/tests/test_110_defaults.rs | 33 +
rust/tests/test_120_set_non_defaults.rs | 56 ++
rust/tests/test_130_private_data.rs | 28 +
rust/tests/test_140_explicit_close.rs | 31 +
rust/tests/test_200_connect_command.rs | 33 +
rust/tests/test_210_opt_abort.rs | 39 +
rust/tests/test_220_opt_list.rs | 85 ++
rust/tests/test_230_opt_info.rs | 124 +++
rust/tests/test_240_opt_list_meta.rs | 151 ++++
rust/tests/test_245_opt_list_meta_queries.rs | 98 ++
rust/tests/test_250_opt_set_meta.rs | 124 +++
rust/tests/test_255_opt_set_meta_queries.rs | 111 +++
rust/tests/test_300_get_size.rs | 36 +
rust/tests/test_400_pread.rs | 40 +
rust/tests/test_405_pread_structured.rs | 80 ++
rust/tests/test_410_pwrite.rs | 62 ++
rust/tests/test_460_block_status.rs | 96 ++
rust/tests/test_620_stats.rs | 76 ++
rust/tests/test_async_100_handle.rs | 25 +
rust/tests/test_async_200_connect_command.rs | 34 +
rust/tests/test_async_210_opt_abort.rs | 40 +
rust/tests/test_async_220_opt_list.rs | 86 ++
rust/tests/test_async_230_opt_info.rs | 126 +++
rust/tests/test_async_235memleak.rs | 57 ++
rust/tests/test_async_240_opt_list_meta.rs | 151 ++++
.../test_async_245_opt_list_meta_queries.rs | 96 ++
rust/tests/test_async_250_opt_set_meta.rs | 123 +++
.../test_async_255_opt_set_meta_queries.rs | 111 +++
rust/tests/test_async_400_pread.rs | 41 +
rust/tests/test_async_405_pread_structured.rs | 85 ++
rust/tests/test_async_410_pwrite.rs | 63 ++
rust/tests/test_async_460_block_status.rs | 96 ++
rust/tests/test_async_620_stats.rs | 77 ++
rust/tests/test_log/mod.rs | 86 ++
rustfmt.toml | 19 +
62 files changed, 4396 insertions(+), 3 deletions(-)
create mode 100644 .ocamlformat
create mode 100644 generator/Rust.ml
create mode 100644 generator/Rust.mli
create mode 100644 rust/Cargo.toml
create mode 100644 rust/Makefile.am
create mode 100644 rust/libnbd-sys/Cargo.toml
create mode 100644 rust/libnbd-sys/build.rs
create mode 100644 rust/libnbd-sys/src/lib.rs
create mode 100644 rust/libnbd-sys/wrapper.h
create mode 100755 rust/run-tests.sh
create mode 100644 rust/src/async_handle.rs
create mode 100644 rust/src/error.rs
create mode 100644 rust/src/handle.rs
create mode 100644 rust/src/lib.rs
create mode 100644 rust/src/types.rs
create mode 100644 rust/src/utils.rs
create mode 100644 rust/tests/nbdkit_pattern/mod.rs
create mode 100644 rust/tests/test_100_handle.rs
create mode 100644 rust/tests/test_110_defaults.rs
create mode 100644 rust/tests/test_120_set_non_defaults.rs
create mode 100644 rust/tests/test_130_private_data.rs
create mode 100644 rust/tests/test_140_explicit_close.rs
create mode 100644 rust/tests/test_200_connect_command.rs
create mode 100644 rust/tests/test_210_opt_abort.rs
create mode 100644 rust/tests/test_220_opt_list.rs
create mode 100644 rust/tests/test_230_opt_info.rs
create mode 100644 rust/tests/test_240_opt_list_meta.rs
create mode 100644 rust/tests/test_245_opt_list_meta_queries.rs
create mode 100644 rust/tests/test_250_opt_set_meta.rs
create mode 100644 rust/tests/test_255_opt_set_meta_queries.rs
create mode 100644 rust/tests/test_300_get_size.rs
create mode 100644 rust/tests/test_400_pread.rs
create mode 100644 rust/tests/test_405_pread_structured.rs
create mode 100644 rust/tests/test_410_pwrite.rs
create mode 100644 rust/tests/test_460_block_status.rs
create mode 100644 rust/tests/test_620_stats.rs
create mode 100644 rust/tests/test_async_100_handle.rs
create mode 100644 rust/tests/test_async_200_connect_command.rs
create mode 100644 rust/tests/test_async_210_opt_abort.rs
create mode 100644 rust/tests/test_async_220_opt_list.rs
create mode 100644 rust/tests/test_async_230_opt_info.rs
create mode 100644 rust/tests/test_async_235memleak.rs
create mode 100644 rust/tests/test_async_240_opt_list_meta.rs
create mode 100644 rust/tests/test_async_245_opt_list_meta_queries.rs
create mode 100644 rust/tests/test_async_250_opt_set_meta.rs
create mode 100644 rust/tests/test_async_255_opt_set_meta_queries.rs
create mode 100644 rust/tests/test_async_400_pread.rs
create mode 100644 rust/tests/test_async_405_pread_structured.rs
create mode 100644 rust/tests/test_async_410_pwrite.rs
create mode 100644 rust/tests/test_async_460_block_status.rs
create mode 100644 rust/tests/test_async_620_stats.rs
create mode 100644 rust/tests/test_log/mod.rs
create mode 100644 rustfmt.toml
--
2.41.0