diff --git a/CMakeLists.txt b/CMakeLists.txt index f0090e0c1..ce69730ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,10 @@ if(ZENOHC_BUILD_IN_SOURCE_TREE AND(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_ set(cargo_toml_dir_release ${CMAKE_CURRENT_BINARY_DIR}/release) file(MAKE_DIRECTORY ${cargo_toml_dir_debug}/include) file(MAKE_DIRECTORY ${cargo_toml_dir_release}/include) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/prebindgen-project-root + DESTINATION ${cargo_toml_dir_debug}) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/prebindgen-project-root + DESTINATION ${cargo_toml_dir_release}) else() message(STATUS "Mode: IDE, Single-Config generator (${CMAKE_GENERATOR})") set(cargo_toml_dir_debug ${cargo_toml_dir_ide}) @@ -96,6 +100,10 @@ else() set(cargo_toml_dir_release ${CMAKE_CURRENT_BINARY_DIR}/release) file(MAKE_DIRECTORY ${cargo_toml_dir_debug}/include) file(MAKE_DIRECTORY ${cargo_toml_dir_release}/include) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/prebindgen-project-root + DESTINATION ${cargo_toml_dir_debug}) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/prebindgen-project-root + DESTINATION ${cargo_toml_dir_release}) endif() # note: case-insensitive build configuration check @@ -252,14 +260,26 @@ if(NOT(ZENOHC_CUSTOM_TARGET STREQUAL "")) set(cargo_flags ${cargo_flags} --target=${ZENOHC_CUSTOM_TARGET}) endif() +# If ZENOHC_CUSTOM_TARGET is set and ZENOHC_CARGO_FLAGS contains target linker setting +# for this target, e.g. +# "--config=target.armv7-unknown-linux-gnueabihf.linker=\"armv7-linux-gnueabihf-gcc\"" +# then extract the linker name and assign it to variable CROSS_RUSTC_LINKER +if("${cargo_flags}" MATCHES "--config=target.${ZENOHC_CUSTOM_TARGET}.linker=\"([^\"]+)\"") + set(cross_rustc_linker "${CMAKE_MATCH_1}") +endif() + status_print(cargo_flags) status_print(libs) file(GLOB_RECURSE rust_sources "Cargo.toml.in" "src/*.rs" "build.rs" "splitguide.yaml") +# The zenoh-ffi needs for correct cross-target build not only "--target" parameter for +# cargo, but also variable CROSS_TARGET set to the same value. +# This is necessary because the build.rs of zenoh-ffi-opaque-types should know +# the target to correctly calculate structure sizes add_custom_command( OUTPUT ${libs} COMMAND ${CMAKE_COMMAND} -E echo \"RUSTFLAGS = $$RUSTFLAGS\" - COMMAND ${CMAKE_COMMAND} -E echo \"cargo ${ZENOHC_CARGO_CHANNEL} build ${cargo_flags}\" - COMMAND ${CMAKE_COMMAND} -E env OPAQUE_TYPES_BUILD_DIR=${CMAKE_BINARY_DIR}/opaque-types cargo ${ZENOHC_CARGO_CHANNEL} build ${cargo_flags} + COMMAND ${CMAKE_COMMAND} -E echo \"CROSS_TARGET=${ZENOHC_CUSTOM_TARGET} CROSS_RUSTC_LINKER=${cross_rustc_linker} cargo ${ZENOHC_CARGO_CHANNEL} build ${cargo_flags}\" + COMMAND ${CMAKE_COMMAND} -E env CROSS_TARGET=${ZENOHC_CUSTOM_TARGET} CROSS_RUSTC_LINKER=${cross_rustc_linker} cargo ${ZENOHC_CARGO_CHANNEL} build ${cargo_flags} VERBATIM COMMAND_EXPAND_LISTS DEPENDS "${rust_sources}" diff --git a/Cargo.lock b/Cargo.lock index 731303325..bfa2c9023 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,18 +4,18 @@ version = 3 [[package]] name = "addr2line" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] name = "adler2" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "advisory-lock" @@ -40,12 +40,12 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", - "getrandom 0.2.15", + "getrandom 0.3.3", "once_cell", "version_check", "zerocopy", @@ -62,9 +62,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "android-tzdata" @@ -83,9 +83,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192" dependencies = [ "anstyle", "anstyle-parse", @@ -98,43 +98,44 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" [[package]] name = "anstyle-parse" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.1" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] name = "anstyle-wincon" -version = "3.0.4" +version = "3.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "once_cell_polyfill", + "windows-sys 0.60.2", ] [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" [[package]] name = "arc-swap" @@ -172,7 +173,7 @@ checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", "synstructure", ] @@ -184,31 +185,31 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] name = "async-trait" -version = "0.1.82" +version = "0.1.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] name = "autocfg" -version = "1.3.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "backtrace" -version = "0.3.74" +version = "0.3.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" dependencies = [ "addr2line", "cfg-if", @@ -254,9 +255,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "34efbcccd345379ca2868b2b2c9d3782e9cc58ba87bc7d79d5b53d9c9ae6f25d" dependencies = [ "serde", ] @@ -272,9 +273,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "byteorder" @@ -284,15 +285,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" - -[[package]] -name = "cache-padded" -version = "1.3.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "981520c98f422fcc584dc1a95c334e6953900b9106bc47a9839b81790009eb21" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cbindgen" @@ -302,22 +297,22 @@ checksum = "975982cdb7ad6a142be15bdf84aea7ec6a9e5d4d797c004d43185b24cfe4e684" dependencies = [ "clap", "heck", - "indexmap 2.5.0", + "indexmap 2.11.0", "log", "proc-macro2", "quote", "serde", "serde_json", - "syn 2.0.87", + "syn 2.0.106", "tempfile", - "toml", + "toml 0.8.23", ] [[package]] name = "cc" -version = "1.2.16" +version = "1.2.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" +checksum = "42bc4aea80032b7bf409b0bc7ccad88853858911b7713a8062fdc0623867bedc" dependencies = [ "shlex", ] @@ -330,9 +325,9 @@ checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" [[package]] name = "cfg-if" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" +checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" [[package]] name = "cfg_aliases" @@ -348,9 +343,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" dependencies = [ "android-tzdata", "iana-time-zone", @@ -358,7 +353,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.52.6", + "windows-link", ] [[package]] @@ -373,18 +368,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.17" +version = "4.5.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" +checksum = "2c5e4fcf9c21d2e544ca1ee9d8552de13019a42aa7dbf32747fa7aaf1df76e57" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.17" +version = "4.5.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" +checksum = "fecb53a0e6fcfb055f686001bc2e2592fa527efaf38dbe81a6a9563562e57d41" dependencies = [ "anstream", "anstyle", @@ -394,9 +389,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" [[package]] name = "cobs" @@ -406,9 +401,9 @@ checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" [[package]] name = "colorchoice" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" [[package]] name = "combine" @@ -437,29 +432,38 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "const_format" -version = "0.2.33" +version = "0.2.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c655d81ff1114fb0dcdea9225ea9f0cc712a6f8d189378e82bdf62a473a64b" +checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd" dependencies = [ "const_format_proc_macros", ] [[package]] name = "const_format_proc_macros" -version = "0.2.33" +version = "0.2.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff1a44b93f47b1bac19a27932f5c591e43d1ba357ee4f61526c8a25603f0eb1" +checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744" dependencies = [ "proc-macro2", "quote", "unicode-xid", ] +[[package]] +name = "const_panic" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb8a602185c3c95b52f86dc78e55a6df9a287a7a93ddbcf012509930880cf879" +dependencies = [ + "typewit", +] + [[package]] name = "core-foundation" -version = "0.9.4" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" dependencies = [ "core-foundation-sys", "libc", @@ -473,13 +477,26 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] +[[package]] +name = "crossbeam" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] + [[package]] name = "crossbeam-channel" version = "0.5.15" @@ -489,6 +506,25 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-queue" version = "0.3.12" @@ -500,9 +536,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crypto-common" @@ -532,9 +568,9 @@ checksum = "e2931af7e13dc045d8e9d26afccc6fa115d64e115c9c84b1166288b46f6782c2" [[package]] name = "darling" -version = "0.20.10" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" dependencies = [ "darling_core", "darling_macro", @@ -542,40 +578,40 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.10" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] name = "darling_macro" -version = "0.20.10" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] name = "data-encoding" -version = "2.6.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" +checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" [[package]] name = "der" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" dependencies = [ "const-oid", "pem-rfc7468", @@ -598,9 +634,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.11" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" dependencies = [ "powerfmt", "serde", @@ -620,23 +656,23 @@ dependencies = [ [[package]] name = "dirs" -version = "5.0.1" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" dependencies = [ "dirs-sys", ] [[package]] name = "dirs-sys" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" dependencies = [ "libc", "option-ext", "redox_users", - "windows-sys 0.48.0", + "windows-sys 0.60.2", ] [[package]] @@ -647,7 +683,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] @@ -667,21 +703,21 @@ checksum = "7454e41ff9012c00d53cf7f475c5e3afa3b91b7c90568495495e8d9bf47a1055" [[package]] name = "dyn-clone" -version = "1.0.17" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "either" -version = "1.13.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" @@ -696,12 +732,12 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.9" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] @@ -714,34 +750,40 @@ dependencies = [ "libc", ] -[[package]] -name = "evalexpr" -version = "11.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aff27af350e7b53e82aac3e5ab6389abd8f280640ac034508dff0608c4c7e5" - [[package]] name = "event-listener" -version = "5.3.1" +version = "5.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" +checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab" dependencies = [ "concurrent-queue", "parking", "pin-project-lite", ] +[[package]] +name = "fastbloom" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18c1ddb9231d8554c2d6bdf4cfaabf0c59251658c68b6c95cd52dd0c513a912a" +dependencies = [ + "getrandom 0.3.3", + "libm", + "rand 0.9.2", + "siphasher", +] + [[package]] name = "fastrand" -version = "2.1.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "filepath" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7faa16fcec147281a1719947edb44af4f9124964bf7476bd5f5356a48e44dcc" +checksum = "38ea8b8ba1c652fcc17279418e1d1eac2a05c6a941e13407b325719b2b1f617f" dependencies = [ "libc", "winapi", @@ -755,9 +797,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flume" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" dependencies = [ "futures-core", "futures-sink", @@ -773,9 +815,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" dependencies = [ "percent-encoding", ] @@ -852,7 +894,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] @@ -897,14 +939,14 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if", "js-sys", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi 0.11.1+wasi-snapshot-preview1", "wasm-bindgen", ] @@ -915,16 +957,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi", - "wasi 0.14.2+wasi-0.2.4", + "wasi 0.14.3+wasi-0.2.4", + "wasm-bindgen", ] [[package]] name = "gimli" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "git-version" @@ -943,7 +987,7 @@ checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] @@ -962,6 +1006,12 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" + [[package]] name = "heck" version = "0.5.0" @@ -970,9 +1020,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" -version = "0.3.9" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" [[package]] name = "hex" @@ -1000,9 +1050,9 @@ dependencies = [ [[package]] name = "http" -version = "1.1.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" dependencies = [ "bytes", "fnv", @@ -1011,9 +1061,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.4" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "humantime" @@ -1023,14 +1073,15 @@ checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f" [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", + "log", "wasm-bindgen", "windows-core", ] @@ -1044,6 +1095,124 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr 0.7.6", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr 0.7.6", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e8338228bdc8ab83303f16b797e177953730f601a96c25d10cb3ab0daa0cb7" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr 0.7.6", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85fb8799753b75aee8d2a21d7c14d9f38921b54b3dbda10f5a3c7a7b82dba5e2" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr 0.7.6", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1052,14 +1221,31 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "icu_normalizer", + "icu_properties", ] +[[package]] +name = "if_rust_version" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46dbcb333e86939721589d25a3557e180b52778cb33c7fdfe9e0158ff790d5ec" + [[package]] name = "indexmap" version = "1.9.3" @@ -1073,20 +1259,20 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.5.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "f2481980430f9f78649238835720ddccc57e52df14ffce1c6f37391d61b563e9" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown 0.15.5", "serde", ] [[package]] name = "inout" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" dependencies = [ "generic-array", ] @@ -1110,6 +1296,17 @@ dependencies = [ "mach2", ] +[[package]] +name = "io-uring" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046fa2d4d00aea763528b4950358d0ead425372445dc8ff86312b3c69ff7727b" +dependencies = [ + "bitflags 2.9.3", + "cfg-if", + "libc", +] + [[package]] name = "ipnetwork" version = "0.20.0" @@ -1134,24 +1331,35 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jni" -version = "0.19.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6df18c2e3db7e453d3c6ac5b3e9d5182664d28788126d39b91f2d1e22b017ec" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" dependencies = [ "cesu8", + "cfg-if", "combine", "jni-sys", "log", "thiserror 1.0.69", "walkdir", + "windows-sys 0.45.0", ] [[package]] @@ -1162,10 +1370,11 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -1198,6 +1407,33 @@ dependencies = [ "hashbrown 0.14.5", ] +[[package]] +name = "konst" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4381b9b00c55f251f2ebe9473aef7c117e96828def1a7cb3bd3f0f903c6894e9" +dependencies = [ + "const_panic", + "konst_kernel", + "konst_proc_macros", + "typewit", +] + +[[package]] +name = "konst_kernel" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4b1eb7788f3824c629b1116a7a9060d6e898c358ebff59070093d51103dcc3c" +dependencies = [ + "typewit", +] + +[[package]] +name = "konst_proc_macros" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00af7901ba50898c9e545c24d5c580c96a982298134e8037d8978b6594782c07" + [[package]] name = "lazy_static" version = "1.5.0" @@ -1215,47 +1451,53 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.175" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543" [[package]] name = "libloading" -version = "0.8.5" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.53.3", ] [[package]] name = "libm" -version = "0.2.8" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" [[package]] name = "libredox" -version = "0.1.3" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.3", "libc", ] [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + +[[package]] +name = "litemap" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" [[package]] name = "lock_api" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" dependencies = [ "autocfg", "scopeguard", @@ -1263,9 +1505,15 @@ dependencies = [ [[package]] name = "log" -version = "0.4.22" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "lru-slab" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" [[package]] name = "lz4_flex" @@ -1278,36 +1526,27 @@ dependencies = [ [[package]] name = "mach2" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" dependencies = [ "libc", ] [[package]] name = "matchers" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" dependencies = [ - "regex-automata 0.1.10", + "regex-automata", ] [[package]] name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "memoffset" -version = "0.7.1" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "memoffset" @@ -1326,46 +1565,34 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", ] [[package]] name = "mio" -version = "0.8.11" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", -] - -[[package]] -name = "mio" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" -dependencies = [ - "hermit-abi", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.52.0", + "wasi 0.11.1+wasi-snapshot-preview1", + "windows-sys 0.59.0", ] [[package]] name = "mio-serial" -version = "5.0.5" +version = "5.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20a4c60ca5c9c0e114b3bd66ff4aa5f9b2b175442be51ca6c4365d687a97a2ac" +checksum = "029e1f407e261176a983a6599c084efd322d9301028055c87174beac71397ba3" dependencies = [ "log", - "mio 0.8.11", - "nix 0.26.4", + "mio", + "nix 0.29.0", "serialport", "winapi", ] @@ -1376,7 +1603,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" dependencies = [ - "getrandom 0.2.15", + "getrandom 0.2.16", ] [[package]] @@ -1388,8 +1615,6 @@ dependencies = [ "bitflags 1.3.2", "cfg-if", "libc", - "memoffset 0.7.1", - "pin-utils", ] [[package]] @@ -1398,10 +1623,10 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.3", "cfg-if", "libc", - "memoffset 0.9.1", + "memoffset", ] [[package]] @@ -1410,7 +1635,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.3", "cfg-if", "cfg_aliases 0.2.1", "libc", @@ -1434,21 +1659,20 @@ dependencies = [ [[package]] name = "nonempty-collections" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f301452dbaf00f14ca0c8204e46cf0c9a96f53543ac72cefa9b4d91c19e0ac" +checksum = "e216d0e8cf9d54fa66e5780f6e1d5dc96d1c1b3c25aeba3b6758548bcbbd8b9d" dependencies = [ "serde", ] [[package]] name = "nu-ansi-term" -version = "0.46.0" +version = "0.50.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" dependencies = [ - "overload", - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -1516,9 +1740,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" dependencies = [ "hermit-abi", "libc", @@ -1526,9 +1750,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.4" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] @@ -1544,15 +1768,21 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" [[package]] name = "openssl-probe" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "option-ext" @@ -1560,12 +1790,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - [[package]] name = "parking" version = "2.2.1" @@ -1614,26 +1838,26 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pest" -version = "2.7.12" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c73c26c01b8c87956cea613c907c9d6ecffd8d18a2a5908e5de0adfaa185cea" +checksum = "198db74531d58c70a361c42201efde7e2591e976d518caf7662a47dc5720e7b6" dependencies = [ "memchr", - "thiserror 1.0.69", + "thiserror 2.0.16", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.7.12" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "664d22978e2815783adbdd2c588b455b1bd625299ce36b2a99881ac9627e6d8d" +checksum = "d725d9cfd79e87dccc9341a2ef39d1b6f6353d68c4b33c177febbe1a402c97c5" dependencies = [ "pest", "pest_generator", @@ -1641,22 +1865,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.12" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2d5487022d5d33f4c30d91c22afa240ce2a644e87fe08caad974d4eab6badbe" +checksum = "db7d01726be8ab66ab32f9df467ae8b1148906685bbe75c82d1e65d7f5b3f841" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] name = "pest_meta" -version = "2.7.12" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0091754bbd0ea592c4deb3a122ce8ecbb0753b738aa82bc055fcc2eccc8d8174" +checksum = "7f9f832470494906d1fca5329f8ab5791cc60beb230c74815dff541cbd2b5ca0" dependencies = [ "once_cell", "pest", @@ -1670,14 +1894,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.5.0", + "indexmap 2.11.0", ] [[package]] name = "phf" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" dependencies = [ "phf_macros", "phf_shared", @@ -1685,9 +1909,9 @@ dependencies = [ [[package]] name = "phf_generator" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" dependencies = [ "phf_shared", "rand 0.8.5", @@ -1695,31 +1919,31 @@ dependencies = [ [[package]] name = "phf_macros" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" dependencies = [ "phf_generator", "phf_shared", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] name = "phf_shared" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" dependencies = [ "siphasher", ] [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -1780,6 +2004,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "potential_utf" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2a1d6d1132e166768a82805efecd7c326eb8dc70ad4a586da697836b44eb970" + [[package]] name = "powerfmt" version = "0.2.0" @@ -1788,85 +2018,169 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ "zerocopy", ] +[[package]] +name = "prebindgen" +version = "0.4.1" +source = "git+https://github.com/milyin/prebindgen.git?branch=main#649126aedfbb8cccc4283c601476efbcbf233e1b" +dependencies = [ + "if_rust_version", + "itertools 0.14.0", + "konst", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "roxygen", + "serde", + "serde_json", + "syn 2.0.106", + "toml 0.9.5", +] + +[[package]] +name = "prebindgen" +version = "0.4.1" +source = "git+https://github.com/milyin/prebindgen#649126aedfbb8cccc4283c601476efbcbf233e1b" +dependencies = [ + "if_rust_version", + "itertools 0.14.0", + "konst", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "roxygen", + "serde", + "serde_json", + "syn 2.0.106", + "toml 0.9.5", +] + +[[package]] +name = "prebindgen-proc-macro" +version = "0.4.1" +source = "git+https://github.com/milyin/prebindgen.git?branch=main#649126aedfbb8cccc4283c601476efbcbf233e1b" +dependencies = [ + "prebindgen 0.4.1 (git+https://github.com/milyin/prebindgen.git?branch=main)", + "proc-macro2", + "quote", + "rand 0.9.2", + "serde", + "serde_json", + "syn 2.0.106", +] + +[[package]] +name = "prebindgen-project-root" +version = "0.4.0" +dependencies = [ + "project-root", + "quote", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.106", +] + [[package]] name = "proc-macro-crate" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" dependencies = [ "toml_edit", ] [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" dependencies = [ "unicode-ident", ] +[[package]] +name = "project-root" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bccbff07d5ed689c4087d20d7307a52ab6141edeedf487c3876a55b86cf63df" + [[package]] name = "quinn" -version = "0.11.5" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" +checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20" dependencies = [ "bytes", + "cfg_aliases 0.2.1", "pin-project-lite", "quinn-proto", "quinn-udp", "rustc-hash", "rustls", - "socket2", - "thiserror 1.0.69", + "socket2 0.6.0", + "thiserror 2.0.16", "tokio", "tracing", + "web-time", ] [[package]] name = "quinn-proto" -version = "0.11.8" +version = "0.11.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" +checksum = "f1906b49b0c3bc04b5fe5d86a77925ae6524a19b816ae38ce1e426255f1d8a31" dependencies = [ "bytes", - "rand 0.8.5", + "fastbloom", + "getrandom 0.3.3", + "lru-slab", + "rand 0.9.2", "ring", "rustc-hash", "rustls", + "rustls-pki-types", "rustls-platform-verifier", "slab", - "thiserror 1.0.69", + "thiserror 2.0.16", "tinyvec", "tracing", + "web-time", ] [[package]] name = "quinn-udp" -version = "0.5.5" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" +checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd" dependencies = [ + "cfg_aliases 0.2.1", "libc", "once_cell", - "socket2", + "socket2 0.6.0", "tracing", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] name = "quote" -version = "1.0.37" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -1924,7 +2238,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.15", + "getrandom 0.2.16", ] [[package]] @@ -1947,33 +2261,33 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.6" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" dependencies = [ - "getrandom 0.2.15", + "getrandom 0.2.16", "libredox", - "thiserror 1.0.69", + "thiserror 2.0.16", ] [[package]] name = "ref-cast" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] @@ -1984,17 +2298,8 @@ checksum = "23d7fd106d8c02486a8d64e778353d1cffe08ce79ac2e82f540c86d0facf6912" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.10", - "regex-syntax 0.8.6", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", + "regex-automata", + "regex-syntax", ] [[package]] @@ -2005,15 +2310,9 @@ checksum = "6b9458fa0bfeeac22b5ca447c63aaf45f28439a709ccd244698632f9aa6394d6" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.6", + "regex-syntax", ] -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - [[package]] name = "regex-syntax" version = "0.8.6" @@ -2022,13 +2321,13 @@ checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" [[package]] name = "ring" -version = "0.17.13" +version = "0.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ac5d832aa16abd7d1def883a8545280c20a60f523a370aa3a9617c2b8550ee" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.15", + "getrandom 0.2.16", "libc", "untrusted", "windows-sys 0.52.0", @@ -2036,12 +2335,12 @@ dependencies = [ [[package]] name = "ringbuffer-spsc" -version = "0.1.9" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd1938faa63a2362ee1747afb2d10567d0fb1413b9cbd6198a8541485c4f773" +checksum = "3ac1597578561cb821dd07711c03cbfaec071eb5a0e526f7f05c86cc4c149d78" dependencies = [ "array-init", - "cache-padded", + "crossbeam", ] [[package]] @@ -2051,16 +2350,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ "base64 0.21.7", - "bitflags 2.6.0", + "bitflags 2.9.3", "serde", "serde_derive", ] +[[package]] +name = "roxygen" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa650dd372f29f0a6be64b2896707f9536962ba28915e3b39bcafd5a6221873b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "rsa" -version = "0.9.6" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" +checksum = "78928ac1ed176a5ca1d17e578a1825f3d81ca54cf41053a592584b020cfd691b" dependencies = [ "const-oid", "digest", @@ -2078,15 +2388,15 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" [[package]] name = "rustc-hash" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustc_version" @@ -2108,40 +2418,39 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.37" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8" dependencies = [ - "bitflags 2.6.0", - "errno 0.3.9", + "bitflags 2.9.3", + "errno 0.3.13", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] name = "rustls" -version = "0.23.23" +version = "0.23.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395" +checksum = "c0ebcbd2f03de0fc1122ad9bb24b127a5a6cd51d72604a3f3c50ac459762b6cc" dependencies = [ "log", "once_cell", "ring", "rustls-pki-types", - "rustls-webpki", + "rustls-webpki 0.103.4", "subtle", "zeroize", ] [[package]] name = "rustls-native-certs" -version = "0.7.3" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" +checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" dependencies = [ "openssl-probe", - "rustls-pemfile", "rustls-pki-types", "schannel", "security-framework", @@ -2149,25 +2458,28 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.3" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "base64 0.22.1", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" +checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" +dependencies = [ + "web-time", + "zeroize", +] [[package]] name = "rustls-platform-verifier" -version = "0.3.4" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afbb878bdfdf63a336a5e63561b1835e7a8c91524f51621db870169eac84b490" +checksum = "be59af91596cac372a6942530653ad0c3a246cdd491aaa9dcaee47f88d67d5a0" dependencies = [ "core-foundation", "core-foundation-sys", @@ -2177,11 +2489,11 @@ dependencies = [ "rustls", "rustls-native-certs", "rustls-platform-verifier-android", - "rustls-webpki", + "rustls-webpki 0.103.4", "security-framework", "security-framework-sys", - "webpki-roots", - "winapi", + "webpki-root-certs", + "windows-sys 0.59.0", ] [[package]] @@ -2201,17 +2513,28 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustls-webpki" +version = "0.103.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" -version = "1.0.17" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "same-file" @@ -2224,18 +2547,18 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.24" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" dependencies = [ "windows-sys 0.59.0", ] [[package]] name = "schemars" -version = "0.8.21" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" dependencies = [ "dyn-clone", "either", @@ -2244,16 +2567,40 @@ dependencies = [ "serde_json", ] +[[package]] +name = "schemars" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + [[package]] name = "schemars_derive" -version = "0.8.21" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] @@ -2274,23 +2621,22 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.11.1" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +checksum = "80fb1d92c5028aa318b4b8bd7302a5bfcf48be96a37fc6fc790f806b0004ee0c" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.3", "core-foundation", "core-foundation-sys", "libc", - "num-bigint", "security-framework-sys", ] [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" dependencies = [ "core-foundation-sys", "libc", @@ -2298,28 +2644,28 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.23" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] @@ -2330,14 +2676,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.143" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a" dependencies = [ "itoa", "memchr", @@ -2354,17 +2700,28 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40734c41988f7306bb04f0ecf60ec0f3f1caa34290e4e8ea471dcd3346483b83" +dependencies = [ + "serde", +] + [[package]] name = "serde_with" -version = "3.12.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" +checksum = "f2c45cd61fefa9db6f254525d46e392b852e0e61d9a1fd36e5bd183450a556d5" dependencies = [ "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.5.0", + "indexmap 2.11.0", + "schemars 0.9.0", + "schemars 1.0.4", "serde", "serde_derive", "serde_json", @@ -2374,14 +2731,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.12.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" +checksum = "de90945e6565ce0d9a25098082ed4ee4002e047cb59892c318d66821e14bb30f" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] @@ -2390,7 +2747,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.11.0", "itoa", "ryu", "serde", @@ -2399,12 +2756,13 @@ dependencies = [ [[package]] name = "serialport" -version = "4.5.0" +version = "4.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "241ebb629ed9bf598b2b392ba42aa429f9ef2a0099001246a36ac4c084ee183f" +checksum = "2acaf3f973e8616d7ceac415f53fc60e190b2a686fbcf8d27d0256c741c5007b" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.3", "cfg-if", + "core-foundation", "core-foundation-sys", "io-kit-sys", "mach2", @@ -2427,9 +2785,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.8" +version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", "cpufeatures", @@ -2463,9 +2821,9 @@ dependencies = [ [[package]] name = "shellexpand" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b" +checksum = "8b1fdf65dd6331831494dd616b30351c38e96e45921a27745cf98490458b90bb" dependencies = [ "dirs", ] @@ -2488,35 +2846,42 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.11" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] name = "slab" -version = "0.4.9" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" [[package]] name = "smallvec" -version = "1.13.2" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" dependencies = [ "libc", "windows-sys 0.52.0", ] +[[package]] +name = "socket2" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + [[package]] name = "spin" version = "0.9.8" @@ -2577,6 +2942,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "static_assertions" version = "1.1.0" @@ -2600,9 +2971,9 @@ dependencies = [ [[package]] name = "static_init_macro" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a2595fc3aa78f2d0e45dd425b22282dd863273761cc77780914b2cf3003acf" +checksum = "1389c88ddd739ec6d3f8f83343764a0e944cd23cfbf126a9796a714b0b6edd6f" dependencies = [ "cfg_aliases 0.1.1", "memchr", @@ -2636,9 +3007,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" dependencies = [ "proc-macro2", "quote", @@ -2647,26 +3018,26 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] name = "tempfile" -version = "3.12.0" +version = "3.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "15b61f8f20e3a6f7e0649d825294eaf317edce30f82cf6026e7e4cb9222a7d1e" dependencies = [ - "cfg-if", "fastrand", + "getrandom 0.3.3", "once_cell", "rustix", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -2680,11 +3051,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.11" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" dependencies = [ - "thiserror-impl 2.0.11", + "thiserror-impl 2.0.16", ] [[package]] @@ -2695,27 +3066,27 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] name = "thiserror-impl" -version = "2.0.11" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] name = "thread-priority" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d3b04d33c9633b8662b167b847c7ab521f83d1ae20f2321b65b5b925e532e36" +checksum = "cfe075d7053dae61ac5413a34ea7d4913b6e6207844fd726bdd858b37ff72bf5" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.3", "cfg-if", "libc", "log", @@ -2725,19 +3096,18 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" dependencies = [ "cfg-if", - "once_cell", ] [[package]] name = "time" -version = "0.3.36" +version = "0.3.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" dependencies = [ "deranged", "itoa", @@ -2750,25 +3120,44 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" [[package]] name = "time-macros" -version = "0.2.18" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" dependencies = [ "num-conv", "time-core", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinystr" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b56a820bb70060f096338fcc02edb78cb3f8fb21c5078503f48588cfcaf494" +dependencies = [ + "displaydoc", +] + [[package]] name = "tinyvec" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" dependencies = [ "tinyvec_macros", ] @@ -2787,7 +3176,7 @@ checksum = "ab41256c16d6fc2b3021545f20bf77a73200b18bd54040ac656dddfca6205bfa" dependencies = [ "futures-util", "pin-project-lite", - "thiserror 2.0.11", + "thiserror 2.0.16", "tokio", "tokio-rustls", ] @@ -2803,36 +3192,38 @@ dependencies = [ [[package]] name = "tokio" -version = "1.40.0" +version = "1.47.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" dependencies = [ "backtrace", "bytes", + "io-uring", "libc", - "mio 1.0.2", + "mio", "pin-project-lite", - "socket2", + "slab", + "socket2 0.6.0", "tokio-macros", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] name = "tokio-rustls" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" +checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" dependencies = [ "rustls", "tokio", @@ -2840,14 +3231,15 @@ dependencies = [ [[package]] name = "tokio-serial" -version = "5.4.4" +version = "5.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa6e2e4cf0520a99c5f87d5abb24172b5bd220de57c3181baaaa5440540c64aa" +checksum = "aa1d5427f11ba7c5e6384521cfd76f2d64572ff29f3f4f7aa0f496282923fdc8" dependencies = [ "cfg-if", "futures", "log", "mio-serial", + "serialport", "tokio", ] @@ -2865,15 +3257,14 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" dependencies = [ "bytes", "futures-core", "futures-sink", "futures-util", - "hashbrown 0.14.5", "pin-project-lite", "tokio", ] @@ -2893,43 +3284,89 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.19" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", - "serde_spanned", - "toml_datetime", + "serde_spanned 0.6.9", + "toml_datetime 0.6.11", "toml_edit", ] +[[package]] +name = "toml" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75129e1dc5000bfbaa9fee9d1b21f974f9fbad9daec557a521ee6e080825f6e8" +dependencies = [ + "indexmap 2.11.0", + "serde", + "serde_spanned 1.0.0", + "toml_datetime 0.7.0", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] + [[package]] name = "toml_datetime" -version = "0.6.8" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +checksum = "bade1c3e902f58d73d3f294cd7f20391c1cb2fbcb643b73566bc773971df91e3" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.11.0", "serde", - "serde_spanned", - "toml_datetime", + "serde_spanned 0.6.9", + "toml_datetime 0.6.11", + "toml_write", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b551886f449aa90d4fe2bdaa9f4a2577ad2dde302c61ecf262d80b116db95c10" +dependencies = [ "winnow", ] +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + +[[package]] +name = "toml_writer" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64" + [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "log", "pin-project-lite", @@ -2939,20 +3376,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", ] [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" dependencies = [ "once_cell", "valuable", @@ -2971,9 +3408,9 @@ dependencies = [ [[package]] name = "tracing-serde" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +checksum = "704b1aeb7be0d0a84fc9828cae51dab5970fee5088f83d1dd7ee6f6246fc6ff1" dependencies = [ "serde", "tracing-core", @@ -2981,14 +3418,14 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.18" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" dependencies = [ "matchers", "nu-ansi-term", "once_cell", - "regex", + "regex-automata", "serde", "serde_json", "sharded-slab", @@ -3025,20 +3462,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", + "rand 0.8.5", "static_assertions", ] [[package]] name = "typenum" -version = "1.17.0" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" + +[[package]] +name = "typewit" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dd91acc53c592cb800c11c83e8e7ee1d48378d05cfa33b5474f5f80c5b236bf" +dependencies = [ + "typewit_proc_macros", +] + +[[package]] +name = "typewit_proc_macros" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "e36a83ea2b3c704935a01b4642946aadd445cea40b10935e3f8bd8052b8193d6" [[package]] name = "ucd-trie" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "uhlc" @@ -3056,48 +3509,33 @@ dependencies = [ [[package]] name = "unescaper" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c878a167baa8afd137494101a688ef8c67125089ff2249284bd2b5f9bfedb815" +checksum = "c01d12e3a56a4432a8b436f293c25f4808bdf9e9f9f98f9260bba1f1bc5a1f26" dependencies = [ - "thiserror 1.0.69", + "thiserror 2.0.16", ] [[package]] -name = "unicode-bidi" -version = "0.3.15" +name = "unicode-ident" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] -name = "unicode-ident" -version = "1.0.13" +name = "unicode-xid" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] -name = "unicode-normalization" -version = "0.1.23" +name = "unix-named-pipe" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "6ad653da8f36ac5825ba06642b5a3cce14a4e52c6a5fab4a8928d53f4426dae2" dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-xid" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" - -[[package]] -name = "unix-named-pipe" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ad653da8f36ac5825ba06642b5a3cce14a4e52c6a5fab4a8928d53f4426dae2" -dependencies = [ - "errno 0.2.8", - "libc", + "errno 0.2.8", + "libc", ] [[package]] @@ -3131,13 +3569,14 @@ dependencies = [ [[package]] name = "url" -version = "2.5.2" +version = "2.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "08bc136a29a3d1758e07a9cca267be308aeebf5cfd5a10f3f67ab2097683ef5b" dependencies = [ "form_urlencoded", "idna", "percent-encoding", + "serde", ] [[package]] @@ -3146,6 +3585,18 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -3154,18 +3605,20 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.10.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f33196643e165781c20a5ead5582283a7dacbb87855d867fbc2df3f81eddc1be" dependencies = [ - "getrandom 0.2.15", + "getrandom 0.3.3", + "js-sys", + "wasm-bindgen", ] [[package]] name = "validated_struct" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feef04c049b4beae3037a2a31b8da40d8cebec0b97456f24c7de0ede4ed9efed" +checksum = "0251cab911130b095b8190d5480729c5e6a05e36e617658039e4bfcfd879c153" dependencies = [ "json5", "serde", @@ -3175,21 +3628,21 @@ dependencies = [ [[package]] name = "validated_struct_macros" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d4444a980afa9ef0d29c2a3f4d952ec0495a7a996a9c78b52698b71bc21edb4" +checksum = "dcba0282a9f9297af06b91ff22615e7f77f0ab66f75fc95898960d1604fc7fd7" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.106", "unzip-n", ] [[package]] name = "valuable" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" [[package]] name = "vec_map" @@ -3225,50 +3678,50 @@ dependencies = [ [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasi" -version = "0.14.2+wasi-0.2.4" +version = "0.14.3+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +checksum = "6a51ae83037bdd272a9e28ce236db8c07016dd0d50c27038b3f407533c030c95" dependencies = [ - "wit-bindgen-rt", + "wit-bindgen", ] [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3276,28 +3729,59 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-root-certs" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4ffd8df1c57e87c325000a3d6ef93db75279dc3a231125aac571650f22b12a" +dependencies = [ + "rustls-pki-types", +] [[package]] name = "webpki-roots" -version = "0.26.5" +version = "0.26.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" +checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" +dependencies = [ + "webpki-roots 1.0.2", +] + +[[package]] +name = "webpki-roots" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8983c3ab33d6fb807cfcdad2491c4ea8cbc8ed839181c7dfd9c67c83e261b2" dependencies = [ "rustls-pki-types", ] @@ -3329,11 +3813,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +checksum = "0978bf7171b3d90bac376700cb56d606feb40f251a475a5d6634613564460b22" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -3357,20 +3841,70 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.52.0" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ - "windows-targets 0.52.6", + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", ] [[package]] name = "windows-sys" -version = "0.48.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets 0.48.5", + "windows-targets 0.42.2", ] [[package]] @@ -3391,19 +3925,28 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.3", +] + [[package]] name = "windows-targets" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -3415,18 +3958,35 @@ dependencies = [ "windows_aarch64_gnullvm 0.52.6", "windows_aarch64_msvc 0.52.6", "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm", + "windows_i686_gnullvm 0.52.6", "windows_i686_msvc 0.52.6", "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm 0.52.6", "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows-targets" +version = "0.53.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", +] + [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" @@ -3434,6 +3994,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.34.0" @@ -3442,9 +4008,9 @@ checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" [[package]] name = "windows_aarch64_msvc" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" @@ -3452,6 +4018,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.34.0" @@ -3460,9 +4032,9 @@ checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" [[package]] name = "windows_i686_gnu" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" @@ -3470,12 +4042,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.34.0" @@ -3484,9 +4068,9 @@ checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" [[package]] name = "windows_i686_msvc" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" @@ -3494,6 +4078,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[package]] name = "windows_x86_64_gnu" version = "0.34.0" @@ -3502,9 +4092,9 @@ checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" [[package]] name = "windows_x86_64_gnu" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" @@ -3512,11 +4102,17 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" @@ -3524,6 +4120,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + [[package]] name = "windows_x86_64_msvc" version = "0.34.0" @@ -3532,9 +4134,9 @@ checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" [[package]] name = "windows_x86_64_msvc" -version = "0.48.5" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" @@ -3542,23 +4144,38 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + [[package]] name = "winnow" -version = "0.6.18" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" dependencies = [ "memchr", ] [[package]] -name = "wit-bindgen-rt" -version = "0.39.0" +name = "wit-bindgen" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" -dependencies = [ - "bitflags 2.6.0", -] +checksum = "052283831dbae3d879dc7f51f3d92703a316ca49f91540417d38591826127814" + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" [[package]] name = "x509-parser" @@ -3577,6 +4194,30 @@ dependencies = [ "time", ] +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", + "synstructure", +] + [[package]] name = "z-serial" version = "0.3.1" @@ -3593,7 +4234,7 @@ dependencies = [ [[package]] name = "zenoh" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "ahash", "arc-swap", @@ -3602,7 +4243,7 @@ dependencies = [ "flume", "futures", "git-version", - "itertools", + "itertools 0.13.0", "json5", "lazy_static", "nonempty-collections", @@ -3615,7 +4256,7 @@ dependencies = [ "rustc_version", "serde", "serde_json", - "socket2", + "socket2 0.5.10", "tokio", "tokio-util", "tracing", @@ -3644,7 +4285,7 @@ dependencies = [ [[package]] name = "zenoh-buffers" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "zenoh-collections", ] @@ -3654,34 +4295,24 @@ name = "zenoh-c" version = "1.5.0" dependencies = [ "cbindgen", - "chrono", - "const_format", - "ctor", - "evalexpr", - "flume", "fs2", "fs_extra", - "json5", - "lazy_static", + "itertools 0.14.0", + "konst", "libc", "phf", - "rand 0.9.2", + "prebindgen 0.4.1 (git+https://github.com/milyin/prebindgen)", "regex", "serde_yaml", - "spin 0.9.8", - "tokio", - "tracing", - "unwrap-infallible", - "zenoh", - "zenoh-ext", - "zenoh-runtime", - "zenoh-util", + "zenoh-ffi", + "zenoh-ffi-opaque-types", + "zenoh-pinned-deps-1-75", ] [[package]] name = "zenoh-codec" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "tracing", "uhlc", @@ -3693,7 +4324,7 @@ dependencies = [ [[package]] name = "zenoh-collections" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "ahash", ] @@ -3701,7 +4332,7 @@ dependencies = [ [[package]] name = "zenoh-config" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "json5", "nonempty-collections", @@ -3725,7 +4356,7 @@ dependencies = [ [[package]] name = "zenoh-core" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "lazy_static", "tokio", @@ -3736,7 +4367,7 @@ dependencies = [ [[package]] name = "zenoh-crypto" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "aes", "hmac", @@ -3749,7 +4380,7 @@ dependencies = [ [[package]] name = "zenoh-ext" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "async-trait", "bincode", @@ -3765,16 +4396,66 @@ dependencies = [ "zenoh-util", ] +[[package]] +name = "zenoh-ffi" +version = "1.5.0" +source = "git+https://github.com/ZettaScaleLabs/zenoh-ffi.git?branch=zenoh-ffi#53ff677e5200203e552ee2a900823499b1957bf1" +dependencies = [ + "chrono", + "const_format", + "ctor", + "flume", + "json5", + "lazy_static", + "libc", + "prebindgen 0.4.1 (git+https://github.com/milyin/prebindgen.git?branch=main)", + "prebindgen-proc-macro", + "project-root", + "rand 0.9.2", + "regex", + "serde_json", + "spin 0.9.8", + "tokio", + "tracing", + "unwrap-infallible", + "zenoh", + "zenoh-ext", + "zenoh-ffi-opaque-types", + "zenoh-runtime", + "zenoh-util", +] + +[[package]] +name = "zenoh-ffi-opaque-types" +version = "1.5.0" +source = "git+https://github.com/ZettaScaleLabs/zenoh-ffi.git?branch=zenoh-ffi#53ff677e5200203e552ee2a900823499b1957bf1" +dependencies = [ + "const_format", + "flume", + "prebindgen 0.4.1 (git+https://github.com/milyin/prebindgen.git?branch=main)", + "prebindgen-proc-macro", + "prebindgen-project-root", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "syn 2.0.106", + "tokio", + "zenoh", + "zenoh-ext", + "zenoh-protocol", +] + [[package]] name = "zenoh-keyexpr" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ - "getrandom 0.2.15", + "getrandom 0.2.16", "hashbrown 0.14.5", "keyed-set", "rand 0.8.5", - "schemars", + "schemars 0.8.22", "serde", "token-cell", "zenoh-result", @@ -3783,11 +4464,12 @@ dependencies = [ [[package]] name = "zenoh-link" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "zenoh-config", "zenoh-link-commons", "zenoh-link-quic", + "zenoh-link-quic_datagram", "zenoh-link-serial", "zenoh-link-tcp", "zenoh-link-tls", @@ -3803,7 +4485,7 @@ dependencies = [ [[package]] name = "zenoh-link-commons" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "async-trait", "base64 0.22.1", @@ -3813,15 +4495,15 @@ dependencies = [ "rustls", "rustls-pemfile", "rustls-pki-types", - "rustls-webpki", + "rustls-webpki 0.102.8", "secrecy", "serde", - "socket2", + "socket2 0.5.10", "time", "tokio", "tokio-util", "tracing", - "webpki-roots", + "webpki-roots 0.26.11", "x509-parser", "zenoh-buffers", "zenoh-codec", @@ -3836,20 +4518,20 @@ dependencies = [ [[package]] name = "zenoh-link-quic" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "async-trait", "base64 0.22.1", "quinn", "rustls", "rustls-pemfile", - "rustls-webpki", + "rustls-webpki 0.102.8", "secrecy", "time", "tokio", "tokio-util", "tracing", - "webpki-roots", + "webpki-roots 0.26.11", "zenoh-config", "zenoh-core", "zenoh-link-commons", @@ -3858,10 +4540,30 @@ dependencies = [ "zenoh-util", ] +[[package]] +name = "zenoh-link-quic_datagram" +version = "1.5.0" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" +dependencies = [ + "async-trait", + "quinn", + "rustls", + "rustls-webpki 0.102.8", + "time", + "tokio", + "tokio-util", + "tracing", + "zenoh-core", + "zenoh-link-commons", + "zenoh-protocol", + "zenoh-result", + "zenoh-util", +] + [[package]] name = "zenoh-link-serial" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "async-trait", "tokio", @@ -3879,10 +4581,10 @@ dependencies = [ [[package]] name = "zenoh-link-tcp" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "async-trait", - "socket2", + "socket2 0.5.10", "tokio", "tokio-util", "tracing", @@ -3896,23 +4598,23 @@ dependencies = [ [[package]] name = "zenoh-link-tls" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "async-trait", "base64 0.22.1", "rustls", "rustls-pemfile", "rustls-pki-types", - "rustls-webpki", + "rustls-webpki 0.102.8", "secrecy", - "socket2", + "socket2 0.5.10", "time", "tls-listener", "tokio", "tokio-rustls", "tokio-util", "tracing", - "webpki-roots", + "webpki-roots 0.26.11", "x509-parser", "zenoh-config", "zenoh-core", @@ -3925,11 +4627,11 @@ dependencies = [ [[package]] name = "zenoh-link-udp" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "async-trait", "libc", - "socket2", + "socket2 0.5.10", "tokio", "tokio-util", "tracing", @@ -3946,7 +4648,7 @@ dependencies = [ [[package]] name = "zenoh-link-unixpipe" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "advisory-lock", "async-trait", @@ -3968,7 +4670,7 @@ dependencies = [ [[package]] name = "zenoh-link-unixsock_stream" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "async-trait", "nix 0.29.0", @@ -3986,7 +4688,7 @@ dependencies = [ [[package]] name = "zenoh-link-vsock" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "async-trait", "libc", @@ -4004,7 +4706,7 @@ dependencies = [ [[package]] name = "zenoh-link-ws" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "async-trait", "futures-util", @@ -4024,18 +4726,40 @@ dependencies = [ [[package]] name = "zenoh-macros" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", "zenoh-keyexpr", ] +[[package]] +name = "zenoh-pinned-deps-1-75" +version = "1.5.0" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=rust-1-75-cleanup#4c73918c5bada6d67f276393f570889087cfed11" +dependencies = [ + "base64ct", + "home", + "icu_normalizer", + "litemap", + "lz4_flex", + "pest", + "pest_derive", + "pest_generator", + "pest_meta", + "potential_utf", + "static_init", + "time", + "tinystr 0.8.0", + "twox-hash", + "zerofrom", +] + [[package]] name = "zenoh-plugin-trait" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "git-version", "libloading", @@ -4051,7 +4775,7 @@ dependencies = [ [[package]] name = "zenoh-protocol" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "const_format", "rand 0.8.5", @@ -4065,7 +4789,7 @@ dependencies = [ [[package]] name = "zenoh-result" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "anyhow", ] @@ -4073,7 +4797,7 @@ dependencies = [ [[package]] name = "zenoh-runtime" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "lazy_static", "ron", @@ -4087,7 +4811,7 @@ dependencies = [ [[package]] name = "zenoh-shm" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "advisory-lock", "async-trait", @@ -4114,7 +4838,7 @@ dependencies = [ [[package]] name = "zenoh-sync" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "arc-swap", "event-listener", @@ -4128,7 +4852,7 @@ dependencies = [ [[package]] name = "zenoh-task" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "futures", "tokio", @@ -4141,8 +4865,9 @@ dependencies = [ [[package]] name = "zenoh-transport" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ + "arc-swap", "async-trait", "crossbeam-utils", "flume", @@ -4176,7 +4901,7 @@ dependencies = [ [[package]] name = "zenoh-util" version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#910d0879290bda642c9b0f532fd2a1d1016c4649" dependencies = [ "async-trait", "const_format", @@ -4200,23 +4925,43 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.35" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" dependencies = [ - "byteorder", "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.35" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.106", + "synstructure", ] [[package]] @@ -4224,3 +4969,25 @@ name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] diff --git a/Cargo.toml b/Cargo.toml index d04bccf39..b488b4d6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,30 @@ # Contributors: # ZettaScale Zenoh Team, # +[workspace] +members = [".", "prebindgen-project-root"] + +[workspace.dependencies] +zenoh-ffi = { version = "1.5.0", git = "https://github.com/ZettaScaleLabs/zenoh-ffi.git", branch = "zenoh-ffi" } +zenoh-ffi-opaque-types = { version = "1.5.0", git = "https://github.com/ZettaScaleLabs/zenoh-ffi.git", branch = "zenoh-ffi" } +zenoh-pinned-deps-1-75 = { version = "1.5.0", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "rust-1-75-cleanup" } +libc = "0.2.139" +konst = "0.3.0" +cbindgen = "0.29.0" +fs2 = "0.4.3" +regex = "1.11.1" +serde_yaml = "0.9.19" +fs_extra = "1.3.0" +phf = { version = "0.11.2", features = ["macros"] } +itertools = "0.14.0" + +[patch] +[patch.crates-io] +[patch.crates-io.prebindgen-project-root] +path = "prebindgen-project-root" +[patch."http://github.com/milyin/prebindgen".prebindgen-project-root] +path = "prebindgen-project-root" + [package] name = "zenoh-c" version = "1.5.0" @@ -31,21 +55,21 @@ build = "build.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -shared-memory = ["zenoh/shared-memory"] -unstable = ["zenoh/unstable", "zenoh-ext/unstable"] -auth_pubkey = ["zenoh/auth_pubkey"] -auth_usrpwd = ["zenoh/auth_usrpwd"] -transport_multilink = ["zenoh/transport_multilink"] -transport_compression = ["zenoh/transport_compression"] -transport_quic = ["zenoh/transport_quic"] -transport_serial = ["zenoh/transport_serial"] -transport_unixpipe = ["zenoh/transport_unixpipe"] -transport_tcp = ["zenoh/transport_tcp"] -transport_tls = ["zenoh/transport_tls"] -transport_udp = ["zenoh/transport_udp"] -transport_unixsock-stream = ["zenoh/transport_unixsock-stream"] -transport_ws = ["zenoh/transport_ws"] -transport_vsock = ["zenoh/transport_vsock"] +shared-memory = ["zenoh-ffi/shared-memory"] +unstable = ["zenoh-ffi/unstable"] +auth_pubkey = ["zenoh-ffi/auth_pubkey"] +auth_usrpwd = ["zenoh-ffi/auth_usrpwd"] +transport_multilink = ["zenoh-ffi/transport_multilink"] +transport_compression = ["zenoh-ffi/transport_compression"] +transport_quic = ["zenoh-ffi/transport_quic"] +transport_serial = ["zenoh-ffi/transport_serial"] +transport_unixpipe = ["zenoh-ffi/transport_unixpipe"] +transport_tcp = ["zenoh-ffi/transport_tcp"] +transport_tls = ["zenoh-ffi/transport_tls"] +transport_udp = ["zenoh-ffi/transport_udp"] +transport_unixsock-stream = ["zenoh-ffi/transport_unixsock-stream"] +transport_ws = ["zenoh-ffi/transport_ws"] +transport_vsock = ["zenoh-ffi/transport_vsock"] default = [ "auth_pubkey", "auth_usrpwd", @@ -63,34 +87,24 @@ default = [ maintenance = { status = "actively-developed" } [dependencies] -chrono = "0.4.37" -json5 = "0.4.1" -lazy_static = "1.4.0" -libc = "0.2.139" -tracing = "0.1" -rand = "0.9.0" -spin = "0.9.5" -tokio = "*" -unwrap-infallible = "0.1.5" -const_format = "0.2.32" -zenoh = { version = "1.5.0", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false, features = ["internal"] } -zenoh-ext = { version = "1.5.0", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false, features=["internal"] } -zenoh-runtime = { version = "1.5.0", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" } -zenoh-util = { version = "1.5.0", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" } -flume = "*" - -[target.'cfg(unix)'.dependencies] -ctor = "0.4.1" +zenoh-ffi = { workspace = true } +zenoh-ffi-opaque-types = { workspace = true } +zenoh-pinned-deps-1-75 = { workspace = true } +libc = { workspace = true } +konst = { workspace = true } [build-dependencies] -zenoh = { version = "1.5.0", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false, features = ["internal"] } -cbindgen = "0.29.0" -fs2 = "0.4.3" -regex = "1.11.1" -serde_yaml = "0.9.19" -fs_extra = "1.3.0" -evalexpr = "11.3.0" # Bumping to 12.x.x will cause 1.75 check fails -phf = { version = "0.11.2", features = ["macros"] } +prebindgen = { version = "0.4.1", git = "https://github.com/milyin/prebindgen"} +zenoh-ffi = { workspace = true } +zenoh-ffi-opaque-types = { workspace = true } +zenoh-pinned-deps-1-75 = { workspace = true } +cbindgen = { workspace = true } +fs2 = { workspace = true } +regex = { workspace = true } +serde_yaml = { workspace = true } +fs_extra = { workspace = true } +phf = { workspace = true } +itertools = { workspace = true } [lib] path = "src/lib.rs" @@ -101,14 +115,14 @@ doctest = false [package.metadata.deb.variants.libzenohc] name = "libzenohc" maintainer = "zenoh-dev@eclipse.org" -copyright = "2017, 2022 ZettaScale Technology" +copyright = "2017, 2025 ZettaScale Technology" section = "net" license-file = ["LICENSE", "0"] [package.metadata.deb.variants.libzenohc-dev] name = "libzenohc-dev" maintainer = "zenoh-dev@eclipse.org" -copyright = "2017, 2022 ZettaScale Technology" +copyright = "2017, 2025 ZettaScale Technology" section = "net" license-file = ["LICENSE", "0"] depends = "libzenohc (=1.5.0)" @@ -124,3 +138,6 @@ lto = "fat" codegen-units = 1 opt-level = 3 panic = "abort" + +[package.metadata.cargo-machete] +ignored = ["konst", "libc", "zenoh-ffi", "zenoh-ffi-opaque-types"] diff --git a/Cargo.toml.in b/Cargo.toml.in index 9842a6cec..0db202df5 100644 --- a/Cargo.toml.in +++ b/Cargo.toml.in @@ -11,6 +11,30 @@ # Contributors: # ZettaScale Zenoh Team, # +[workspace] +members = [".", "prebindgen-project-root"] + +[workspace.dependencies] +zenoh-ffi = { version = "1.5.0", git = "https://github.com/ZettaScaleLabs/zenoh-ffi.git", branch = "zenoh-ffi" } +zenoh-ffi-opaque-types = { version = "1.5.0", git = "https://github.com/ZettaScaleLabs/zenoh-ffi.git", branch = "zenoh-ffi" } +zenoh-pinned-deps-1-75 = { version = "1.5.0", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "rust-1-75-cleanup" } +libc = "0.2.139" +konst = "0.3.0" +cbindgen = "0.29.0" +fs2 = "0.4.3" +regex = "1.11.1" +serde_yaml = "0.9.19" +fs_extra = "1.3.0" +phf = { version = "0.11.2", features = ["macros"] } +itertools = "0.14.0" + +[patch] +[patch.crates-io] +[patch.crates-io.prebindgen-project-root] +path = "prebindgen-project-root" +[patch."http://github.com/milyin/prebindgen".prebindgen-project-root] +path = "prebindgen-project-root" + [package] name = "zenoh-c" version = "@CARGO_PROJECT_VERSION@" @@ -31,21 +55,21 @@ build = "@CARGO_PROJECT_DIR@build.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -shared-memory = ["zenoh/shared-memory"] -unstable = ["zenoh/unstable", "zenoh-ext/unstable"] -auth_pubkey = ["zenoh/auth_pubkey"] -auth_usrpwd = ["zenoh/auth_usrpwd"] -transport_multilink = ["zenoh/transport_multilink"] -transport_compression = ["zenoh/transport_compression"] -transport_quic = ["zenoh/transport_quic"] -transport_serial = ["zenoh/transport_serial"] -transport_unixpipe = ["zenoh/transport_unixpipe"] -transport_tcp = ["zenoh/transport_tcp"] -transport_tls = ["zenoh/transport_tls"] -transport_udp = ["zenoh/transport_udp"] -transport_unixsock-stream = ["zenoh/transport_unixsock-stream"] -transport_ws = ["zenoh/transport_ws"] -transport_vsock = ["zenoh/transport_vsock"] +shared-memory = ["zenoh-ffi/shared-memory"] +unstable = ["zenoh-ffi/unstable"] +auth_pubkey = ["zenoh-ffi/auth_pubkey"] +auth_usrpwd = ["zenoh-ffi/auth_usrpwd"] +transport_multilink = ["zenoh-ffi/transport_multilink"] +transport_compression = ["zenoh-ffi/transport_compression"] +transport_quic = ["zenoh-ffi/transport_quic"] +transport_serial = ["zenoh-ffi/transport_serial"] +transport_unixpipe = ["zenoh-ffi/transport_unixpipe"] +transport_tcp = ["zenoh-ffi/transport_tcp"] +transport_tls = ["zenoh-ffi/transport_tls"] +transport_udp = ["zenoh-ffi/transport_udp"] +transport_unixsock-stream = ["zenoh-ffi/transport_unixsock-stream"] +transport_ws = ["zenoh-ffi/transport_ws"] +transport_vsock = ["zenoh-ffi/transport_vsock"] default = [ "auth_pubkey", "auth_usrpwd", @@ -63,34 +87,24 @@ default = [ maintenance = { status = "actively-developed" } [dependencies] -chrono = "0.4.37" -json5 = "0.4.1" -lazy_static = "1.4.0" -libc = "0.2.139" -tracing = "0.1" -rand = "0.9.0" -spin = "0.9.5" -tokio = "*" -unwrap-infallible = "0.1.5" -const_format = "0.2.32" -zenoh = { version = "1.5.0", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false, features = ["internal"] } -zenoh-ext = { version = "1.5.0", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false, features=["internal"] } -zenoh-runtime = { version = "1.5.0", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" } -zenoh-util = { version = "1.5.0", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" } -flume = "*" - -[target.'cfg(unix)'.dependencies] -ctor = "0.4.1" +zenoh-ffi = { workspace = true } +zenoh-ffi-opaque-types = { workspace = true } +zenoh-pinned-deps-1-75 = { workspace = true } +libc = { workspace = true } +konst = { workspace = true } [build-dependencies] -zenoh = { version = "1.5.0", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false, features = ["internal"] } -cbindgen = "0.29.0" -fs2 = "0.4.3" -regex = "1.11.1" -serde_yaml = "0.9.19" -fs_extra = "1.3.0" -evalexpr = "11.3.0" # Bumping to 12.x.x will cause 1.75 check fails -phf = { version = "0.11.2", features = ["macros"] } +prebindgen = { version = "0.4.1", git = "https://github.com/milyin/prebindgen"} +zenoh-ffi = { workspace = true } +zenoh-ffi-opaque-types = { workspace = true } +zenoh-pinned-deps-1-75 = { workspace = true } +cbindgen = { workspace = true } +fs2 = { workspace = true } +regex = { workspace = true } +serde_yaml = { workspace = true } +fs_extra = { workspace = true } +phf = { workspace = true } +itertools = { workspace = true } [lib] path = "@CARGO_PROJECT_DIR@src/lib.rs" @@ -101,14 +115,14 @@ doctest = false [package.metadata.deb.variants.libzenohc] name = "libzenohc" maintainer = "zenoh-dev@eclipse.org" -copyright = "2017, 2022 ZettaScale Technology" +copyright = "2017, 2025 ZettaScale Technology" section = "net" license-file = ["LICENSE", "0"] [package.metadata.deb.variants.libzenohc-dev] name = "libzenohc-dev" maintainer = "zenoh-dev@eclipse.org" -copyright = "2017, 2022 ZettaScale Technology" +copyright = "2017, 2025 ZettaScale Technology" section = "net" license-file = ["LICENSE", "0"] depends = "libzenohc (=1.5.0)" @@ -124,3 +138,6 @@ lto = "fat" codegen-units = 1 opt-level = 3 panic = "abort" + +[package.metadata.cargo-machete] +ignored = ["konst", "libc", "zenoh-ffi", "zenoh-ffi-opaque-types"] diff --git a/build-resources/opaque-types/Cargo.lock b/build-resources/opaque-types/Cargo.lock deleted file mode 100644 index 3cd375521..000000000 --- a/build-resources/opaque-types/Cargo.lock +++ /dev/null @@ -1,3911 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler2" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" - -[[package]] -name = "advisory-lock" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6caee7d48f930f9ad3fc9546f8cbf843365da0c5b0ca4eee1d1ac3dd12d8f93" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "aes" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures", -] - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "getrandom", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[package]] -name = "allocator-api2" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" - -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "anyhow" -version = "1.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" - -[[package]] -name = "arc-swap" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" - -[[package]] -name = "array-init" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" - -[[package]] -name = "asn1-rs" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5493c3bedbacf7fd7382c6346bbd66687d12bbaad3a89a2d2c303ee6cf20b048" -dependencies = [ - "asn1-rs-derive", - "asn1-rs-impl", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", - "thiserror 1.0.69", - "time", -] - -[[package]] -name = "asn1-rs-derive" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", - "synstructure", -] - -[[package]] -name = "asn1-rs-impl" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "async-trait" -version = "0.1.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "backtrace" -version = "0.3.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" -dependencies = [ - "addr2line", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", - "windows-targets 0.52.6", -] - -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - -[[package]] -name = "base64" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" -dependencies = [ - "serde", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "bumpalo" -version = "3.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "bytes" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" - -[[package]] -name = "cache-padded" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "981520c98f422fcc584dc1a95c334e6953900b9106bc47a9839b81790009eb21" - -[[package]] -name = "cc" -version = "1.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" -dependencies = [ - "shlex", -] - -[[package]] -name = "cesu8" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" - -[[package]] -name = "cfg-if" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" - -[[package]] -name = "cfg_aliases" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" - -[[package]] -name = "cfg_aliases" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" - -[[package]] -name = "chrono" -version = "0.4.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "num-traits", - "serde", - "windows-targets 0.52.6", -] - -[[package]] -name = "cipher" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" -dependencies = [ - "crypto-common", - "inout", -] - -[[package]] -name = "cobs" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" - -[[package]] -name = "combine" -version = "4.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" -dependencies = [ - "bytes", - "memchr", -] - -[[package]] -name = "concurrent-queue" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - -[[package]] -name = "const_format" -version = "0.2.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c655d81ff1114fb0dcdea9225ea9f0cc712a6f8d189378e82bdf62a473a64b" -dependencies = [ - "const_format_proc_macros", -] - -[[package]] -name = "const_format_proc_macros" -version = "0.2.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff1a44b93f47b1bac19a27932f5c591e43d1ba357ee4f61526c8a25603f0eb1" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - -[[package]] -name = "cpufeatures" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" -dependencies = [ - "libc", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-queue" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "darling" -version = "0.20.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.20.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 2.0.87", -] - -[[package]] -name = "darling_macro" -version = "0.20.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" -dependencies = [ - "darling_core", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "data-encoding" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" - -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "pem-rfc7468", - "zeroize", -] - -[[package]] -name = "der-parser" -version = "9.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553" -dependencies = [ - "asn1-rs", - "displaydoc", - "nom", - "num-bigint", - "num-traits", - "rusticata-macros", -] - -[[package]] -name = "deranged" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" -dependencies = [ - "powerfmt", - "serde", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "const-oid", - "crypto-common", - "subtle", -] - -[[package]] -name = "dirs" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" -dependencies = [ - "libc", - "option-ext", - "redox_users", - "windows-sys 0.48.0", -] - -[[package]] -name = "displaydoc" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "dyn-clone" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" - -[[package]] -name = "either" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "event-listener" -version = "5.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" -dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite", -] - -[[package]] -name = "filepath" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7faa16fcec147281a1719947edb44af4f9124964bf7476bd5f5356a48e44dcc" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "fixedbitset" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" - -[[package]] -name = "flume" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" -dependencies = [ - "futures-core", - "futures-sink", - "nanorand", - "spin 0.9.8", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "form_urlencoded" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "futures" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" - -[[package]] -name = "futures-executor" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" - -[[package]] -name = "futures-macro" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "futures-sink" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" - -[[package]] -name = "futures-task" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" - -[[package]] -name = "futures-util" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "wasi", - "wasm-bindgen", -] - -[[package]] -name = "gimli" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" - -[[package]] -name = "git-version" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad568aa3db0fcbc81f2f116137f263d7304f512a1209b35b85150d3ef88ad19" -dependencies = [ - "git-version-macro", -] - -[[package]] -name = "git-version-macro" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", - "allocator-api2", -] - -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - -[[package]] -name = "http" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "httparse" -version = "1.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" - -[[package]] -name = "humantime" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f" - -[[package]] -name = "iana-time-zone" -version = "0.1.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "idna" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown 0.14.5", - "serde", -] - -[[package]] -name = "inout" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" -dependencies = [ - "generic-array", -] - -[[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-kit-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "617ee6cf8e3f66f3b4ea67a4058564628cde41901316e19f559e14c7c72c5e7b" -dependencies = [ - "core-foundation-sys", - "mach2", -] - -[[package]] -name = "ipnetwork" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf466541e9d546596ee94f9f69590f89473455f88372423e0008fc1a7daf100e" -dependencies = [ - "serde", -] - -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" - -[[package]] -name = "jni" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6df18c2e3db7e453d3c6ac5b3e9d5182664d28788126d39b91f2d1e22b017ec" -dependencies = [ - "cesu8", - "combine", - "jni-sys", - "log", - "thiserror 1.0.69", - "walkdir", -] - -[[package]] -name = "jni-sys" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" - -[[package]] -name = "js-sys" -version = "0.3.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "json5" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1" -dependencies = [ - "pest", - "pest_derive", - "serde", -] - -[[package]] -name = "keccak" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" -dependencies = [ - "cpufeatures", -] - -[[package]] -name = "keyed-set" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a3ec39d2dc17953a1540d63906a112088f79b2e46833b4ed65bc9de3904ae34" -dependencies = [ - "hashbrown 0.14.5", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin 0.9.8", -] - -[[package]] -name = "leb128" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "libloading" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" -dependencies = [ - "cfg-if", - "windows-targets 0.52.6", -] - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "libredox" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" -dependencies = [ - "bitflags 2.6.0", - "libc", -] - -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" - -[[package]] -name = "lz4_flex" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75761162ae2b0e580d7e7c390558127e5f01b4194debd6221fd8c207fc80e3f5" -dependencies = [ - "twox-hash", -] - -[[package]] -name = "mach2" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" -dependencies = [ - "libc", -] - -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata 0.1.10", -] - -[[package]] -name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - -[[package]] -name = "memoffset" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" -dependencies = [ - "autocfg", -] - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - -[[package]] -name = "miniz_oxide" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" -dependencies = [ - "adler2", -] - -[[package]] -name = "mio" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.48.0", -] - -[[package]] -name = "mio" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" -dependencies = [ - "hermit-abi", - "libc", - "wasi", - "windows-sys 0.52.0", -] - -[[package]] -name = "mio-serial" -version = "5.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20a4c60ca5c9c0e114b3bd66ff4aa5f9b2b175442be51ca6c4365d687a97a2ac" -dependencies = [ - "log", - "mio 0.8.11", - "nix 0.26.4", - "serialport", - "winapi", -] - -[[package]] -name = "nanorand" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" -dependencies = [ - "getrandom", -] - -[[package]] -name = "nix" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" -dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset 0.7.1", - "pin-utils", -] - -[[package]] -name = "nix" -version = "0.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" -dependencies = [ - "bitflags 2.6.0", - "cfg-if", - "libc", - "memoffset 0.9.1", -] - -[[package]] -name = "nix" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" -dependencies = [ - "bitflags 2.6.0", - "cfg-if", - "cfg_aliases 0.2.1", - "libc", -] - -[[package]] -name = "no-std-net" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43794a0ace135be66a25d3ae77d41b91615fb68ae937f904090203e81f755b65" - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - -[[package]] -name = "nonempty-collections" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f301452dbaf00f14ca0c8204e46cf0c9a96f53543ac72cefa9b4d91c19e0ac" -dependencies = [ - "serde", -] - -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - -[[package]] -name = "num-bigint" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-bigint-dig" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" -dependencies = [ - "byteorder", - "lazy_static", - "libm", - "num-integer", - "num-iter", - "num-traits", - "rand", - "smallvec", - "zeroize", -] - -[[package]] -name = "num-conv" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", - "libm", -] - -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "object" -version = "0.36.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" -dependencies = [ - "memchr", -] - -[[package]] -name = "oid-registry" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d8034d9489cdaf79228eb9f6a3b8d7bb32ba00d6645ebd48eef4077ceb5bd9" -dependencies = [ - "asn1-rs", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "opaque-types" -version = "0.1.0" -dependencies = [ - "const_format", - "flume", - "tokio", - "zenoh", - "zenoh-ext", - "zenoh-protocol", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "option-ext" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" - -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - -[[package]] -name = "parking" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" - -[[package]] -name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" -dependencies = [ - "cfg-if", - "instant", - "libc", - "redox_syscall", - "smallvec", - "winapi", -] - -[[package]] -name = "paste" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" - -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - -[[package]] -name = "percent-encoding" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" - -[[package]] -name = "pest" -version = "2.7.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c73c26c01b8c87956cea613c907c9d6ecffd8d18a2a5908e5de0adfaa185cea" -dependencies = [ - "memchr", - "thiserror 1.0.69", - "ucd-trie", -] - -[[package]] -name = "pest_derive" -version = "2.7.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "664d22978e2815783adbdd2c588b455b1bd625299ce36b2a99881ac9627e6d8d" -dependencies = [ - "pest", - "pest_generator", -] - -[[package]] -name = "pest_generator" -version = "2.7.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2d5487022d5d33f4c30d91c22afa240ce2a644e87fe08caad974d4eab6badbe" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "pest_meta" -version = "2.7.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0091754bbd0ea592c4deb3a122ce8ecbb0753b738aa82bc055fcc2eccc8d8174" -dependencies = [ - "once_cell", - "pest", - "sha2", -] - -[[package]] -name = "petgraph" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" -dependencies = [ - "fixedbitset", - "indexmap 2.5.0", -] - -[[package]] -name = "phf" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" -dependencies = [ - "phf_macros", - "phf_shared", -] - -[[package]] -name = "phf_generator" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" -dependencies = [ - "phf_shared", - "rand", -] - -[[package]] -name = "phf_macros" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" -dependencies = [ - "phf_generator", - "phf_shared", - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "phf_shared" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" -dependencies = [ - "siphasher", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkcs1" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" -dependencies = [ - "der", - "pkcs8", - "spki", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - -[[package]] -name = "pnet_base" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc190d4067df16af3aba49b3b74c469e611cad6314676eaf1157f31aa0fb2f7" -dependencies = [ - "no-std-net", -] - -[[package]] -name = "pnet_datalink" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79e70ec0be163102a332e1d2d5586d362ad76b01cec86f830241f2b6452a7b7" -dependencies = [ - "ipnetwork", - "libc", - "pnet_base", - "pnet_sys", - "winapi", -] - -[[package]] -name = "pnet_sys" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d4643d3d4db6b08741050c2f3afa9a892c4244c085a72fcda93c9c2c9a00f4b" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - -[[package]] -name = "ppv-lite86" -version = "0.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" -dependencies = [ - "zerocopy", -] - -[[package]] -name = "proc-macro-crate" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" -dependencies = [ - "toml_edit", -] - -[[package]] -name = "proc-macro2" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quinn" -version = "0.11.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" -dependencies = [ - "bytes", - "pin-project-lite", - "quinn-proto", - "quinn-udp", - "rustc-hash", - "rustls", - "socket2", - "thiserror 1.0.69", - "tokio", - "tracing", -] - -[[package]] -name = "quinn-proto" -version = "0.11.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" -dependencies = [ - "bytes", - "rand", - "ring", - "rustc-hash", - "rustls", - "rustls-platform-verifier", - "slab", - "thiserror 1.0.69", - "tinyvec", - "tracing", -] - -[[package]] -name = "quinn-udp" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" -dependencies = [ - "libc", - "once_cell", - "socket2", - "tracing", - "windows-sys 0.59.0", -] - -[[package]] -name = "quote" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_users" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" -dependencies = [ - "getrandom", - "libredox", - "thiserror 1.0.69", -] - -[[package]] -name = "ref-cast" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" -dependencies = [ - "ref-cast-impl", -] - -[[package]] -name = "ref-cast-impl" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "regex" -version = "1.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", -] - -[[package]] -name = "regex-automata" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax 0.8.4", -] - -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - -[[package]] -name = "regex-syntax" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" - -[[package]] -name = "ring" -version = "0.17.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ac5d832aa16abd7d1def883a8545280c20a60f523a370aa3a9617c2b8550ee" -dependencies = [ - "cc", - "cfg-if", - "getrandom", - "libc", - "untrusted", - "windows-sys 0.52.0", -] - -[[package]] -name = "ringbuffer-spsc" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd1938faa63a2362ee1747afb2d10567d0fb1413b9cbd6198a8541485c4f773" -dependencies = [ - "array-init", - "cache-padded", -] - -[[package]] -name = "ron" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" -dependencies = [ - "base64 0.21.7", - "bitflags 2.6.0", - "serde", - "serde_derive", -] - -[[package]] -name = "rsa" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" -dependencies = [ - "const-oid", - "digest", - "num-bigint-dig", - "num-integer", - "num-traits", - "pkcs1", - "pkcs8", - "rand_core", - "signature", - "spki", - "subtle", - "zeroize", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" - -[[package]] -name = "rustc-hash" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" - -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "rusticata-macros" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" -dependencies = [ - "nom", -] - -[[package]] -name = "rustls" -version = "0.23.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395" -dependencies = [ - "log", - "once_cell", - "ring", - "rustls-pki-types", - "rustls-webpki", - "subtle", - "zeroize", -] - -[[package]] -name = "rustls-native-certs" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" -dependencies = [ - "openssl-probe", - "rustls-pemfile", - "rustls-pki-types", - "schannel", - "security-framework", -] - -[[package]] -name = "rustls-pemfile" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" -dependencies = [ - "base64 0.22.1", - "rustls-pki-types", -] - -[[package]] -name = "rustls-pki-types" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" - -[[package]] -name = "rustls-platform-verifier" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afbb878bdfdf63a336a5e63561b1835e7a8c91524f51621db870169eac84b490" -dependencies = [ - "core-foundation", - "core-foundation-sys", - "jni", - "log", - "once_cell", - "rustls", - "rustls-native-certs", - "rustls-platform-verifier-android", - "rustls-webpki", - "security-framework", - "security-framework-sys", - "webpki-roots", - "winapi", -] - -[[package]] -name = "rustls-platform-verifier-android" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" - -[[package]] -name = "rustls-webpki" -version = "0.102.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" -dependencies = [ - "ring", - "rustls-pki-types", - "untrusted", -] - -[[package]] -name = "rustversion" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" - -[[package]] -name = "ryu" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "schannel" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" -dependencies = [ - "windows-sys 0.59.0", -] - -[[package]] -name = "schemars" -version = "0.8.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" -dependencies = [ - "dyn-clone", - "either", - "schemars_derive", - "serde", - "serde_json", -] - -[[package]] -name = "schemars_derive" -version = "0.8.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" -dependencies = [ - "proc-macro2", - "quote", - "serde_derive_internals", - "syn 2.0.87", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "secrecy" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" -dependencies = [ - "serde", - "zeroize", -] - -[[package]] -name = "security-framework" -version = "2.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" -dependencies = [ - "bitflags 2.6.0", - "core-foundation", - "core-foundation-sys", - "libc", - "num-bigint", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "semver" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" - -[[package]] -name = "serde" -version = "1.0.210" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.210" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "serde_derive_internals" -version = "0.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "serde_json" -version = "1.0.128" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" -dependencies = [ - "itoa", - "memchr", - "ryu", - "serde", -] - -[[package]] -name = "serde_with" -version = "3.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" -dependencies = [ - "base64 0.22.1", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.5.0", - "serde", - "serde_derive", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "3.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "serde_yaml" -version = "0.9.34+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" -dependencies = [ - "indexmap 2.5.0", - "itoa", - "ryu", - "serde", - "unsafe-libyaml", -] - -[[package]] -name = "serialport" -version = "4.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "241ebb629ed9bf598b2b392ba42aa429f9ef2a0099001246a36ac4c084ee183f" -dependencies = [ - "bitflags 2.6.0", - "cfg-if", - "core-foundation-sys", - "io-kit-sys", - "mach2", - "nix 0.26.4", - "scopeguard", - "unescaper", - "winapi", -] - -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "sha2" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "sha2-const-stable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f179d4e11094a893b82fff208f74d448a7512f99f5a0acbd5c679b705f83ed9" - -[[package]] -name = "sha3" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" -dependencies = [ - "digest", - "keccak", -] - -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "shellexpand" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b" -dependencies = [ - "dirs", -] - -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core", -] - -[[package]] -name = "siphasher" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" - -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] - -[[package]] -name = "smallvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - -[[package]] -name = "socket2" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spin" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5fe4ccb98d9c292d56fec89a5e07da7fc4cf0dc11e156b41793132775d3e591" - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "stabby" -version = "36.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b7e94eaf470c2e76b5f15fb2fb49714471a36cc512df5ee231e62e82ec79f8" -dependencies = [ - "rustversion", - "stabby-abi", -] - -[[package]] -name = "stabby-abi" -version = "36.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc7a63b8276b54e51bfffe3d85da56e7906b2dcfcb29018a8ab666c06734c1a" -dependencies = [ - "rustc_version", - "rustversion", - "sha2-const-stable", - "stabby-macros", -] - -[[package]] -name = "stabby-macros" -version = "36.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eecb7ec5611ec93ec79d120fbe55f31bea234dc1bed1001d4a071bb688651615" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "rand", - "syn 1.0.109", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "static_init" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a2a1c578e98c1c16fc3b8ec1328f7659a500737d7a0c6d625e73e830ff9c1f6" -dependencies = [ - "bitflags 1.3.2", - "cfg_aliases 0.1.1", - "libc", - "parking_lot", - "parking_lot_core", - "static_init_macro", - "winapi", -] - -[[package]] -name = "static_init_macro" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a2595fc3aa78f2d0e45dd425b22282dd863273761cc77780914b2cf3003acf" -dependencies = [ - "cfg_aliases 0.1.1", - "memchr", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "synstructure" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "thiserror" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl 1.0.69", -] - -[[package]] -name = "thiserror" -version = "2.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" -dependencies = [ - "thiserror-impl 2.0.11", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "thiserror-impl" -version = "2.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "thread-priority" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d3b04d33c9633b8662b167b847c7ab521f83d1ae20f2321b65b5b925e532e36" -dependencies = [ - "bitflags 2.6.0", - "cfg-if", - "libc", - "log", - "rustversion", - "winapi", -] - -[[package]] -name = "thread_local" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" -dependencies = [ - "cfg-if", - "once_cell", -] - -[[package]] -name = "time" -version = "0.3.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" -dependencies = [ - "deranged", - "itoa", - "num-conv", - "powerfmt", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" - -[[package]] -name = "time-macros" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" -dependencies = [ - "num-conv", - "time-core", -] - -[[package]] -name = "tinyvec" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tls-listener" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab41256c16d6fc2b3021545f20bf77a73200b18bd54040ac656dddfca6205bfa" -dependencies = [ - "futures-util", - "pin-project-lite", - "thiserror 2.0.11", - "tokio", - "tokio-rustls", -] - -[[package]] -name = "token-cell" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4a2b964fdb303b08a4eab04d7c1bad2bca33f8eee334ccd28802f1041c6eb87" -dependencies = [ - "paste", -] - -[[package]] -name = "tokio" -version = "1.40.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" -dependencies = [ - "backtrace", - "bytes", - "libc", - "mio 1.0.2", - "pin-project-lite", - "socket2", - "tokio-macros", - "windows-sys 0.52.0", -] - -[[package]] -name = "tokio-macros" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "tokio-rustls" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" -dependencies = [ - "rustls", - "tokio", -] - -[[package]] -name = "tokio-serial" -version = "5.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa6e2e4cf0520a99c5f87d5abb24172b5bd220de57c3181baaaa5440540c64aa" -dependencies = [ - "cfg-if", - "futures", - "log", - "mio-serial", - "tokio", -] - -[[package]] -name = "tokio-tungstenite" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" -dependencies = [ - "futures-util", - "log", - "tokio", - "tungstenite", -] - -[[package]] -name = "tokio-util" -version = "0.7.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "futures-util", - "hashbrown 0.14.5", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-vsock" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e336ac4b36df625d5429a735dd5847732fe5f62010e3ce0c50f3705d44730f8" -dependencies = [ - "bytes", - "futures", - "libc", - "tokio", - "vsock", -] - -[[package]] -name = "toml_datetime" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" - -[[package]] -name = "toml_edit" -version = "0.22.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" -dependencies = [ - "indexmap 2.5.0", - "toml_datetime", - "winnow", -] - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "log", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" -dependencies = [ - "log", - "once_cell", - "tracing-core", -] - -[[package]] -name = "tracing-serde" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" -dependencies = [ - "serde", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" -dependencies = [ - "matchers", - "nu-ansi-term", - "once_cell", - "regex", - "serde", - "serde_json", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", - "tracing-serde", -] - -[[package]] -name = "tungstenite" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18e5b8366ee7a95b16d32197d0b2604b43a0be89dc5fac9f8e96ccafbaedda8a" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http", - "httparse", - "log", - "rand", - "sha1", - "thiserror 1.0.69", - "utf-8", -] - -[[package]] -name = "twox-hash" -version = "1.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" -dependencies = [ - "cfg-if", - "static_assertions", -] - -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "ucd-trie" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" - -[[package]] -name = "uhlc" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bbb93b0c2258fe1e81a84d8de5391f2577b039decabf75a6441ea1ebbf4cb5" -dependencies = [ - "humantime", - "lazy_static", - "log", - "rand", - "serde", - "spin 0.10.0", -] - -[[package]] -name = "unescaper" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c878a167baa8afd137494101a688ef8c67125089ff2249284bd2b5f9bfedb815" -dependencies = [ - "thiserror 1.0.69", -] - -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - -[[package]] -name = "unicode-ident" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" - -[[package]] -name = "unicode-normalization" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-xid" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" - -[[package]] -name = "unix-named-pipe" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ad653da8f36ac5825ba06642b5a3cce14a4e52c6a5fab4a8928d53f4426dae2" -dependencies = [ - "errno", - "libc", -] - -[[package]] -name = "unsafe-libyaml" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" - -[[package]] -name = "untrusted" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" - -[[package]] -name = "unzip-n" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7e85a0596447f0f2ac090e16bc4c516c6fe91771fb0c0ccf7fa3dae896b9c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "url" -version = "2.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - -[[package]] -name = "utf-8" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" - -[[package]] -name = "uuid" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" -dependencies = [ - "getrandom", -] - -[[package]] -name = "validated_struct" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feef04c049b4beae3037a2a31b8da40d8cebec0b97456f24c7de0ede4ed9efed" -dependencies = [ - "json5", - "serde", - "serde_json", - "validated_struct_macros", -] - -[[package]] -name = "validated_struct_macros" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d4444a980afa9ef0d29c2a3f4d952ec0495a7a996a9c78b52698b71bc21edb4" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unzip-n", -] - -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "vsock" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfb6e7a74830912f1f4a7655227c9ded1ea4e9136676311fedf54bedb412f35" -dependencies = [ - "libc", - "nix 0.27.1", -] - -[[package]] -name = "walkdir" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.93" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" -dependencies = [ - "cfg-if", - "once_cell", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.93" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.87", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.93" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.93" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.93" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" - -[[package]] -name = "webpki-roots" -version = "0.26.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" -dependencies = [ - "rustls-pki-types", -] - -[[package]] -name = "win-sys" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b7b128a98c1cfa201b09eb49ba285887deb3cbe7466a98850eb1adabb452be5" -dependencies = [ - "windows", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" -dependencies = [ - "windows-sys 0.59.0", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45296b64204227616fdbf2614cefa4c236b98ee64dfaaaa435207ed99fe7829f" -dependencies = [ - "windows_aarch64_msvc 0.34.0", - "windows_i686_gnu 0.34.0", - "windows_i686_msvc 0.34.0", - "windows_x86_64_gnu 0.34.0", - "windows_x86_64_msvc 0.34.0", -] - -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "winnow" -version = "0.6.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" -dependencies = [ - "memchr", -] - -[[package]] -name = "x509-parser" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcbc162f30700d6f3f82a24bf7cc62ffe7caea42c0b2cba8bf7f3ae50cf51f69" -dependencies = [ - "asn1-rs", - "data-encoding", - "der-parser", - "lazy_static", - "nom", - "oid-registry", - "rusticata-macros", - "thiserror 1.0.69", - "time", -] - -[[package]] -name = "z-serial" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1660dfc9f90480610f94c285a9a967b49cd2f57b3b1267d9bd7fd5d4f57c36c8" -dependencies = [ - "cobs", - "futures", - "log", - "tokio", - "tokio-serial", -] - -[[package]] -name = "zenoh" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "ahash", - "arc-swap", - "async-trait", - "bytes", - "flume", - "futures", - "git-version", - "itertools", - "json5", - "lazy_static", - "nonempty-collections", - "once_cell", - "paste", - "petgraph", - "phf", - "rand", - "ref-cast", - "rustc_version", - "serde", - "serde_json", - "socket2", - "tokio", - "tokio-util", - "tracing", - "uhlc", - "vec_map", - "zenoh-buffers", - "zenoh-codec", - "zenoh-collections", - "zenoh-config", - "zenoh-core", - "zenoh-keyexpr", - "zenoh-link", - "zenoh-link-commons", - "zenoh-macros", - "zenoh-plugin-trait", - "zenoh-protocol", - "zenoh-result", - "zenoh-runtime", - "zenoh-shm", - "zenoh-sync", - "zenoh-task", - "zenoh-transport", - "zenoh-util", -] - -[[package]] -name = "zenoh-buffers" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "zenoh-collections", -] - -[[package]] -name = "zenoh-codec" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "tracing", - "uhlc", - "zenoh-buffers", - "zenoh-protocol", - "zenoh-shm", -] - -[[package]] -name = "zenoh-collections" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "ahash", -] - -[[package]] -name = "zenoh-config" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "json5", - "nonempty-collections", - "num_cpus", - "secrecy", - "serde", - "serde_json", - "serde_with", - "serde_yaml", - "tracing", - "uhlc", - "validated_struct", - "zenoh-core", - "zenoh-keyexpr", - "zenoh-macros", - "zenoh-protocol", - "zenoh-result", - "zenoh-util", -] - -[[package]] -name = "zenoh-core" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "lazy_static", - "tokio", - "zenoh-result", - "zenoh-runtime", -] - -[[package]] -name = "zenoh-crypto" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "aes", - "hmac", - "rand", - "rand_chacha", - "sha3", - "zenoh-result", -] - -[[package]] -name = "zenoh-ext" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "async-trait", - "bincode", - "flume", - "futures", - "leb128", - "serde", - "tokio", - "tracing", - "uhlc", - "zenoh", - "zenoh-macros", - "zenoh-util", -] - -[[package]] -name = "zenoh-keyexpr" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "getrandom", - "hashbrown 0.14.5", - "keyed-set", - "rand", - "schemars", - "serde", - "token-cell", - "zenoh-result", -] - -[[package]] -name = "zenoh-link" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "zenoh-config", - "zenoh-link-commons", - "zenoh-link-quic", - "zenoh-link-quic_datagram", - "zenoh-link-serial", - "zenoh-link-tcp", - "zenoh-link-tls", - "zenoh-link-udp", - "zenoh-link-unixpipe", - "zenoh-link-unixsock_stream", - "zenoh-link-vsock", - "zenoh-link-ws", - "zenoh-protocol", - "zenoh-result", -] - -[[package]] -name = "zenoh-link-commons" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "async-trait", - "base64 0.22.1", - "flume", - "futures", - "quinn", - "rustls", - "rustls-pemfile", - "rustls-pki-types", - "rustls-webpki", - "secrecy", - "serde", - "socket2", - "time", - "tokio", - "tokio-util", - "tracing", - "webpki-roots", - "x509-parser", - "zenoh-buffers", - "zenoh-codec", - "zenoh-config", - "zenoh-core", - "zenoh-protocol", - "zenoh-result", - "zenoh-runtime", - "zenoh-util", -] - -[[package]] -name = "zenoh-link-quic" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "async-trait", - "base64 0.22.1", - "quinn", - "rustls", - "rustls-pemfile", - "rustls-webpki", - "secrecy", - "time", - "tokio", - "tokio-util", - "tracing", - "webpki-roots", - "zenoh-config", - "zenoh-core", - "zenoh-link-commons", - "zenoh-protocol", - "zenoh-result", - "zenoh-util", -] - -[[package]] -name = "zenoh-link-quic_datagram" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "async-trait", - "quinn", - "rustls", - "rustls-webpki", - "time", - "tokio", - "tokio-util", - "tracing", - "zenoh-core", - "zenoh-link-commons", - "zenoh-protocol", - "zenoh-result", - "zenoh-util", -] - -[[package]] -name = "zenoh-link-serial" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "async-trait", - "tokio", - "tokio-util", - "tracing", - "uuid", - "z-serial", - "zenoh-core", - "zenoh-link-commons", - "zenoh-protocol", - "zenoh-result", - "zenoh-runtime", -] - -[[package]] -name = "zenoh-link-tcp" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "async-trait", - "socket2", - "tokio", - "tokio-util", - "tracing", - "zenoh-config", - "zenoh-core", - "zenoh-link-commons", - "zenoh-protocol", - "zenoh-result", -] - -[[package]] -name = "zenoh-link-tls" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "async-trait", - "base64 0.22.1", - "rustls", - "rustls-pemfile", - "rustls-pki-types", - "rustls-webpki", - "secrecy", - "socket2", - "time", - "tls-listener", - "tokio", - "tokio-rustls", - "tokio-util", - "tracing", - "webpki-roots", - "x509-parser", - "zenoh-config", - "zenoh-core", - "zenoh-link-commons", - "zenoh-protocol", - "zenoh-result", - "zenoh-runtime", -] - -[[package]] -name = "zenoh-link-udp" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "async-trait", - "libc", - "socket2", - "tokio", - "tokio-util", - "tracing", - "windows-sys 0.59.0", - "zenoh-buffers", - "zenoh-core", - "zenoh-link-commons", - "zenoh-protocol", - "zenoh-result", - "zenoh-sync", - "zenoh-util", -] - -[[package]] -name = "zenoh-link-unixpipe" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "advisory-lock", - "async-trait", - "filepath", - "nix 0.29.0", - "rand", - "tokio", - "tokio-util", - "tracing", - "unix-named-pipe", - "zenoh-config", - "zenoh-core", - "zenoh-link-commons", - "zenoh-protocol", - "zenoh-result", - "zenoh-runtime", -] - -[[package]] -name = "zenoh-link-unixsock_stream" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "async-trait", - "nix 0.29.0", - "tokio", - "tokio-util", - "tracing", - "uuid", - "zenoh-core", - "zenoh-link-commons", - "zenoh-protocol", - "zenoh-result", - "zenoh-runtime", -] - -[[package]] -name = "zenoh-link-vsock" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "async-trait", - "libc", - "tokio", - "tokio-util", - "tokio-vsock", - "tracing", - "zenoh-core", - "zenoh-link-commons", - "zenoh-protocol", - "zenoh-result", - "zenoh-runtime", -] - -[[package]] -name = "zenoh-link-ws" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "async-trait", - "futures-util", - "tokio", - "tokio-tungstenite", - "tokio-util", - "tracing", - "url", - "zenoh-core", - "zenoh-link-commons", - "zenoh-protocol", - "zenoh-result", - "zenoh-runtime", - "zenoh-util", -] - -[[package]] -name = "zenoh-macros" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", - "zenoh-keyexpr", -] - -[[package]] -name = "zenoh-plugin-trait" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "git-version", - "libloading", - "serde", - "tracing", - "zenoh-config", - "zenoh-keyexpr", - "zenoh-macros", - "zenoh-result", - "zenoh-util", -] - -[[package]] -name = "zenoh-protocol" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "const_format", - "rand", - "serde", - "uhlc", - "zenoh-buffers", - "zenoh-keyexpr", - "zenoh-result", -] - -[[package]] -name = "zenoh-result" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "anyhow", -] - -[[package]] -name = "zenoh-runtime" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "lazy_static", - "ron", - "serde", - "tokio", - "tracing", - "zenoh-macros", - "zenoh-result", -] - -[[package]] -name = "zenoh-shm" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "advisory-lock", - "async-trait", - "cfg_aliases 0.2.1", - "crossbeam-channel", - "crossbeam-queue", - "nix 0.29.0", - "num-traits", - "rand", - "stabby", - "static_assertions", - "static_init", - "thread-priority", - "tokio", - "tracing", - "win-sys", - "winapi", - "zenoh-buffers", - "zenoh-core", - "zenoh-macros", - "zenoh-result", -] - -[[package]] -name = "zenoh-sync" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "arc-swap", - "event-listener", - "futures", - "tokio", - "zenoh-buffers", - "zenoh-collections", - "zenoh-core", -] - -[[package]] -name = "zenoh-task" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "futures", - "tokio", - "tokio-util", - "tracing", - "zenoh-core", - "zenoh-runtime", -] - -[[package]] -name = "zenoh-transport" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "async-trait", - "crossbeam-utils", - "flume", - "lazy_static", - "lz4_flex", - "paste", - "rand", - "ringbuffer-spsc", - "rsa", - "serde", - "sha3", - "tokio", - "tokio-util", - "tracing", - "zenoh-buffers", - "zenoh-codec", - "zenoh-config", - "zenoh-core", - "zenoh-crypto", - "zenoh-link", - "zenoh-link-commons", - "zenoh-protocol", - "zenoh-result", - "zenoh-runtime", - "zenoh-shm", - "zenoh-sync", - "zenoh-task", - "zenoh-util", -] - -[[package]] -name = "zenoh-util" -version = "1.5.0" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#9f3ccaa54b8a76d492077ec9067207558330b482" -dependencies = [ - "async-trait", - "const_format", - "flume", - "home", - "humantime", - "lazy_static", - "libc", - "libloading", - "pnet_datalink", - "serde", - "serde_json", - "shellexpand", - "tokio", - "tracing", - "tracing-subscriber", - "winapi", - "zenoh-core", - "zenoh-result", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "byteorder", - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "zeroize" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/build-resources/opaque-types/Cargo.toml b/build-resources/opaque-types/Cargo.toml deleted file mode 100644 index 692452567..000000000 --- a/build-resources/opaque-types/Cargo.toml +++ /dev/null @@ -1,39 +0,0 @@ -[package] -name = "opaque-types" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[features] -shared-memory = ["zenoh/shared-memory", "zenoh-protocol/shared-memory"] -unstable = ["zenoh/unstable", "zenoh-ext/unstable"] -auth_pubkey = ["zenoh/auth_pubkey"] -auth_usrpwd = ["zenoh/auth_usrpwd"] -transport_multilink = ["zenoh/transport_multilink"] -transport_compression = ["zenoh/transport_compression"] -transport_quic = ["zenoh/transport_quic"] -transport_serial = ["zenoh/transport_serial"] -transport_unixpipe = ["zenoh/transport_unixpipe"] -transport_tcp = ["zenoh/transport_tcp"] -transport_tls = ["zenoh/transport_tls"] -transport_udp = ["zenoh/transport_udp"] -transport_unixsock-stream = ["zenoh/transport_unixsock-stream"] -transport_ws = ["zenoh/transport_ws"] -transport_vsock = ["zenoh/transport_vsock"] - -panic = [ -] # The whole purpose of this project is to generate set of compilation panic messages with calculated structure sizes. To do it the "panic" feature should be set. By default we just want to check if build is successful. -default = ["zenoh/default"] - -[dependencies] -zenoh = { version = "1.5.0", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false, features = [ - "internal", -] } -zenoh-ext = { version = "1.5.0", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false, features = [ - "internal", -] } -zenoh-protocol = { version = "1.5.0", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" } -const_format = "0.2.32" -flume = "*" -tokio = "*" diff --git a/build-resources/opaque-types/src/lib.rs b/build-resources/opaque-types/src/lib.rs deleted file mode 100644 index b392f1b3a..000000000 --- a/build-resources/opaque-types/src/lib.rs +++ /dev/null @@ -1,557 +0,0 @@ -#![allow(unused_doc_comments)] -#![allow(dead_code)] -#![allow(deprecated)] -use core::ffi::c_void; -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -use std::sync::Arc; -use std::{ - sync::{Condvar, Mutex, MutexGuard}, - thread::JoinHandle, -}; - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -use zenoh::shm::{ - zshm, zshmmut, AllocLayout, ChunkAllocResult, ChunkDescriptor, MemoryLayout, - PosixShmProviderBackend, ProtocolID, PtrInSegment, ShmClient, ShmClientStorage, ShmProvider, - ShmProviderBackend, WithProtocolID, ZLayoutError, ZShm, ZShmMut, -}; -use zenoh::{ - bytes::{Encoding, ZBytes, ZBytesReader, ZBytesSliceIterator, ZBytesWriter}, - config::Config, - handlers::{FifoChannelHandler, RingChannelHandler}, - key_expr::KeyExpr, - liveliness::LivelinessToken, - matching::MatchingListener, - pubsub::{Publisher, Subscriber}, - query::{Querier, Query, Queryable, Reply, ReplyError}, - sample::Sample, - scouting::Hello, - session::{Session, ZenohId}, - time::Timestamp, -}; -#[cfg(feature = "unstable")] -use zenoh::{ - internal::builders::close::NolocalJoinHandle, sample::SourceInfo, session::EntityGlobalId, -}; - -#[macro_export] -macro_rules! get_opaque_type_data { - ($src_type:ty, $name:ident) => { - const _: () = { - use const_format::concatcp; - const DST_NAME: &str = stringify!($name); - const ALIGN: usize = std::mem::align_of::<$src_type>(); - const SIZE: usize = std::mem::size_of::<$src_type>(); - const INFO_MESSAGE: &str = - concatcp!("type: ", DST_NAME, ", align: ", ALIGN, ", size: ", SIZE); - #[cfg(feature = "panic")] - panic!("{}", INFO_MESSAGE); - }; - }; -} - -/// A Zenoh data. -/// -/// To minimize copies and reallocations, Zenoh may provide data in several separate buffers. -get_opaque_type_data!(ZBytes, z_owned_bytes_t); -/// A loaned Zenoh data. -get_opaque_type_data!(ZBytes, z_loaned_bytes_t); - -pub struct CSlice { - _data: *const u8, - _len: usize, - _drop: Option, - _context: *mut c_void, -} - -get_opaque_type_data!(CSlice, z_owned_slice_t); -/// A contiguous sequence of bytes owned by some other entity. -get_opaque_type_data!(CSlice, z_view_slice_t); -/// A loaned sequence of bytes. -get_opaque_type_data!(CSlice, z_loaned_slice_t); - -/// The wrapper type for strings allocated by Zenoh. -get_opaque_type_data!(CSlice, z_owned_string_t); -/// The view over a string. -get_opaque_type_data!(CSlice, z_view_string_t); -/// A loaned string. -get_opaque_type_data!(CSlice, z_loaned_string_t); - -/// An array of maybe-owned non-null terminated strings. -/// -get_opaque_type_data!(Vec, z_owned_string_array_t); -/// A loaned string array. -get_opaque_type_data!(Vec, z_loaned_string_array_t); - -/// An owned Zenoh sample. -/// -/// This is a read only type that can only be constructed by cloning a `z_loaned_sample_t`. -/// Like all owned types, it should be freed using z_drop or z_sample_drop. -get_opaque_type_data!(Option, z_owned_sample_t); -/// A loaned Zenoh sample. -get_opaque_type_data!(Sample, z_loaned_sample_t); - -/// A reader for payload. -get_opaque_type_data!(ZBytesReader<'static>, z_bytes_reader_t); - -/// An owned writer for payload. -get_opaque_type_data!(Option, z_owned_bytes_writer_t); -/// An loaned writer for payload. -get_opaque_type_data!(ZBytesWriter, z_loaned_bytes_writer_t); - -/// An iterator over slices of serialized data. -get_opaque_type_data!(ZBytesSliceIterator<'static>, z_bytes_slice_iterator_t); - -/// The encoding of Zenoh data. -get_opaque_type_data!(Encoding, z_owned_encoding_t); -/// A loaned Zenoh encoding. -get_opaque_type_data!(Encoding, z_loaned_encoding_t); - -/// An owned reply from a Queryable to a `z_get()`. -get_opaque_type_data!(Option, z_owned_reply_t); -/// A loaned reply. -get_opaque_type_data!(Reply, z_loaned_reply_t); - -/// A Zenoh reply error - a combination of reply error payload and its encoding. -get_opaque_type_data!(ReplyError, z_owned_reply_err_t); -/// A loaned Zenoh reply error. -get_opaque_type_data!(ReplyError, z_loaned_reply_err_t); - -/// An owned Zenoh query received by a queryable. -/// -/// Queries are atomically reference-counted, letting you extract them from the callback that handed them to you by cloning. -get_opaque_type_data!(Option, z_owned_query_t); -/// A loaned Zenoh query. -get_opaque_type_data!(Query, z_loaned_query_t); - -/// An owned Zenoh queryable . -/// -/// Responds to queries sent via `z_get()` with intersecting key expression. -get_opaque_type_data!(Option>, z_owned_queryable_t); -/// A loaned Zenoh queryable. -get_opaque_type_data!(Queryable<()>, z_loaned_queryable_t); - -/// An owned Zenoh querier. -/// -/// Sends queries to matching queryables. -get_opaque_type_data!(Option, z_owned_querier_t); -/// A loaned Zenoh queryable. -get_opaque_type_data!(Querier, z_loaned_querier_t); - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An owned Zenoh querying subscriber. -/// -/// In addition to receiving the data it is subscribed to, -/// it also will fetch data from a Queryable at startup and peridodically (using `ze_querying_subscriber_get()`). -get_opaque_type_data!( - Option<(zenoh_ext::FetchingSubscriber<()>, &'static Session)>, - ze_owned_querying_subscriber_t -); -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A loaned Zenoh querying subscriber. -get_opaque_type_data!( - (zenoh_ext::FetchingSubscriber<()>, &'static Session), - ze_loaned_querying_subscriber_t -); - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An owned Zenoh advanced subscriber. -/// -/// In addition to receiving the data it is subscribed to, -/// it is also able to receive notifications regarding missed samples and/or automatically recover them. -get_opaque_type_data!( - Option>, - ze_owned_advanced_subscriber_t -); -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A loaned Zenoh advanced subscriber. -get_opaque_type_data!( - zenoh_ext::AdvancedSubscriber<()>, - ze_loaned_advanced_subscriber_t -); -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An owned Zenoh sample miss listener. Missed samples can only be detected from advanced publishers, enabling sample miss detection. -/// -/// A listener that sends notification when the advanced subscriber misses a sample . -/// Dropping the corresponding subscriber, also drops the listener. -get_opaque_type_data!( - Option>, - ze_owned_sample_miss_listener_t -); - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An owned Zenoh advanced publisher. -/// -/// In addition to publishing the data, -/// it also maintains the storage, allowing matching subscribers to retrive missed samples. -get_opaque_type_data!( - Option>, - ze_owned_advanced_publisher_t -); -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A loaned Zenoh advanced publisher. -get_opaque_type_data!( - zenoh_ext::AdvancedPublisher<'static>, - ze_loaned_advanced_publisher_t -); -/// A Zenoh-allocated key expression . -/// -/// Key expressions can identify a single key or a set of keys. -/// -/// Examples : -/// - ``"key/expression"``. -/// - ``"key/ex*"``. -/// -/// Key expressions can be mapped to numerical ids through `z_declare_keyexpr` -/// for wire and computation efficiency. -/// -/// Internally key expressiobn can be either: -/// - A plain string expression. -/// - A pure numerical id. -/// - The combination of a numerical prefix and a string suffix. -get_opaque_type_data!(Option>, z_owned_keyexpr_t); -/// A user allocated string, viewed as a key expression. -get_opaque_type_data!(Option>, z_view_keyexpr_t); - -/// A loaned key expression. -/// -/// Key expressions can identify a single key or a set of keys. -/// -/// Examples : -/// - ``"key/expression"``. -/// - ``"key/ex*"``. -/// -/// Using `z_declare_keyexpr` allows Zenoh to optimize a key expression, -/// both for local processing and network-wise. -get_opaque_type_data!(KeyExpr<'static>, z_loaned_keyexpr_t); - -/// An owned Zenoh session. -get_opaque_type_data!(Option, z_owned_session_t); -/// A loaned Zenoh session. -get_opaque_type_data!(Session, z_loaned_session_t); - -#[cfg(feature = "unstable")] -/// An owned Close handle -get_opaque_type_data!( - Option>>, - zc_owned_concurrent_close_handle_t -); - -/// An owned Zenoh configuration. -get_opaque_type_data!(Option, z_owned_config_t); -/// A loaned Zenoh configuration. -get_opaque_type_data!(Config, z_loaned_config_t); - -/// @brief A Zenoh ID. -/// -/// In general, valid Zenoh IDs are LSB-first 128bit unsigned and non-zero integers. -get_opaque_type_data!(ZenohId, z_id_t); - -/// A Zenoh timestamp . -/// -/// It consists of a time generated by a Hybrid Logical Clock (HLC) in NPT64 format and a unique zenoh identifier. -get_opaque_type_data!(Timestamp, z_timestamp_t); - -/// An owned Zenoh publisher . -get_opaque_type_data!(Option>, z_owned_publisher_t); -/// A loaned Zenoh publisher. -get_opaque_type_data!(Publisher<'static>, z_loaned_publisher_t); - -/// @brief An owned Zenoh matching listener. -/// -/// A listener that sends notifications when the [`MatchingStatus`] of a publisher or querier changes. -/// Dropping the corresponding publisher, also drops matching listener. -get_opaque_type_data!(Option>, z_owned_matching_listener_t); - -/// An owned Zenoh subscriber . -/// -/// Receives data from publication on intersecting key expressions. -/// Destroying the subscriber cancels the subscription. -get_opaque_type_data!(Option>, z_owned_subscriber_t); -/// A loaned Zenoh subscriber. -get_opaque_type_data!(Subscriber<()>, z_loaned_subscriber_t); - -/// @brief A liveliness token that can be used to provide the network with information about connectivity to its -/// declarer: when constructed, a PUT sample will be received by liveliness subscribers on intersecting key -/// expressions. -/// -/// A DELETE on the token's key expression will be received by subscribers if the token is destroyed, or if connectivity between the subscriber and the token's creator is lost. -get_opaque_type_data!(Option, z_owned_liveliness_token_t); -get_opaque_type_data!(LivelinessToken, z_loaned_liveliness_token_t); - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An owned Zenoh publication cache. -/// -/// Used to store publications on intersecting key expressions. Can be queried later via `z_get()` to retrieve this data -/// (for example by `ze_owned_querying_subscriber_t`). -get_opaque_type_data!( - Option, - ze_owned_publication_cache_t -); -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A loaned Zenoh publication cache. -get_opaque_type_data!(zenoh_ext::PublicationCache, ze_loaned_publication_cache_t); - -/// An owned mutex. -get_opaque_type_data!( - Option<(Mutex<()>, Option>)>, - z_owned_mutex_t -); -/// A loaned mutex. -get_opaque_type_data!( - (Mutex<()>, Option>), - z_loaned_mutex_t -); - -/// An owned conditional variable. -/// -/// Used in combination with `z_owned_mutex_t` to wake up thread when certain conditions are met. -get_opaque_type_data!(Option, z_owned_condvar_t); -/// A loaned conditional variable. -get_opaque_type_data!(Condvar, z_loaned_condvar_t); - -/// An owned Zenoh task. -get_opaque_type_data!(Option>, z_owned_task_t); - -/// An owned Zenoh-allocated hello message returned by a Zenoh entity to a scout message sent with `z_scout()`. -get_opaque_type_data!(Option, z_owned_hello_t); -/// A loaned hello message. -get_opaque_type_data!(Hello, z_loaned_hello_t); - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An owned SHM Client. -get_opaque_type_data!(Option>, z_owned_shm_client_t); -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An owned list of SHM Clients. -get_opaque_type_data!(Option>>, zc_owned_shm_client_list_t); -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A loaned list of SHM Clients. -get_opaque_type_data!(Vec>, zc_loaned_shm_client_list_t); - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An owned SHM Client Storage -get_opaque_type_data!(Option>, z_owned_shm_client_storage_t); -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// A loaned SHM Client Storage. -get_opaque_type_data!(Arc, z_loaned_shm_client_storage_t); - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An owned MemoryLayout. -get_opaque_type_data!(Option, z_owned_memory_layout_t); -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A loaned MemoryLayout. -get_opaque_type_data!(MemoryLayout, z_loaned_memory_layout_t); - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An owned ChunkAllocResult. -get_opaque_type_data!(Option, z_owned_chunk_alloc_result_t); -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An owned ZShm slice. -get_opaque_type_data!(Option, z_owned_shm_t); -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A loaned ZShm slice. -get_opaque_type_data!(zshm, z_loaned_shm_t); - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An owned ZShmMut slice. -get_opaque_type_data!(Option, z_owned_shm_mut_t); -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A loaned ZShmMut slice. -get_opaque_type_data!(zshmmut, z_loaned_shm_mut_t); - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -#[derive(Debug)] -#[repr(C)] -struct DummyCallbacks { - alloc_fn: unsafe extern "C" fn(), - free_fn: unsafe extern "C" fn(), - defragment_fn: unsafe extern "C" fn() -> usize, - available_fn: unsafe extern "C" fn() -> usize, - layout_for_fn: unsafe extern "C" fn(), - id_fn: unsafe extern "C" fn(), -} - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -#[derive(Debug)] -#[repr(C)] -struct DummyContext { - context: *mut c_void, - delete_fn: unsafe extern "C" fn(*mut c_void), -} - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -#[derive(Debug)] -struct DummySHMProviderBackend { - context: DummyContext, - callbacks: DummyCallbacks, -} - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -impl WithProtocolID for DummySHMProviderBackend { - fn id(&self) -> ProtocolID { - 0 - } -} - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -impl ShmProviderBackend for DummySHMProviderBackend { - fn alloc(&self, _layout: &MemoryLayout) -> ChunkAllocResult { - todo!() - } - - fn free(&self, _chunk: &ChunkDescriptor) { - todo!() - } - - fn defragment(&self) -> usize { - todo!() - } - - fn available(&self) -> usize { - todo!() - } - - fn layout_for(&self, _layout: MemoryLayout) -> Result { - todo!() - } -} - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -type DummySHMProvider = ShmProvider; - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -type PosixSHMProvider = ShmProvider; - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -enum CDummySHMProvider { - Posix(PosixSHMProvider), - Dynamic(DummySHMProvider), - DynamicThreadsafe(DummySHMProvider), -} - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An owned ShmProvider. -get_opaque_type_data!(Option, z_owned_shm_provider_t); -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A loaned ShmProvider. -get_opaque_type_data!(CDummySHMProvider, z_loaned_shm_provider_t); - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -type PosixAllocLayout = AllocLayout<'static, PosixShmProviderBackend>; - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -type DummyDynamicAllocLayout = AllocLayout<'static, DummySHMProviderBackend>; - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -enum CSHMLayout { - Posix(PosixAllocLayout), - Dynamic(DummyDynamicAllocLayout), -} -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An owned ShmProvider's AllocLayout. -get_opaque_type_data!(Option, z_owned_alloc_layout_t); -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A loaned ShmProvider's AllocLayout. -get_opaque_type_data!(CSHMLayout, z_loaned_alloc_layout_t); - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A pointer in SHM Segment. -get_opaque_type_data!(Option, z_owned_ptr_in_segment_t); -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A loaned pointer in SHM Segment. -get_opaque_type_data!(PtrInSegment, z_loaned_ptr_in_segment_t); - -/// An owned Zenoh fifo sample handler. -get_opaque_type_data!( - Option>, - z_owned_fifo_handler_sample_t -); -/// An loaned Zenoh fifo sample handler. -get_opaque_type_data!(FifoChannelHandler, z_loaned_fifo_handler_sample_t); - -/// An owned Zenoh ring sample handler. -get_opaque_type_data!( - Option>, - z_owned_ring_handler_sample_t -); -/// An loaned Zenoh ring sample handler. -get_opaque_type_data!(RingChannelHandler, z_loaned_ring_handler_sample_t); - -/// An owned Zenoh fifo query handler. -get_opaque_type_data!( - Option>, - z_owned_fifo_handler_query_t -); -/// An loaned Zenoh fifo query handler. -get_opaque_type_data!(FifoChannelHandler, z_loaned_fifo_handler_query_t); - -/// An owned Zenoh ring query handler. -get_opaque_type_data!( - Option>, - z_owned_ring_handler_query_t -); -/// An loaned Zenoh ring query handler. -get_opaque_type_data!(RingChannelHandler, z_loaned_ring_handler_query_t); - -/// An owned Zenoh fifo reply handler. -get_opaque_type_data!( - Option>, - z_owned_fifo_handler_reply_t -); -/// An loaned Zenoh fifo reply handler. -get_opaque_type_data!(FifoChannelHandler, z_loaned_fifo_handler_reply_t); - -/// An owned Zenoh ring reply handler. -get_opaque_type_data!( - Option>, - z_owned_ring_handler_reply_t -); -/// An loaned Zenoh ring reply handler. -get_opaque_type_data!(RingChannelHandler, z_loaned_ring_handler_reply_t); - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An owned Zenoh-allocated source info`. -get_opaque_type_data!(SourceInfo, z_owned_source_info_t); -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A loaned source info. -get_opaque_type_data!(SourceInfo, z_loaned_source_info_t); -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An entity gloabal id. -get_opaque_type_data!(EntityGlobalId, z_entity_global_id_t); - -/// @brief An owned Zenoh serializer. -get_opaque_type_data!(Option, ze_owned_serializer_t); -/// @brief A loaned Zenoh serializer. -get_opaque_type_data!(zenoh_ext::ZSerializer, ze_loaned_serializer_t); -/// @brief A Zenoh serializer. -get_opaque_type_data!(zenoh_ext::ZDeserializer<'static>, ze_deserializer_t); diff --git a/build.rs b/build.rs index f2099a0bd..5604ce971 100644 --- a/build.rs +++ b/build.rs @@ -1,63 +1,18 @@ -use std::env; - -use fs_extra::{dir, file}; - mod buildrs; -pub fn get_build_rs_path() -> std::path::PathBuf { - let file_path = file!(); - let mut path_buf = std::path::PathBuf::new(); - path_buf.push(file_path); - path_buf.parent().unwrap().to_path_buf() -} - -pub fn get_out_rs_path() -> std::path::PathBuf { - let out_dir = env::var_os("OUT_DIR").unwrap(); - std::path::Path::new(&out_dir).to_path_buf() -} - -pub fn dump_rust_sources(out_path: &std::path::Path) { - let build_rs_path = get_build_rs_path(); - let src_path = build_rs_path.join("./src"); - - let out_rs_path = get_out_rs_path(); - let opaque_types_src_path = out_rs_path.join("./opaque_types.rs"); - - if !out_path.exists() { - std::fs::create_dir_all(out_path).unwrap(); - } - fs_extra::copy_items( - &[src_path], - out_path, - &dir::CopyOptions::new().overwrite(true), - ) - .unwrap(); - fs_extra::file::copy( - opaque_types_src_path, - out_path.join("./src/opaque_types/mod.rs"), - &file::CopyOptions::new().overwrite(true), - ) - .unwrap(); -} - fn main() { - buildrs::opaque_types_generator::generate_opaque_types(); - buildrs::cbindgen_generator::generate_c_headers(); - if let Some(out_path) = env::var_os("ZENOHC_DUMP_SRC_DIR") { - let out_path = std::path::Path::new(&out_path); - dump_rust_sources(out_path); - } + let source = buildrs::prebindgen_generator::generate_source(); + prebindgen::trace!("Generated source: {}", source.display()); + buildrs::cbindgen_generator::generate_c_headers(&source); println!("cargo:rerun-if-changed=build.rs"); - println!("cargo:rerun-if-changed=buildrs"); println!("cargo:rerun-if-changed=src"); println!("cargo:rerun-if-changed=splitguide.yaml"); println!("cargo:rerun-if-changed=cbindgen.toml"); - println!("cargo:rerun-if-changed=build-resources"); println!("cargo:rerun-if-changed=include"); if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("linux") { let name = std::env::var("CARGO_PKG_NAME").unwrap(); // Create the shared library name by removing hyphens from the pkg_name let soname = format!("lib{}.so", name.replace('-', "")); - println!("cargo:rustc-cdylib-link-arg=-Wl,-soname,{}", soname); + println!("cargo:rustc-cdylib-link-arg=-Wl,-soname,{soname}"); } } diff --git a/buildrs/cbindgen_generator.rs b/buildrs/cbindgen_generator.rs index 1edac725a..57f4c555e 100644 --- a/buildrs/cbindgen_generator.rs +++ b/buildrs/cbindgen_generator.rs @@ -1,7 +1,7 @@ use std::{ collections::HashSet, fs::File, - io::{BufRead, Read, Write}, + io::{Read, Write}, path::{Path, PathBuf}, }; @@ -10,14 +10,10 @@ use phf::phf_map; use regex::Regex; use super::{ - common_helpers::{cargo_target_dir, split_type_name, test_feature}, + common_helpers::{cargo_target_dir, split_type_name}, splitguide::{split_bindings, FuncArg, FunctionSignature}, }; -use crate::get_out_rs_path; - -const BUGGY_GENERATION_PATH: &str = "include/zenoh-gen-buggy.h"; -const GENERATION_PATH: &str = "include/zenoh-gen.h"; -const PREPROCESS_PATH: &str = "include/zenoh-cpp.h"; +use crate::buildrs::common_helpers::{get_manifest_path, get_tmp_dir}; static RUST_TO_C_FEATURES: phf::Map<&'static str, &'static str> = phf_map! { "unstable" => "Z_FEATURE_UNSTABLE_API", @@ -35,51 +31,92 @@ static RUST_TO_C_FEATURES: phf::Map<&'static str, &'static str> = phf_map! { "transport_vsock" => "Z_FEATURE_VSOCK" }; -pub fn generate_c_headers() { - let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); +fn trace_generated(title: &str, path: &Path) { + let tmp = path.starts_with(get_tmp_dir()); + prebindgen::trace!( + "{} {}{}", + title, + path.display(), + if tmp { " [TEMPORARY] " } else { "" } + ); +} + +pub fn generate_c_headers(source: &Path) { + let crate_dir = get_manifest_path(); + let tmp_dir = get_tmp_dir(); + let include_dir = crate_dir.join("include"); + std::fs::create_dir_all(&include_dir).unwrap_or_else(|e| { + panic!( + "Failed to create include directory {}: {}", + include_dir.display(), + e + ); + }); + let config = cbindgen::Config::from_root_or_default(crate_dir.clone()); + + let buggy_generation_path = tmp_dir.join("zenoh-gen-buggy.h"); cbindgen::Builder::new() .with_config(config) - .with_crate(crate_dir) - .with_src(get_out_rs_path().join("./opaque_types.rs")) + .with_crate(&crate_dir) + .with_src(source) .generate() .expect("Unable to generate bindings") - .write_to_file(BUGGY_GENERATION_PATH); - - fix_cbindgen(BUGGY_GENERATION_PATH, GENERATION_PATH); - std::fs::remove_file(BUGGY_GENERATION_PATH).unwrap(); - - preprocess_header(GENERATION_PATH, PREPROCESS_PATH); - create_generics_header(PREPROCESS_PATH, "include/zenoh_macros.h"); - std::fs::remove_file(PREPROCESS_PATH).unwrap(); + .write_to_file(&buggy_generation_path); + trace_generated("Generated buggy source by cbindgen", &buggy_generation_path); + + let generation_path = tmp_dir.join("zenoh-gen.h"); + fix_cbindgen(&buggy_generation_path, &generation_path); + trace_generated("Fixed cbindgen source", &generation_path); + + prebindgen::trace!( + "Splitting {}", + generation_path.file_name().unwrap().to_str().unwrap() + ); + let files = split_bindings(&generation_path); + files.iter().for_each(|file| { + trace_generated(" - ", file); + }); + + let replaced = text_replace(files.iter(), &include_dir); + prebindgen::trace!("Resulting headers after text replacements"); + replaced.iter().for_each(|file| { + trace_generated(" - ", file); + }); + + let zenoh_macros_path = include_dir.join("zenoh_macros.h"); + create_generics_header(&generation_path, &zenoh_macros_path); + trace_generated("Generated generics header", &zenoh_macros_path); configure(); - let files = split_bindings(GENERATION_PATH).unwrap(); - text_replace(files.iter()); + let cargo_target_dir = cargo_target_dir(); fs_extra::copy_items( - &["include"], - cargo_target_dir(), + &[&include_dir], + &cargo_target_dir, &fs_extra::dir::CopyOptions::default().overwrite(true), ) - .expect("include should be copied to CARGO_TARGET_DIR"); + .unwrap_or_else(|e| { + panic!( + "failed to copy include directory from {} to {}: {}", + include_dir.display(), + cargo_target_dir.display(), + e + ); + }); } -fn fix_cbindgen(input: &str, output: &str) { - let bindings = std::fs::read_to_string(input).expect("failed to open input file"); +fn fix_cbindgen(input: &Path, output: &Path) { + let bindings = std::fs::read_to_string(input) + .unwrap_or_else(|e| panic!("failed to open input file {}: {}", input.display(), e)); let bindings = bindings.replace("\n#endif\n ;", ";\n#endif"); - let mut out = File::create(output).expect("failed to open output file"); + let mut out = File::create(output) + .unwrap_or_else(|e| panic!("failed to open output file {}: {}", output.display(), e)); out.write_all(bindings.as_bytes()).unwrap(); } -fn preprocess_header(input: &str, output: &str) { - let parsed = process_feature_defines(input).expect("failed to open input file"); - let mut out = File::create(output).expect("failed to open output file"); - out.write_all(parsed.as_bytes()).unwrap(); -} - -fn create_generics_header(path_in: &str, path_out: &str) { +fn create_generics_header(path_in: &Path, path_out: &Path) { let mut file_out = std::fs::File::options() .read(false) .write(true) @@ -87,7 +124,7 @@ fn create_generics_header(path_in: &str, path_out: &str) { .append(false) .create(true) .open(path_out) - .unwrap(); + .unwrap_or_else(|e| panic!("failed to open output file {}: {}", path_out.display(), e)); file_out .write_all( @@ -314,20 +351,30 @@ fn create_generics_header(path_in: &str, path_out: &str) { } fn configure() { + let crate_dir = get_manifest_path(); + let zenoh_configure_h_path = crate_dir.join("include/zenoh_configure.h"); + trace_generated("Generating configuration file", &zenoh_configure_h_path); let mut file = std::fs::File::options() .write(true) .truncate(true) .append(false) .create(true) - .open("include/zenoh_configure.h") - .unwrap(); + .open(&zenoh_configure_h_path) + .unwrap_or_else(|e| { + panic!( + "failed to open output file {}: {}", + zenoh_configure_h_path.display(), + e + ) + }); file.lock_exclusive().unwrap(); - let version = std::fs::read_to_string("version.txt").unwrap(); + let version_txt_path = crate_dir.join("version.txt"); + let version = std::fs::read_to_string(version_txt_path).unwrap(); let version = version.trim(); let version_parts: Vec<&str> = version.split('.').collect(); if version_parts.len() < 3 { - panic!("Invalid version format: \"{}\" in file version.txt. Major.Minor.Patch parts are required", version); + panic!("Invalid version format: \"{version}\" in file version.txt. Major.Minor.Patch parts are required"); } let major = version_parts[0]; let minor = version_parts[1]; @@ -361,25 +408,33 @@ fn configure() { .unwrap(); for (rust_feature, c_feature) in RUST_TO_C_FEATURES.entries() { - if test_feature(rust_feature) { - file.write_all(format!("#define {}\n", c_feature).as_bytes()) + if prebindgen::is_feature_enabled(rust_feature) { + file.write_all(format!("#define {c_feature}\n").as_bytes()) .unwrap(); } } fs2::FileExt::unlock(&file).unwrap(); } -fn text_replace(files: impl Iterator>) { - for name in files { - let path = PathBuf::from("include").join(name); +fn text_replace(files: impl Iterator>, dst_dir: &Path) -> Vec { + let mut result = Vec::new(); + for src_path in files { + assert!(src_path.as_ref().is_absolute()); + let dst_path = dst_dir.join(src_path.as_ref().file_name().unwrap()); // Read content let mut file = std::fs::File::options() .read(true) .create(false) .write(false) - .open(&path) - .unwrap(); + .open(&src_path) + .unwrap_or_else(|e| { + panic!( + "failed to open input file {}: {}", + src_path.as_ref().display(), + e + ) + }); file.lock_exclusive().unwrap(); let mut buf = String::new(); file.read_to_string(&mut buf).unwrap(); @@ -394,72 +449,21 @@ fn text_replace(files: impl Iterator>) { // So have to do it here. let buf = buf.replace("extern const", "ZENOHC_API extern const"); - // Overwrite content - let mut file = std::fs::File::options() - .read(false) - .create(false) - .write(true) - .truncate(true) - .open(&path) - .unwrap(); + // Store result + let mut file = std::fs::File::create(&dst_path).unwrap_or_else(|e| { + panic!("failed to create output file {}: {}", dst_path.display(), e) + }); file.lock_exclusive().unwrap(); file.write_all(buf.as_bytes()).unwrap(); fs2::FileExt::unlock(&file).unwrap(); + result.push(dst_path); } + result } -/// Evaluates conditional feature macros in the form #if (logical expression of define(FEATURE_NAME)) -/// and removes the code under those that evaluate to false -/// Note: works only on single string conditional expressions -fn process_feature_defines(input_path: &str) -> Result> { - let file = std::fs::File::open(input_path)?; - let lines = std::io::BufReader::new(file).lines(); - let mut out = String::new(); - let mut skip = false; - let mut nest_level: usize = 0; - for line in lines.map_while(Result::ok) { - if line.starts_with("#ifdef") && skip { - nest_level += 1; - } else if line.starts_with("#endif") && skip { - nest_level -= 1; - skip = nest_level != 0; - continue; - } else if line.starts_with("#if ") { - skip = skip || evaluate_c_defines_line(&line); - if skip { - nest_level += 1; - } - } - if !skip { - out += &line; - out += "\n"; - } - } - - Ok(out) -} - -fn evaluate_c_defines_line(line: &str) -> bool { - let mut s = line.to_string(); - for (rust_feature, c_feature) in RUST_TO_C_FEATURES.entries() { - s = s.replace( - &format!("defined({})", c_feature), - match test_feature(rust_feature) { - true => "true", - false => "false", - }, - ); - } - - s = s.replace("#if", ""); - match evalexpr::eval(&s) { - Ok(v) => v == evalexpr::Value::from(false), - Err(_) => panic!("Failed to evaluate {}", &s), - } -} - -fn make_move_take_signatures(path_in: &str) -> (Vec, Vec) { - let bindings = std::fs::read_to_string(path_in).unwrap(); +fn make_move_take_signatures(path_in: &Path) -> (Vec, Vec) { + let bindings = std::fs::read_to_string(path_in) + .unwrap_or_else(|e| panic!("failed to read file {}: {}", path_in.display(), e)); let re = Regex::new(r"(\w+)_drop\(struct (\w+) \*(\w+)\);").unwrap(); let mut move_funcs = Vec::::new(); let mut take_funcs = Vec::::new(); @@ -491,8 +495,9 @@ fn make_move_take_signatures(path_in: &str) -> (Vec, Vec Vec { - let bindings = std::fs::read_to_string(path_in).unwrap(); +fn find_loan_functions(path_in: &Path) -> Vec { + let bindings = std::fs::read_to_string(path_in) + .unwrap_or_else(|e| panic!("failed to read file {}: {}", path_in.display(), e)); let re = Regex::new(r"const struct (\w+) \*(\w+)_loan\(const struct (\w+) \*(\w+)\);").unwrap(); let mut res = Vec::::new(); @@ -514,8 +519,9 @@ fn find_loan_functions(path_in: &str) -> Vec { res } -fn find_loan_mut_functions(path_in: &str) -> Vec { - let bindings = std::fs::read_to_string(path_in).unwrap(); +fn find_loan_mut_functions(path_in: &Path) -> Vec { + let bindings = std::fs::read_to_string(path_in) + .unwrap_or_else(|e| panic!("failed to read file {}: {}", path_in.display(), e)); let re = Regex::new(r"struct (\w+) \*(\w+)_loan_mut\(struct (\w+) \*(\w+)\);").unwrap(); let mut res = Vec::::new(); @@ -534,8 +540,9 @@ fn find_loan_mut_functions(path_in: &str) -> Vec { res } -fn find_take_from_loaned_functions(path_in: &str) -> Vec { - let bindings = std::fs::read_to_string(path_in).unwrap(); +fn find_take_from_loaned_functions(path_in: &Path) -> Vec { + let bindings = std::fs::read_to_string(path_in) + .unwrap_or_else(|e| panic!("failed to read file {}: {}", path_in.display(), e)); let re = Regex::new(r"void (\w+)_take_from_loaned\(struct (\w+) \*(\w+)").unwrap(); let mut res = Vec::::new(); @@ -557,8 +564,9 @@ fn find_take_from_loaned_functions(path_in: &str) -> Vec { res } -fn find_drop_functions(path_in: &str) -> Vec { - let bindings = std::fs::read_to_string(path_in).unwrap(); +fn find_drop_functions(path_in: &Path) -> Vec { + let bindings = std::fs::read_to_string(path_in) + .unwrap_or_else(|e| panic!("failed to read file {}: {}", path_in.display(), e)); let re = Regex::new(r"(.+?) +(\w+_drop)\(struct (\w+) \*(\w+)\);").unwrap(); let mut res = Vec::::new(); @@ -584,8 +592,9 @@ fn find_drop_functions(path_in: &str) -> Vec { res } -fn find_null_functions(path_in: &str) -> Vec { - let bindings = std::fs::read_to_string(path_in).unwrap(); +fn find_null_functions(path_in: &Path) -> Vec { + let bindings = std::fs::read_to_string(path_in) + .unwrap_or_else(|e| panic!("failed to read file {}: {}", path_in.display(), e)); let re = Regex::new(r" (z.?_internal_\w+_null)\(struct (\w+) \*(\w+)\);").unwrap(); let mut res = Vec::::new(); @@ -602,8 +611,9 @@ fn find_null_functions(path_in: &str) -> Vec { res } -fn find_check_functions(path_in: &str) -> Vec { - let bindings = std::fs::read_to_string(path_in).unwrap(); +fn find_check_functions(path_in: &Path) -> Vec { + let bindings = std::fs::read_to_string(path_in) + .unwrap_or_else(|e| panic!("failed to read file {}: {}", path_in.display(), e)); let re = Regex::new(r"bool (z.?_internal_\w+_check)\(const struct (\w+) \*(\w+)\);").unwrap(); let mut res = Vec::::new(); @@ -623,8 +633,9 @@ fn find_check_functions(path_in: &str) -> Vec { res } -fn find_call_functions(path_in: &str) -> Vec { - let bindings = std::fs::read_to_string(path_in).unwrap(); +fn find_call_functions(path_in: &Path) -> Vec { + let bindings = std::fs::read_to_string(path_in) + .unwrap_or_else(|e| panic!("failed to read file {}: {}", path_in.display(), e)); let re = Regex::new( r"(\w+) (\w+)_call\(const struct (\w+) \*(\w+),\s+(\w*)\s*struct (\w+) (\*?)(\w+)\);", ) @@ -656,8 +667,9 @@ fn find_call_functions(path_in: &str) -> Vec { res } -fn find_closure_constructors(path_in: &str) -> Vec { - let bindings = std::fs::read_to_string(path_in).unwrap(); +fn find_closure_constructors(path_in: &Path) -> Vec { + let bindings = std::fs::read_to_string(path_in) + .unwrap_or_else(|e| panic!("failed to read file {}: {}", path_in.display(), e)); let re = Regex::new( r"(\w+) (\w+)_closure_(\w+)\(struct\s+(\w+)\s+\*(\w+),\s+void\s+\(\*call\)(\([\s\w,\*]*\)),\s+void\s+\(\*drop\)(\(.*\)),\s+void\s+\*context\);" ) @@ -692,8 +704,9 @@ fn find_closure_constructors(path_in: &str) -> Vec { res } -fn find_recv_functions(path_in: &str) -> Vec { - let bindings = std::fs::read_to_string(path_in).unwrap(); +fn find_recv_functions(path_in: &Path) -> Vec { + let bindings = std::fs::read_to_string(path_in) + .unwrap_or_else(|e| panic!("failed to read file {}: {}", path_in.display(), e)); let re = Regex::new(r"(\w+)\s+z_(\w+)_handler_(\w+)_recv\(const\s+struct\s+(\w+)\s+\*(\w+),\s+struct\s+(\w+)\s+\*(\w+)\);").unwrap(); let mut res = Vec::::new(); @@ -715,8 +728,9 @@ fn find_recv_functions(path_in: &str) -> Vec { res } -fn find_clone_functions(path_in: &str) -> Vec { - let bindings = std::fs::read_to_string(path_in).unwrap(); +fn find_clone_functions(path_in: &Path) -> Vec { + let bindings = std::fs::read_to_string(path_in) + .unwrap_or_else(|e| panic!("failed to read file {}: {}", path_in.display(), e)); let re = Regex::new( r"(\w+)\s+z_(\w+)_clone\(struct\s+(\w+)\s+\*(\w+),\s+const\s+struct\s+(\w+)\s+\*(\w+)\);", ) @@ -889,7 +903,7 @@ fn generate_generic_closure_c(macro_func: &[FunctionSignature]) -> String { .typename .replace(" (*call)", &format!("(*{})", &callback_typename)); - out += &format!("typedef {};\n", prototype); + out += &format!("typedef {prototype};\n"); } out += "\n"; out += &generate_generic_c(macro_func, "z_closure", false); @@ -1061,10 +1075,7 @@ fn generate_generic_closure_cpp(macro_func: &[FunctionSignature]) -> String { .typename .replace(&format!(" (*{})", &processed_f.args[1].name), ""); let callback_typename = f.func_name.clone() + "_callback_t"; - out += &format!( - "extern \"C\" using {} = {};\n", - callback_typename, prototype - ); + out += &format!("extern \"C\" using {callback_typename} = {prototype};\n"); processed_f.args[1].typename.typename = callback_typename + "*"; processed_f.args[2].typename.typename = "z_closure_drop_callback_t*".to_string(); processed.push(processed_f); diff --git a/buildrs/common_helpers.rs b/buildrs/common_helpers.rs index 4f4dae7cd..420509151 100644 --- a/buildrs/common_helpers.rs +++ b/buildrs/common_helpers.rs @@ -1,4 +1,4 @@ -use std::{collections::BTreeSet, env, path::PathBuf}; +use std::{env, path::PathBuf}; pub fn split_type_name(type_name: &str) -> (&str, Option<&str>, &str, &str) { let mut split = type_name.split('_'); @@ -19,14 +19,6 @@ pub fn split_type_name(type_name: &str) -> (&str, Option<&str>, &str, &str) { (prefix, category, semantic, postfix) } -pub fn features() -> BTreeSet<&'static str> { - zenoh::FEATURES.split(" zenoh/").collect() -} - -pub fn test_feature(feature: &str) -> bool { - zenoh::FEATURES.contains(format!(" zenoh/{feature}").as_str()) -} - // See: https://github.com/rust-lang/cargo/issues/9661 // See: https://github.com/rust-lang/cargo/issues/545 pub fn cargo_target_dir() -> PathBuf { @@ -49,3 +41,17 @@ pub fn cargo_target_dir() -> PathBuf { .expect("OUT_DIR should be a child of a PROFILE directory") .to_path_buf() } + +pub fn get_out_dir() -> std::path::PathBuf { + let out_dir = std::env::var_os("OUT_DIR").unwrap(); + std::path::Path::new(&out_dir).to_path_buf() +} + +pub fn get_manifest_path() -> std::path::PathBuf { + let manifest_path = std::env::var_os("CARGO_MANIFEST_DIR").unwrap(); + std::path::Path::new(&manifest_path).to_path_buf() +} + +pub fn get_tmp_dir() -> PathBuf { + get_out_dir().join("tmp") +} diff --git a/buildrs/mod.rs b/buildrs/mod.rs index c7b292b00..56d8e1f1b 100644 --- a/buildrs/mod.rs +++ b/buildrs/mod.rs @@ -1,4 +1,4 @@ pub mod cbindgen_generator; pub mod common_helpers; -pub mod opaque_types_generator; +pub mod prebindgen_generator; pub mod splitguide; diff --git a/buildrs/opaque_types_generator.rs b/buildrs/opaque_types_generator.rs deleted file mode 100644 index c1d0bdd35..000000000 --- a/buildrs/opaque_types_generator.rs +++ /dev/null @@ -1,176 +0,0 @@ -use std::{collections::HashMap, path::PathBuf}; - -use regex::Regex; - -use super::common_helpers::{features, split_type_name}; -use crate::{get_build_rs_path, get_out_rs_path}; - -pub fn generate_opaque_types() { - let type_to_inner_field_name = HashMap::from([("z_id_t", "pub id")]); - let current_folder = get_out_rs_path(); - let (command, path_in) = produce_opaque_types_data(); - let path_out = current_folder.join("./opaque_types.rs"); - - let data_in = std::fs::read_to_string(path_in).unwrap(); - - // Check for cargo-level errors (dependency resolution, manifest parsing, etc.) - if data_in.contains("error: failed to") || data_in.contains("Caused by:") { - panic!( - "Failed to generate opaque types due to cargo error:\n\nCommand executed:\n\n{command}\n\nCargo output:\n\n{data_in}" - ); - } - - let mut data_out = String::new(); - let mut docs = get_opaque_type_docs(); - - // Count the total number of errors in the input data - let total_error_count = data_in - .lines() - .filter(|line| line.starts_with("error[E")) - .count(); - - // Scan for type size and layout information which is generated as compilation errors - let mut good_error_count = 0; - let re = Regex::new(r"type: (\w+), align: (\d+), size: (\d+)").unwrap(); - for (_, [type_name, align, size]) in re.captures_iter(&data_in).map(|c| c.extract()) { - good_error_count += 1; - let inner_field_name = type_to_inner_field_name.get(type_name).unwrap_or(&"_0"); - let (prefix, category, semantic, postfix) = split_type_name(type_name); - let mut s = String::new(); - if category != Some("owned") { - s += "#[derive(Copy, Clone)]\n"; - }; - s += format!( - "#[repr(C, align({align}))] -#[rustfmt::skip] -pub struct {type_name} {{ - {inner_field_name}: [u8; {size}], -}} -" - ) - .as_str(); - if category == Some("owned") { - let moved_type_name = format!("{}_{}_{}_{}", prefix, "moved", semantic, postfix); - s += format!( - "#[repr(C)] -#[rustfmt::skip] -pub struct {moved_type_name} {{ - _this: {type_name}, -}} - -#[rustfmt::skip] -impl crate::transmute::TakeCType for {moved_type_name} {{ - type CType = {type_name}; - fn take_c_type(&mut self) -> Self::CType {{ - use crate::transmute::Gravestone; - std::mem::replace(&mut self._this, {type_name}::gravestone()) - }} -}} - -#[rustfmt::skip] -impl Drop for {type_name} {{ - fn drop(&mut self) {{ - use crate::transmute::{{RustTypeRef, Gravestone, IntoRustType}}; - let _ = std::mem::replace(self.as_rust_type_mut(), {type_name}::gravestone().into_rust_type()); - }} -}} -" - ) - .as_str(); - } - - let doc = docs - .remove(type_name) - .unwrap_or_else(|| panic!("Failed to extract docs for opaque type: {type_name}")); - for d in doc { - data_out += &d; - data_out += "\r\n"; - } - data_out += &s; - } - - if good_error_count != total_error_count { - panic!( - "Failed to generate opaque types: there are {} errors in the input data, but only {} of them were processed as information about opaque types\n\nCommand executed:\n\n{}\n\nCompiler output:\n\n{}", - total_error_count, - good_error_count, - command, - data_in - ); - } - - std::fs::write(path_out, data_out).unwrap(); -} - -fn produce_opaque_types_data() -> (String, PathBuf) { - let target = std::env::var("TARGET").unwrap(); - let linker = std::env::var("RUSTC_LINKER").unwrap_or_default(); - let manifest_path = get_build_rs_path().join("./build-resources/opaque-types/Cargo.toml"); - let output_file_path = get_out_rs_path().join("./build_resources_opaque_types.txt"); - let out_file = std::fs::File::create(output_file_path.clone()).unwrap(); - let stdio = std::process::Stdio::from(out_file); - - let mut linker_args = Vec::::new(); - if !linker.is_empty() { - linker_args.push("--config".to_string()); - linker_args.push(format!("target.{target}.linker=\"{linker}\"")); - } - #[allow(unused_mut)] - let mut feature_args: Vec<&str> = vec!["-F", "panic"]; - for feature in features().iter().filter(|f| !f.is_empty()) { - feature_args.push("-F"); - feature_args.push(feature); - } - - let mut command = std::process::Command::new("cargo"); - command - .arg("build") - .args(feature_args) - .args(linker_args) - .arg("--target") - .arg(target) - .arg("--manifest-path") - .arg(manifest_path) - .arg("--target-dir") - .arg(match std::env::var("OPAQUE_TYPES_BUILD_DIR") { - Ok(opaque_types_build_dir) => { - println!( - "cargo:warning=OPAQUE_TYPES_BUILD_DIR = {}", - opaque_types_build_dir - ); - opaque_types_build_dir.into() - } - Err(_) => get_out_rs_path().join("./build_resources/opaque_types"), - }); - - let command_str = format!("{:?}", command); - let _ = command.stderr(stdio).output().unwrap(); - (command_str, output_file_path) -} - -fn get_opaque_type_docs() -> HashMap> { - let current_folder = get_build_rs_path(); - let path_in = current_folder.join("./build-resources/opaque-types/src/lib.rs"); - let re = Regex::new(r"(?m)^get_opaque_type_data!\(\s*(.*)\s*,\s*(\w+)\s*(,)?\s*\);").unwrap(); - let mut comments = Vec::new(); - let mut opaque_lines = Vec::new(); - let mut res = HashMap::new(); - for line in std::fs::read_to_string(&path_in) - .unwrap_or_else(|_| panic!("failed to read file {}", path_in.display())) - .lines() - { - if line.starts_with("///") { - comments.push(line.to_string()); - continue; - } - if line.starts_with("get_opaque_type_data!(") || !opaque_lines.is_empty() { - opaque_lines.push(line); - } - if !opaque_lines.is_empty() && line.ends_with(");") { - let joined_lines = std::mem::take(&mut opaque_lines).join(""); - let capture = re.captures(&joined_lines).expect("invalid opaque type"); - res.insert(capture[2].to_string(), std::mem::take(&mut comments)); - } - } - res -} diff --git a/buildrs/prebindgen_generator.rs b/buildrs/prebindgen_generator.rs new file mode 100644 index 000000000..4bb2ea195 --- /dev/null +++ b/buildrs/prebindgen_generator.rs @@ -0,0 +1,42 @@ +use std::path::PathBuf; + +use itertools::Itertools; + +pub fn generate_source() -> PathBuf { + let source_ffi = prebindgen::Source::new(zenoh_ffi::PREBINDGEN_OUT_DIR); + let source_ffi_opaque_types = + prebindgen::Source::new(zenoh_ffi_opaque_types::PREBINDGEN_OUT_DIR); + + let replace_types = prebindgen::map::ReplaceTypes::builder() + .replace_type("MaybeUninit", "std::mem::MaybeUninit") + .replace_type("c_char", "libc::c_char") + .replace_type("c_void", "libc::c_void") + .replace_type("c_uint", "libc::c_uint") + .replace_type("result::z_result_t", "z_result_t") + .build(); + + let strip_derives = prebindgen::map::StripDerives::builder() + .strip_derive("Default") + .build(); + + let strip_macros = prebindgen::map::StripMacros::builder() + .strip_macro("default") + .build(); + + let ffi_converter = prebindgen::batching::FfiConverter::builder("zenoh_ffi") + .edition(prebindgen::RustEdition::Edition2021) + .strip_transparent_wrapper("std::mem::MaybeUninit") + .strip_transparent_wrapper("::std::mem::MaybeUninit") + .strip_transparent_wrapper("Option") + .build(); + + source_ffi + .items_except_groups(&["move"]) // the move operations are generated in the header + .chain(source_ffi_opaque_types.items_all()) + .map(strip_derives.into_closure()) + .map(strip_macros.into_closure()) + .map(replace_types.into_closure()) + .batching(ffi_converter.into_closure()) + .collect::() + .write("zenoh_ffi.rs") +} diff --git a/buildrs/splitguide.rs b/buildrs/splitguide.rs index 4332402d0..cca475d77 100644 --- a/buildrs/splitguide.rs +++ b/buildrs/splitguide.rs @@ -7,7 +7,7 @@ use std::{ use fs2::FileExt; -use super::common_helpers::test_feature; +use crate::buildrs::common_helpers::{get_manifest_path, get_tmp_dir}; const SPLITGUIDE_PATH: &str = "splitguide.yaml"; const HEADER: &str = r"// @@ -54,7 +54,7 @@ impl SplitGuide { let mut split = s.split('#'); let val = split.next().unwrap(); for feature in split { - if !test_feature(feature) { + if !prebindgen::is_feature_enabled(feature) { return None; } } @@ -567,59 +567,71 @@ impl FunctionSignature { } } -pub fn split_bindings(genetation_path: impl AsRef) -> Result, String> { - let bindings = std::fs::read_to_string(&genetation_path).unwrap(); - let split_guide = SplitGuide::from_yaml(SPLITGUIDE_PATH); +pub fn split_bindings(generation_path: impl AsRef) -> Vec { + let splitguide_path = get_manifest_path().join(SPLITGUIDE_PATH); + let split_guide = SplitGuide::from_yaml(&splitguide_path); + let bindings = std::fs::read_to_string(&generation_path).unwrap(); let mut files = split_guide .rules .iter() - .map(|(path, _)| { + .map(|(name, _)| { + let path = get_tmp_dir().join(name); let file = std::fs::File::options() .write(true) .truncate(true) .append(false) .create(true) - .open(PathBuf::from("include").join(path)) + .open(&path) .unwrap(); file.lock_exclusive().unwrap(); file.set_len(0).unwrap(); - (path as &Path, BufWriter::new(file)) + (name as &Path, (path, BufWriter::new(file))) }) .collect::>(); for file in files.values_mut() { - file.write_all(HEADER.as_bytes()) - .map_err(|e| e.to_string())?; + file.1 + .write_all(HEADER.as_bytes()) + .unwrap_or_else(|e| panic!("Failed to write to file {}: {}", file.0.display(), e)); } let mut records = group_tokens(Tokenizer { - filename: genetation_path.as_ref(), + filename: generation_path.as_ref(), inner: &bindings, - })?; + }) + .unwrap_or_else(|e| { + panic!( + "Failed to parse C file {}: {}", + generation_path.as_ref().display(), + e + ); + }); for id in split_guide.requested_ids() { if !records.iter().any(|r| r.contains_id(id)) { - return Err(format!( - "{} not found (requested explicitly by splitguide.yaml)", - id, - )); + panic!("{id} not found (requested explicitly by splitguide.yaml)",); } } for record in &mut records { let appropriate_files = split_guide.appropriate_files(record); - for file in appropriate_files { - let writer = files.get_mut(&file).unwrap(); + for name in appropriate_files { + let (_, writer) = files.get_mut(&name).unwrap(); record.used = true; write!(writer, "{}", &record).unwrap(); } } for record in &records { - record.is_used()?; - } - let files = files + record.is_used().unwrap_or_else(|e| { + panic!( + "Unused record {:?} in file {}: {}", + record.rt, + generation_path.as_ref().display(), + e + ); + }); + } + files .into_iter() - .map(|(path, file)| { - fs2::FileExt::unlock(&file.into_inner().unwrap()).unwrap(); - path.to_path_buf() + .map(|(_, (path, writer))| { + fs2::FileExt::unlock(&writer.into_inner().unwrap()).unwrap(); + path }) - .collect(); - std::fs::remove_file(genetation_path).unwrap(); - Ok(files) + .collect() } diff --git a/cmake/helpers.cmake b/cmake/helpers.cmake index 1244ad0c1..5f5e49a54 100644 --- a/cmake/helpers.cmake +++ b/cmake/helpers.cmake @@ -25,13 +25,19 @@ macro(status_print var) message(STATUS "${var} = ${${var}}") endmacro() +# if variable is overridden from .cmake configuration file, avoid overriding it +# so keep set CACHE in the function. But do status_print in the macro +# to show real value of overridden variable +function(_declare_cache_var_impl var default_value type docstring) + set(${var} ${default_value} CACHE ${type} ${docstring}) +endfunction() # # Declare cache variable and print VARIABLE = value on configuration stage # -function(declare_cache_var var default_value type docstring) - set(${var} ${default_value} CACHE ${type} ${docstring}) - status_print(${var}) -endfunction() +macro(declare_cache_var var default_value type docstring) + _declare_cache_var_impl("${var}" "${default_value}" "${type}" "${docstring}") + status_print(${var}) +endmacro() # # Declare cache variable which is set to TRUE if project is supposedly diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index 95dbeb04d..b8d9a6667 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -25,12 +25,6 @@ typedef enum z_congestion_control_t { * Messages are dropped in case of congestion. */ Z_CONGESTION_CONTROL_DROP = 1, -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * Messages except the first one are dropped in case of congestion. - */ - Z_CONGESTION_CONTROL_BLOCK_FIRST = 2, -#endif } z_congestion_control_t; /** * Consolidation mode values. @@ -59,30 +53,6 @@ typedef enum z_consolidation_mode_t { */ Z_CONSOLIDATION_MODE_LATEST = 2, } z_consolidation_mode_t; -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Intersection level of 2 key expressions. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef enum z_keyexpr_intersection_level_t { - /** - * 2 key expressions do not intersect. - */ - Z_KEYEXPR_INTERSECTION_LEVEL_DISJOINT = 0, - /** - * 2 key expressions intersect, i.e. there exists at least one key expression that is included by both. - */ - Z_KEYEXPR_INTERSECTION_LEVEL_INTERSECTS = 1, - /** - * First key expression is the superset of second one. - */ - Z_KEYEXPR_INTERSECTION_LEVEL_INCLUDES = 2, - /** - * 2 key expressions are equal. - */ - Z_KEYEXPR_INTERSECTION_LEVEL_EQUALS = 3, -} z_keyexpr_intersection_level_t; -#endif /** * The priority of zenoh messages. */ @@ -133,24 +103,6 @@ typedef enum z_query_target_t { */ Z_QUERY_TARGET_ALL_COMPLETE = 2, } z_query_target_t; -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief The publisher reliability. - * @note Currently `reliability` does not trigger any data retransmission on the wire. - * It is rather used as a marker on the wire and it may be used to select the best link available (e.g. TCP for reliable data and UDP for best effort data). - */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef enum z_reliability_t { - /** - * Defines reliability as ``BEST_EFFORT`` - */ - Z_RELIABILITY_BEST_EFFORT = 0, - /** - * Defines reliability as ``RELIABLE`` - */ - Z_RELIABILITY_RELIABLE = 1, -} z_reliability_t; -#endif typedef enum z_sample_kind_t { /** * The Sample was issued by a ``put`` operation. @@ -227,60 +179,10 @@ typedef enum zc_log_severity_t { */ ZC_LOG_SEVERITY_ERROR = 4, } zc_log_severity_t; -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Key expressions types to which Queryable should reply to. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef enum zc_reply_keyexpr_t { - /** - * Replies to any key expression queries. - */ - ZC_REPLY_KEYEXPR_ANY = 0, - /** - * Replies only to queries with intersecting key expressions. - */ - ZC_REPLY_KEYEXPR_MATCHING_QUERY = 1, -} zc_reply_keyexpr_t; -#endif -#if defined(Z_FEATURE_UNSTABLE_API) -typedef enum ze_advanced_publisher_heartbeat_mode_t { -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * Disable heartbeat-based last sample miss detection. - */ - ZE_ADVANCED_PUBLISHER_HEARTBEAT_MODE_NONE = 0, -#endif -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * Allow last sample miss detection through periodic heartbeat. - * Periodically send the last published Sample's sequence number to allow last sample recovery. - */ - ZE_ADVANCED_PUBLISHER_HEARTBEAT_MODE_PERIODIC = 1, -#endif -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * Allow last sample miss detection through sporadic heartbeat. - * Each period, the last published Sample's sequence number is sent with `z_congestion_control_t::BLOCK` - * but only if it changed since last period. - */ - ZE_ADVANCED_PUBLISHER_HEARTBEAT_MODE_SPORADIC = 2, -#endif -} ze_advanced_publisher_heartbeat_mode_t; -#endif -typedef struct z_moved_alloc_layout_t { - struct z_owned_alloc_layout_t _this; -} z_moved_alloc_layout_t; typedef int8_t z_result_t; typedef struct z_moved_bytes_t { struct z_owned_bytes_t _this; } z_moved_bytes_t; -typedef struct z_moved_shm_t { - struct z_owned_shm_t _this; -} z_moved_shm_t; -typedef struct z_moved_shm_mut_t { - struct z_owned_shm_mut_t _this; -} z_moved_shm_mut_t; typedef struct z_moved_slice_t { struct z_owned_slice_t _this; } z_moved_slice_t; @@ -288,7 +190,7 @@ typedef struct z_moved_string_t { struct z_owned_string_t _this; } z_moved_string_t; /** - * An iterator over slices of serialized data. + *An iterator over slices of serialized data. */ typedef struct ALIGN(8) z_bytes_slice_iterator_t { uint8_t _0[24]; @@ -296,12 +198,6 @@ typedef struct ALIGN(8) z_bytes_slice_iterator_t { typedef struct z_moved_bytes_writer_t { struct z_owned_bytes_writer_t _this; } z_moved_bytes_writer_t; -typedef struct z_moved_chunk_alloc_result_t { - struct z_owned_chunk_alloc_result_t _this; -} z_moved_chunk_alloc_result_t; -typedef struct z_moved_ptr_in_segment_t { - struct z_owned_ptr_in_segment_t _this; -} z_moved_ptr_in_segment_t; /** * Monotonic clock */ @@ -313,23 +209,7 @@ typedef struct z_clock_t { * Options passed to the `z_close()` function. */ typedef struct z_close_options_t { -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * The timeout for close operation in milliseconds. 0 means default close timeout which is 10 seconds. - */ - uint32_t internal_timeout_ms; -#endif -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * An optional uninitialized concurrent close handle. If set, the close operation will be executed - * concurrently in separate task, and this handle will be initialized to be used for controlling - * it's execution. - */ - struct zc_owned_concurrent_close_handle_t *internal_out_concurrent; -#endif -#if !defined(Z_FEATURE_UNSTABLE_API) uint8_t _dummy; -#endif } z_close_options_t; /** * @brief A hello message-processing closure. @@ -367,6 +247,15 @@ typedef struct z_owned_closure_matching_status_t { void (*_call)(const struct z_matching_status_t *matching_status, void *context); void (*_drop)(void *context); } z_owned_closure_matching_status_t; +/** + * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. + * @brief Loaned closure. + */ +typedef struct z_loaned_closure_matching_status_t { + size_t _0; + size_t _1; + size_t _2; +} z_loaned_closure_matching_status_t; /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Moved closure. @@ -491,19 +380,19 @@ typedef struct z_publisher_options_t { * If set to ``true``, this message will not be batched. This usually has a positive impact on latency but negative impact on throughput. */ bool is_express; -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * - * The publisher reliability. - */ - enum z_reliability_t reliability; -#endif /** * The allowed destination for this publisher. */ enum zc_locality_t allowed_destination; } z_publisher_options_t; +/** + *An owned Zenoh querier. + * + *Sends queries to matching queryables. + */ +typedef struct ALIGN(8) z_owned_querier_t { + uint8_t _0[80]; +} z_owned_querier_t; /** * The replies consolidation strategy to apply on replies to a `z_get()`. */ @@ -534,14 +423,6 @@ typedef struct z_querier_options_t { * The allowed destination for the querier queries. */ enum zc_locality_t allowed_destination; -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * - * The accepted replies for the querier queries. - */ - enum zc_reply_keyexpr_t accept_replies; -#endif /** * The priority of the querier queries. */ @@ -571,14 +452,6 @@ typedef struct z_delete_options_t { * The timestamp of this message. */ struct z_timestamp_t *timestamp; -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * - * The delete operation reliability. - */ - enum z_reliability_t reliability; -#endif /** * The allowed destination of this message. */ @@ -593,9 +466,6 @@ typedef struct z_moved_fifo_handler_reply_t { typedef struct z_moved_fifo_handler_sample_t { struct z_owned_fifo_handler_sample_t _this; } z_moved_fifo_handler_sample_t; -typedef struct z_moved_source_info_t { - struct z_owned_source_info_t _this; -} z_moved_source_info_t; /** * Options passed to the `z_get()` function. */ @@ -628,26 +498,10 @@ typedef struct z_get_options_t { * The allowed destination for the query. */ enum zc_locality_t allowed_destination; -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * - * The accepted replies for the query. - */ - enum zc_reply_keyexpr_t accept_replies; -#endif /** * The priority of the query. */ enum z_priority_t priority; -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * - * The source info for the query. - */ - struct z_moved_source_info_t *source_info; -#endif /** * An optional attachment to attach to the query. */ @@ -660,6 +514,15 @@ typedef struct z_get_options_t { typedef struct z_moved_hello_t { struct z_owned_hello_t _this; } z_moved_hello_t; +/** + *@brief An owned Zenoh matching listener. + * + *A listener that sends notifications when the [`MatchingStatus`] of a publisher or querier changes. + *Dropping the corresponding publisher, also drops matching listener. + */ +typedef struct ALIGN(8) z_owned_matching_listener_t { + uint8_t _0[24]; +} z_owned_matching_listener_t; typedef struct z_moved_keyexpr_t { struct z_owned_keyexpr_t _this; } z_moved_keyexpr_t; @@ -693,9 +556,6 @@ typedef struct z_moved_liveliness_token_t { typedef struct z_moved_matching_listener_t { struct z_owned_matching_listener_t _this; } z_moved_matching_listener_t; -typedef struct z_moved_memory_layout_t { - struct z_owned_memory_layout_t _this; -} z_moved_memory_layout_t; typedef struct z_moved_mutex_t { struct z_owned_mutex_t _this; } z_moved_mutex_t; @@ -730,14 +590,6 @@ typedef struct z_publisher_put_options_t { * The timestamp of the publication. */ const struct z_timestamp_t *timestamp; -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * - * The source info for the publication. - */ - struct z_moved_source_info_t *source_info; -#endif /** * The attachment to attach to the publication. */ @@ -767,31 +619,21 @@ typedef struct z_put_options_t { * The timestamp of this message. */ struct z_timestamp_t *timestamp; -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * - * The put operation reliability. - */ - enum z_reliability_t reliability; -#endif /** * The allowed destination of this message. */ enum zc_locality_t allowed_destination; -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * - * The source info for the message. - */ - struct z_moved_source_info_t *source_info; -#endif /** * The attachment to this message. */ struct z_moved_bytes_t *attachment; } z_put_options_t; +/** + *A loaned Zenoh queryable. + */ +typedef struct ALIGN(8) z_loaned_querier_t { + uint8_t _0[80]; +} z_loaned_querier_t; typedef struct z_moved_querier_t { struct z_owned_querier_t _this; } z_moved_querier_t; @@ -807,14 +649,6 @@ typedef struct z_querier_get_options_t { * An optional encoding of the query payload and or attachment. */ struct z_moved_encoding_t *encoding; -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * - * The source info for the query. - */ - struct z_moved_source_info_t *source_info; -#endif /** * An optional attachment to attach to the query. */ @@ -848,14 +682,6 @@ typedef struct z_query_reply_options_t { * The timestamp of the reply. */ struct z_timestamp_t *timestamp; -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * - * The source info for the reply. - */ - struct z_moved_source_info_t *source_info; -#endif /** * The attachment to this reply. */ @@ -882,14 +708,6 @@ typedef struct z_query_reply_del_options_t { * The timestamp of the reply. */ struct z_timestamp_t *timestamp; -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * - * The source info for the reply. - */ - struct z_moved_source_info_t *source_info; -#endif /** * The attachment to this reply. */ @@ -942,15 +760,6 @@ typedef struct z_scout_options_t { typedef struct z_moved_session_t { struct z_owned_session_t _this; } z_moved_session_t; -typedef struct z_moved_shm_client_t { - struct z_owned_shm_client_t _this; -} z_moved_shm_client_t; -typedef struct z_moved_shm_client_storage_t { - struct z_owned_shm_client_storage_t _this; -} z_moved_shm_client_storage_t; -typedef struct z_moved_shm_provider_t { - struct z_owned_shm_provider_t _this; -} z_moved_shm_provider_t; typedef struct z_moved_string_array_t { struct z_owned_string_array_t _this; } z_moved_string_array_t; @@ -985,586 +794,97 @@ typedef struct zc_owned_closure_log_t { typedef struct zc_moved_closure_log_t { struct zc_owned_closure_log_t _this; } zc_moved_closure_log_t; -typedef struct zc_moved_concurrent_close_handle_t { - struct zc_owned_concurrent_close_handle_t _this; -} zc_moved_concurrent_close_handle_t; typedef struct zc_internal_encoding_data_t { uint16_t id; const uint8_t *schema_ptr; size_t schema_len; } zc_internal_encoding_data_t; -typedef struct zc_moved_shm_client_list_t { - struct zc_owned_shm_client_list_t _this; -} zc_moved_shm_client_list_t; +typedef struct ze_moved_serializer_t { + struct ze_owned_serializer_t _this; +} ze_moved_serializer_t; /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Setting for advanced publisher's cache. The cache allows advanced subscribers to recover history and/or lost samples. + * Constructs an owned shallow copy of data in provided uninitialized memory location. */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct ze_advanced_publisher_cache_options_t { - /** - * Must be set to ``true``, to enable the cache. - */ - bool is_enabled; - /** - * Number of samples to keep for each resource. - */ - size_t max_samples; - /** - * The congestion control to apply to replies. - */ - enum z_congestion_control_t congestion_control; - /** - * The priority of replies. - */ - enum z_priority_t priority; - /** - * If set to ``true``, this cache replies will not be batched. This usually has a positive impact on latency but negative impact on throughput. - */ - bool is_express; -} ze_advanced_publisher_cache_options_t; -#endif +ZENOHC_API void z_bytes_clone(struct z_owned_bytes_t *dst, const struct z_loaned_bytes_t *this_); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Represents the set of options that can be applied to the delete operation by a previously declared advanced publisher, - * whenever issued via `ze_advanced_publisher_delete()`. + * Converts a data from buffer into `z_owned_bytes_t` by copying. + * @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. + * @param data: A pointer to the buffer containing data. + * @param len: Length of the buffer. + * @return 0 in case of success, negative error code otherwise. */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct ze_advanced_publisher_delete_options_t { - /** - * Base delete options. - */ - struct z_publisher_delete_options_t delete_options; -} ze_advanced_publisher_delete_options_t; -#endif -typedef struct ze_moved_advanced_publisher_t { - struct ze_owned_advanced_publisher_t _this; -} ze_moved_advanced_publisher_t; +ZENOHC_API +z_result_t z_bytes_copy_from_buf(struct z_owned_bytes_t *this_, + const uint8_t *data, + size_t len); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Settings for sample miss detection on Advanced Publisher. + * Converts a slice into `z_owned_bytes_t` by copying. */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct ze_advanced_publisher_sample_miss_detection_options_t { - /** - * Must be set to ``true``, to enable sample miss detection by adding sequence numbers. - */ - bool is_enabled; - /** - * Allow last sample miss detection through sporadic or periodic heartbeat. - */ - enum ze_advanced_publisher_heartbeat_mode_t heartbeat_mode; - /** - * If heartbeat_mode is not NONE, the publisher will send heartbeats with the specified period, which - * can be used by Advanced Subscribers for last sample(s) miss detection (if last sample miss detection with zero query period is enabled). - */ - uint64_t heartbeat_period_ms; -} ze_advanced_publisher_sample_miss_detection_options_t; -#endif +ZENOHC_API +void z_bytes_copy_from_slice(struct z_owned_bytes_t *this_, + const struct z_loaned_slice_t *slice); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Options passed to the `ze_declare_advanced_publisher()` function. + * Converts a null-terminated string into `z_owned_bytes_t` by copying. + * @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. + * @param str: a pointer to the null-terminated string. + * @return 0 in case of success, negative error code otherwise. */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct ze_advanced_publisher_options_t { - /** - * Base publisher options. - */ - struct z_publisher_options_t publisher_options; - /** - * Publisher cache settings. - */ - struct ze_advanced_publisher_cache_options_t cache; - /** - * Settings to allow matching Subscribers to detect lost samples and optionally ask for retransimission. - * - * Retransmission can only be done if cache is enabled. - */ - struct ze_advanced_publisher_sample_miss_detection_options_t sample_miss_detection; - /** - * Allow this publisher to be detected through liveliness. - */ - bool publisher_detection; - /** - * An optional key expression to be added to the liveliness token key expression. - * It can be used to convey meta data. - */ - const struct z_loaned_keyexpr_t *publisher_detection_metadata; -} ze_advanced_publisher_options_t; -#endif +ZENOHC_API z_result_t z_bytes_copy_from_str(struct z_owned_bytes_t *this_, const char *str); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Options passed to the `ze_advanced_publisher_put()` function. + * Converts a string into `z_owned_bytes_t` by copying. */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct ze_advanced_publisher_put_options_t { - /** - * Base put options. - */ - struct z_publisher_put_options_t put_options; -} ze_advanced_publisher_put_options_t; -#endif +ZENOHC_API +void z_bytes_copy_from_string(struct z_owned_bytes_t *this_, + const struct z_loaned_string_t *str); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief A struct that represents missed samples. + * Drops `this_`, resetting it to gravestone value. If there are any shallow copies + * created by `z_bytes_clone()`, they would still stay valid. */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct ze_miss_t { - /** - * The source of missed samples. - */ - struct z_entity_global_id_t source; - /** - * The number of missed samples. - */ - uint32_t nb; -} ze_miss_t; -#endif +ZENOHC_API void z_bytes_drop(struct z_moved_bytes_t *this_); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief A sample miss-processing closure. - * - * A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks. + * Constructs an empty instance of `z_owned_bytes_t`. */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct ze_owned_closure_miss_t { - void *_context; - void (*_call)(const struct ze_miss_t *matching_status, void *context); - void (*_drop)(void *context); -} ze_owned_closure_miss_t; -#endif +ZENOHC_API void z_bytes_empty(struct z_owned_bytes_t *this_); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Moved closure. + * Converts buffer into `z_owned_bytes_t`. + * @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. + * @param data: A pointer to the buffer containing data. `this_` will take ownership of the buffer. + * @param len: Length of the buffer. + * @param deleter: A thread-safe function, that will be called on `data` when `this_` is dropped. Can be `NULL` if `data` is located in static memory and does not require a drop. + * @param context: An optional context to be passed to `deleter`. + * @return 0 in case of success, negative error code otherwise. */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct ze_moved_closure_miss_t { - struct ze_owned_closure_miss_t _this; -} ze_moved_closure_miss_t; -#endif +ZENOHC_API +z_result_t z_bytes_from_buf(struct z_owned_bytes_t *this_, + uint8_t *data, + size_t len, + void (*deleter)(void *data, void *context), + void *context); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief An owned Zenoh sample miss listener. Missed samples can only be detected from advanced publishers, enabling sample miss detection. - * - * A listener that sends notification when the advanced subscriber misses a sample . - * Dropping the corresponding subscriber, also drops the listener. + * Converts a slice into `z_owned_bytes_t`. + * The slice is consumed upon function return. */ -typedef struct ALIGN(8) ze_owned_sample_miss_listener_t { - uint8_t _0[24]; -} ze_owned_sample_miss_listener_t; -typedef struct ze_moved_advanced_subscriber_t { - struct ze_owned_advanced_subscriber_t _this; -} ze_moved_advanced_subscriber_t; +ZENOHC_API void z_bytes_from_slice(struct z_owned_bytes_t *this_, struct z_moved_slice_t *slice); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Settings for retrievieng historical data for Advanced Subscriber. + * Converts a statically allocated constant buffer into `z_owned_bytes_t`. + * @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. + * @param data: A pointer to the statically allocated constant data. + * @param len: A length of the buffer. + * @return 0 in case of success, negative error code otherwise. */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct ze_advanced_subscriber_history_options_t { - /** - * Must be set to ``true``, to enable the history data recovery. - */ - bool is_enabled; - /** - * Enable detection of late joiner publishers and query for their historical data. - * Late joiner detection can only be achieved for Publishers that enable publisher_detection. - * History can only be retransmitted by Publishers that enable caching. - */ - bool detect_late_publishers; - /** - * Number of samples to query for each resource. ``0`` corresponds to no limit on number of samples. - */ - size_t max_samples; - /** - * Maximum age of samples to query. ``0`` corresponds to no limit on samples' age. - */ - uint64_t max_age_ms; -} ze_advanced_subscriber_history_options_t; -#endif +ZENOHC_API +z_result_t z_bytes_from_static_buf(struct z_owned_bytes_t *this_, + uint8_t *data, + size_t len); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Settings for detection of the last sample(s) miss by Advanced Subscriber. + * Converts a statically allocated constant null-terminated string into `z_owned_bytes_t` by aliasing. + * @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. + * @param str: a pointer to the statically allocated constant string. + * @return 0 in case of success, negative error code otherwise. */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct ze_advanced_subscriber_last_sample_miss_detection_options_t { - /** - * Must be set to ``true``, to enable the last sample(s) miss detection. - */ - bool is_enabled; - /** - * Period for queries for not yet received Samples. - * - * These queries allow to retrieve the last Sample(s) if the last Sample(s) is/are lost. - * So it is useful for sporadic publications but useless for periodic publications - * with a period smaller or equal to this period. If set to 0, the last sample(s) miss detection will be performed - * based on publisher's heartbeat if the latter is enabled. - */ - uint64_t periodic_queries_period_ms; -} ze_advanced_subscriber_last_sample_miss_detection_options_t; -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Settings for recovering lost messages for Advanced Subscriber. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct ze_advanced_subscriber_recovery_options_t { - /** - * Must be set to ``true``, to enable the lost sample recovery. - */ - bool is_enabled; - /** - * Setting for detecting last sample(s) miss. - * Note that it does not affect intermediate sample miss detection/retrieval (which is performed automatically as long as recovery is enabled). - * If this option is disabled, subscriber will be unable to detect/request retransmission of missed sample until it receives a more recent one from the same publisher. - */ - struct ze_advanced_subscriber_last_sample_miss_detection_options_t last_sample_miss_detection; -} ze_advanced_subscriber_recovery_options_t; -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Options passed to the `ze_declare_advanced_subscriber()` function. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct ze_advanced_subscriber_options_t { - /** - * Base subscriber options. - */ - struct z_subscriber_options_t subscriber_options; - /** - * Settings for querying historical data. History can only be retransmitted by Publishers that enable caching. - */ - struct ze_advanced_subscriber_history_options_t history; - /** - * Settings for retransmission of detected lost Samples. Retransmission of lost samples can only be done by Publishers that enable - * caching and sample_miss_detection. - */ - struct ze_advanced_subscriber_recovery_options_t recovery; - /** - * Timeout to be used for history and recovery queries. - * Default value will be used if set to ``0``. - */ - uint64_t query_timeout_ms; - /** - * Allow this subscriber to be detected through liveliness. - */ - bool subscriber_detection; - /** - * An optional key expression to be added to the liveliness token key expression. - * It can be used to convey meta data. - */ - const struct z_loaned_keyexpr_t *subscriber_detection_metadata; -} ze_advanced_subscriber_options_t; -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Loaned closure. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct ze_loaned_closure_miss_t { - size_t _0; - size_t _1; - size_t _2; -} ze_loaned_closure_miss_t; -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_publisher. - * @brief Options passed to the `ze_declare_publication_cache()` function. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct ze_publication_cache_options_t { - /** - * The suffix used for queryable. - */ - const struct z_loaned_keyexpr_t *queryable_suffix; - /** - * The restriction for the matching queries that will be receive by this publication cache. - */ - enum zc_locality_t queryable_origin; - /** - * The `complete` option for the queryable. - */ - bool queryable_complete; - /** - * The the history size (i.e. maximum number of messages to store). - */ - size_t history; - /** - * The limit number of cached resources. - */ - size_t resources_limit; -} ze_publication_cache_options_t; -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_subscriber. - * @brief A set of options that can be applied to a querying subscriber, - * upon its declaration via `ze_declare_querying_subscriber()`. - * - */ -#if defined(Z_FEATURE_UNSTABLE_API) -typedef struct ze_querying_subscriber_options_t { - /** - * The restriction for the matching publications that will be receive by this subscriber. - */ - enum zc_locality_t allowed_origin; - /** - * The selector to be used for queries. - */ - const struct z_loaned_keyexpr_t *query_selector; - /** - * The target to be used for queries. - */ - enum z_query_target_t query_target; - /** - * The consolidation mode to be used for queries. - */ - struct z_query_consolidation_t query_consolidation; -#if defined(Z_FEATURE_UNSTABLE_API) - /** - * The accepted replies for queries. - */ - enum zc_reply_keyexpr_t query_accept_replies; -#endif - /** - * The timeout to be used for queries. - */ - uint64_t query_timeout_ms; -} ze_querying_subscriber_options_t; -#endif -typedef struct ze_moved_publication_cache_t { - struct ze_owned_publication_cache_t _this; -} ze_moved_publication_cache_t; -typedef struct ze_moved_querying_subscriber_t { - struct ze_owned_querying_subscriber_t _this; -} ze_moved_querying_subscriber_t; -typedef struct ze_moved_sample_miss_listener_t { - struct ze_owned_sample_miss_listener_t _this; -} ze_moved_sample_miss_listener_t; -typedef struct ze_moved_serializer_t { - struct ze_owned_serializer_t _this; -} ze_moved_serializer_t; -ZENOHC_API extern const unsigned int Z_ROUTER; -ZENOHC_API extern const unsigned int Z_PEER; -ZENOHC_API extern const unsigned int Z_CLIENT; -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make allocation without any additional actions. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_alloc_layout_alloc(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make allocation performing garbage collection if needed. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_alloc_layout_alloc_gc(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make allocation performing garbage collection and/or defragmentation if needed. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_alloc_layout_alloc_gc_defrag(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make allocation performing garbage collection and/or defragmentation and/or blocking if needed. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_alloc_layout_alloc_gc_defrag_blocking(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make allocation performing garbage collection and/or defragmentation and/or forced deallocation if needed. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_alloc_layout_alloc_gc_defrag_dealloc(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Deletes Alloc Layout. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_alloc_layout_drop(struct z_moved_alloc_layout_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Borrows Alloc Layout. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -const struct z_loaned_alloc_layout_t *z_alloc_layout_loan(const struct z_owned_alloc_layout_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Creates a new Alloc Layout for SHM Provider. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_alloc_layout_new(struct z_owned_alloc_layout_t *this_, - const struct z_loaned_shm_provider_t *provider, - size_t size); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make allocation performing garbage collection and/or defragmentation in async manner. Will return Z_EINVAL - * if used with non-threadsafe SHM Provider. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_alloc_layout_threadsafe_alloc_gc_defrag_async(struct z_buf_alloc_result_t *out_result, - const struct z_loaned_alloc_layout_t *layout, - struct zc_threadsafe_context_t result_context, - void (*result_callback)(void*, - struct z_buf_alloc_result_t*)); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Creates a new Alloc Layout for SHM Provider specifying the exact alignment. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_alloc_layout_with_alignment_new(struct z_owned_alloc_layout_t *this_, - const struct z_loaned_shm_provider_t *provider, - size_t size, - struct z_alloc_alignment_t alignment); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Converts data into a loaned SHM buffer. - * - * @param this_: Data to convert. - * @param dst: An uninitialized memory location where to construct an SHM buffer. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_bytes_as_loaned_shm(const struct z_loaned_bytes_t *this_, - const struct z_loaned_shm_t **dst); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Converts data into a mutably loaned SHM buffer. - * - * @param this_: Data to convert. - * @param dst: An uninitialized memory location where to construct an SHM buffer. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_bytes_as_mut_loaned_shm(struct z_loaned_bytes_t *this_, - struct z_loaned_shm_t **dst); -#endif -/** - * Constructs an owned shallow copy of data in provided uninitialized memory location. - */ -ZENOHC_API void z_bytes_clone(struct z_owned_bytes_t *dst, const struct z_loaned_bytes_t *this_); -/** - * Converts a data from buffer into `z_owned_bytes_t` by copying. - * @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. - * @param data: A pointer to the buffer containing data. - * @param len: Length of the buffer. - * @return 0 in case of success, negative error code otherwise. - */ -ZENOHC_API -z_result_t z_bytes_copy_from_buf(struct z_owned_bytes_t *this_, - const uint8_t *data, - size_t len); -/** - * Converts a slice into `z_owned_bytes_t` by copying. - */ -ZENOHC_API -void z_bytes_copy_from_slice(struct z_owned_bytes_t *this_, - const struct z_loaned_slice_t *slice); -/** - * Converts a null-terminated string into `z_owned_bytes_t` by copying. - * @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. - * @param str: a pointer to the null-terminated string. - * @return 0 in case of success, negative error code otherwise. - */ -ZENOHC_API z_result_t z_bytes_copy_from_str(struct z_owned_bytes_t *this_, const char *str); -/** - * Converts a string into `z_owned_bytes_t` by copying. - */ -ZENOHC_API -void z_bytes_copy_from_string(struct z_owned_bytes_t *this_, - const struct z_loaned_string_t *str); -/** - * Drops `this_`, resetting it to gravestone value. If there are any shallow copies - * created by `z_bytes_clone()`, they would still stay valid. - */ -ZENOHC_API void z_bytes_drop(struct z_moved_bytes_t *this_); -/** - * Constructs an empty instance of `z_owned_bytes_t`. - */ -ZENOHC_API void z_bytes_empty(struct z_owned_bytes_t *this_); -/** - * Converts buffer into `z_owned_bytes_t`. - * @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. - * @param data: A pointer to the buffer containing data. `this_` will take ownership of the buffer. - * @param len: Length of the buffer. - * @param deleter: A thread-safe function, that will be called on `data` when `this_` is dropped. Can be `NULL` if `data` is located in static memory and does not require a drop. - * @param context: An optional context to be passed to `deleter`. - * @return 0 in case of success, negative error code otherwise. - */ -ZENOHC_API -z_result_t z_bytes_from_buf(struct z_owned_bytes_t *this_, - uint8_t *data, - size_t len, - void (*deleter)(void *data, void *context), - void *context); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Converts from an immutable SHM buffer consuming it. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_bytes_from_shm(struct z_owned_bytes_t *this_, - struct z_moved_shm_t *shm); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Converts a mutable SHM buffer consuming it. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_bytes_from_shm_mut(struct z_owned_bytes_t *this_, - struct z_moved_shm_mut_t *shm); -#endif -/** - * Converts a slice into `z_owned_bytes_t`. - * The slice is consumed upon function return. - */ -ZENOHC_API void z_bytes_from_slice(struct z_owned_bytes_t *this_, struct z_moved_slice_t *slice); -/** - * Converts a statically allocated constant buffer into `z_owned_bytes_t`. - * @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. - * @param data: A pointer to the statically allocated constant data. - * @param len: A length of the buffer. - * @return 0 in case of success, negative error code otherwise. - */ -ZENOHC_API -z_result_t z_bytes_from_static_buf(struct z_owned_bytes_t *this_, - uint8_t *data, - size_t len); -/** - * Converts a statically allocated constant null-terminated string into `z_owned_bytes_t` by aliasing. - * @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. - * @param str: a pointer to the statically allocated constant string. - * @return 0 in case of success, negative error code otherwise. - */ -ZENOHC_API -z_result_t z_bytes_from_static_str(struct z_owned_bytes_t *this_, - const char *str); +ZENOHC_API +z_result_t z_bytes_from_static_str(struct z_owned_bytes_t *this_, + const char *str); /** * Converts a null-terminated string into `z_owned_bytes_t`. * @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. @@ -1583,21 +903,6 @@ z_result_t z_bytes_from_str(struct z_owned_bytes_t *this_, * The string is consumed upon function return. */ ZENOHC_API void z_bytes_from_string(struct z_owned_bytes_t *this_, struct z_moved_string_t *s); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Attempts to get a contiguous view to the underlying bytes. - * This is only possible if data is not fragmented, otherwise the function will fail. - * In case of fragmented data, consider using `z_bytes_get_slice_iterator()`. - * - * @param this_: An instance of Zenoh data. - * @param view: An uninitialized memory location where a contiguous view on data will be constructed. - * @return ​0​ upon success, negative error code otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t z_bytes_get_contiguous_view(const struct z_loaned_bytes_t *this_, - struct z_view_slice_t *view); -#endif /** * Returns a reader for the data. * @@ -1670,18 +975,6 @@ ZENOHC_API int64_t z_bytes_reader_tell(struct z_bytes_reader_t *this_); ZENOHC_API bool z_bytes_slice_iterator_next(struct z_bytes_slice_iterator_t *this_, struct z_view_slice_t *slice); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Converts data into an owned SHM buffer by copying it's shared reference. - * - * @param this_: Data to convert. - * @param dst: An uninitialized memory location where to construct an SHM buffer. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_bytes_to_owned_shm(const struct z_loaned_bytes_t *this_, - struct z_owned_shm_t *dst); -#endif /** * Converts data into an owned slice. * @@ -1734,7 +1027,7 @@ void z_bytes_writer_finish(struct z_moved_bytes_writer_t *this_, ZENOHC_API const struct z_loaned_bytes_writer_t *z_bytes_writer_loan(const struct z_owned_bytes_writer_t *this_); /** - * Muatably borrows writer. + * Mutably borrows writer. */ ZENOHC_API struct z_loaned_bytes_writer_t *z_bytes_writer_loan_mut(struct z_owned_bytes_writer_t *this_); @@ -1747,32 +1040,6 @@ ZENOHC_API z_result_t z_bytes_writer_write_all(struct z_loaned_bytes_writer_t *this_, const uint8_t *src, size_t len); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Deletes Chunk Alloc Result. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_chunk_alloc_result_drop(struct z_moved_chunk_alloc_result_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Creates a new Chunk Alloc Result with Error value. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_chunk_alloc_result_new_error(struct z_owned_chunk_alloc_result_t *this_, - enum z_alloc_error_t alloc_error); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Creates a new Chunk Alloc Result with Ok value. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_chunk_alloc_result_new_ok(struct z_owned_chunk_alloc_result_t *this_, - struct z_allocated_chunk_t allocated_chunk); -#endif /** * Get number of milliseconds passed since creation of `time`. */ @@ -1840,7 +1107,7 @@ ZENOHC_API void z_closure_hello_drop(struct z_moved_closure_hello_t *this_); ZENOHC_API const struct z_loaned_closure_hello_t *z_closure_hello_loan(const struct z_owned_closure_hello_t *closure); /** - * Mutably norrows closure. + * Mutably borrows closure. */ ZENOHC_API struct z_loaned_closure_hello_t *z_closure_hello_loan_mut(struct z_owned_closure_hello_t *closure); @@ -2627,30 +1894,14 @@ ZENOHC_API const struct z_loaned_encoding_t *z_encoding_zenoh_serialized(void); ZENOHC_API const struct z_loaned_encoding_t *z_encoding_zenoh_string(void); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns the entity id of the entity global id. + * Constructs send and recieve ends of the fifo channel */ -#if defined(Z_FEATURE_UNSTABLE_API) ZENOHC_API -uint32_t z_entity_global_id_eid(const struct z_entity_global_id_t *this_); -#endif +void z_fifo_channel_query_new(struct z_owned_closure_query_t *callback, + struct z_owned_fifo_handler_query_t *handler, + size_t capacity); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns the zenoh id of entity global id. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -struct z_id_t z_entity_global_id_zid(const struct z_entity_global_id_t *this_); -#endif -/** - * Constructs send and recieve ends of the fifo channel - */ -ZENOHC_API -void z_fifo_channel_query_new(struct z_owned_closure_query_t *callback, - struct z_owned_fifo_handler_query_t *handler, - size_t capacity); -/** - * Constructs send and recieve ends of the fifo channel + * Constructs send and recieve ends of the fifo channel */ ZENOHC_API void z_fifo_channel_reply_new(struct z_owned_closure_reply_t *callback, @@ -2852,22 +2103,6 @@ z_result_t z_info_routers_zid(const struct z_loaned_session_t *session, * to pass it a valid session. */ ZENOHC_API struct z_id_t z_info_zid(const struct z_loaned_session_t *session); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_alloc_layout_check(const struct z_owned_alloc_layout_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs Alloc Layout in its gravestone value. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_internal_alloc_layout_null(struct z_owned_alloc_layout_t *this_); -#endif /** * Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. */ @@ -2884,22 +2119,6 @@ ZENOHC_API bool z_internal_bytes_writer_check(const struct z_owned_bytes_writer_ * Constructs a writer in a gravestone state. */ ZENOHC_API void z_internal_bytes_writer_null(struct z_owned_bytes_writer_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_chunk_alloc_result_check(const struct z_owned_chunk_alloc_result_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs Chunk Alloc Result in its gravestone value. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_internal_chunk_alloc_result_null(struct z_owned_chunk_alloc_result_t *this_); -#endif /** * Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. */ @@ -3050,22 +2269,6 @@ ZENOHC_API bool z_internal_matching_listener_check(const struct z_owned_matching * @brief Constructs an empty matching listener. */ ZENOHC_API void z_internal_matching_listener_null(struct z_owned_matching_listener_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_memory_layout_check(const struct z_owned_memory_layout_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs Memory Layout in its gravestone value. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_internal_memory_layout_null(struct z_owned_memory_layout_t *this_); -#endif /** * Returns ``true`` if mutex is valid, ``false`` otherwise. */ @@ -3074,22 +2277,6 @@ ZENOHC_API bool z_internal_mutex_check(const struct z_owned_mutex_t *this_); * Constructs mutex in a gravestone state. */ ZENOHC_API void z_internal_mutex_null(struct z_owned_mutex_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_ptr_in_segment_check(const struct z_owned_ptr_in_segment_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs data pointer in SHM Segment in its gravestone value. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_internal_ptr_in_segment_null(struct z_owned_ptr_in_segment_t *this_); -#endif /** * Returns ``true`` if publisher is valid, ``false`` otherwise. */ @@ -3181,86 +2368,6 @@ ZENOHC_API bool z_internal_session_check(const struct z_owned_session_t *this_); * Constructs a Zenoh session in its gravestone state. */ ZENOHC_API void z_internal_session_null(struct z_owned_session_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_shm_check(const struct z_owned_shm_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_shm_client_check(const struct z_owned_shm_client_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs SHM client in its gravestone value. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_internal_shm_client_null(struct z_owned_shm_client_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_shm_client_storage_check(const struct z_owned_shm_client_storage_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Constructs SHM Client Storage in its gravestone value. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_internal_shm_client_storage_null(struct z_owned_shm_client_storage_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_shm_mut_check(const struct z_owned_shm_mut_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs ZShmMut slice in its gravestone value. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_internal_shm_mut_null(struct z_owned_shm_mut_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs ZShm slice in its gravestone value. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_internal_shm_null(struct z_owned_shm_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool z_internal_shm_provider_check(const struct z_owned_shm_provider_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs SHM Provider in its gravestone value. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_internal_shm_provider_null(struct z_owned_shm_provider_t *this_); -#endif /** * @return ``true`` if slice is not empty, ``false`` otherwise. */ @@ -3269,22 +2376,6 @@ ZENOHC_API bool z_internal_slice_check(const struct z_owned_slice_t *this_); * Constructs an empty `z_owned_slice_t`. */ ZENOHC_API void z_internal_slice_null(struct z_owned_slice_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if source info is valid, ``false`` if it is in gravestone state. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool z_internal_source_info_check(const struct z_owned_source_info_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs source info in its gravestone state. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void z_internal_source_info_null(struct z_owned_source_info_t *this_); -#endif /** * @return ``true`` if the string array is valid, ``false`` if it is in a gravestone state. */ @@ -3443,17 +2534,6 @@ z_result_t z_keyexpr_join(struct z_owned_keyexpr_t *this_, * Borrows `z_owned_keyexpr_t`. */ ZENOHC_API const struct z_loaned_keyexpr_t *z_keyexpr_loan(const struct z_owned_keyexpr_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns the relation between `left` and `right` from `left`'s point of view. - * - * @note This is slower than `z_keyexpr_intersects` and `keyexpr_includes`, so you should favor these methods for most applications. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -enum z_keyexpr_intersection_level_t z_keyexpr_relation_to(const struct z_loaned_keyexpr_t *left, - const struct z_loaned_keyexpr_t *right); -#endif /** * @brief Declares a background subscriber on liveliness tokens that intersect `key_expr`. Subscriber callback will be called to process the messages, * until the corresponding session is closed or dropped. @@ -3545,42 +2625,6 @@ ZENOHC_API z_result_t z_liveliness_undeclare_token(struct z_moved_liveliness_tok * @brief Undeclares the given matching listener, droping and invalidating it. */ ZENOHC_API void z_matching_listener_drop(struct z_moved_matching_listener_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Deletes Memory Layout. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_memory_layout_drop(struct z_moved_memory_layout_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Extract data from Memory Layout. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_memory_layout_get_data(const struct z_loaned_memory_layout_t *this_, - size_t *out_size, - struct z_alloc_alignment_t *out_alignment); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Borrows Memory Layout. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -const struct z_loaned_memory_layout_t *z_memory_layout_loan(const struct z_owned_memory_layout_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Creates a new Memory Layout. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_memory_layout_new(struct z_owned_memory_layout_t *this_, - size_t size, - struct z_alloc_alignment_t alignment); -#endif /** * Drops mutex and resets it to its gravestone state. */ @@ -3623,83 +2667,10 @@ z_result_t z_open(struct z_owned_session_t *this_, * Constructs the default value for `z_open_options_t`. */ ZENOHC_API void z_open_options_default(struct z_open_options_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs and opens a new Zenoh session with specified client storage. - * - * @return 0 in case of success, negative error code otherwise (in this case the session will be in its gravestone state). - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_open_with_custom_shm_clients(struct z_owned_session_t *this_, - struct z_moved_config_t *config, - const struct z_loaned_shm_client_storage_t *shm_clients); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Creates a new POSIX SHM Client. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_posix_shm_client_new(struct z_owned_shm_client_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Creates a new POSIX SHM Provider. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_posix_shm_provider_new(struct z_owned_shm_provider_t *this_, - size_t size); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Creates a new POSIX SHM Provider. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_posix_shm_provider_with_layout_new(struct z_owned_shm_provider_t *this_, - const struct z_loaned_memory_layout_t *layout); -#endif /** * Returns the default value of #z_priority_t. */ ZENOHC_API enum z_priority_t z_priority_default(void); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Makes a shallow data pointer in SHM Segment copy. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_ptr_in_segment_clone(struct z_owned_ptr_in_segment_t *out, - const struct z_loaned_ptr_in_segment_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Deletes data pointer in SHM Segment. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_ptr_in_segment_drop(struct z_moved_ptr_in_segment_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Borrows data pointer in SHM Segment. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -const struct z_loaned_ptr_in_segment_t *z_ptr_in_segment_loan(const struct z_owned_ptr_in_segment_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Creates a new data pointer in SHM Segment. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_ptr_in_segment_new(struct z_owned_ptr_in_segment_t *this_, - uint8_t *ptr, - struct zc_threadsafe_context_t segment); -#endif /** * @brief Declares a matching listener, registering a callback for notifying subscribers matching with a given publisher. * The callback will be run in the background until the corresponding publisher is dropped. @@ -3750,14 +2721,6 @@ ZENOHC_API void z_publisher_drop(struct z_moved_publisher_t *this_); ZENOHC_API z_result_t z_publisher_get_matching_status(const struct z_loaned_publisher_t *this_, struct z_matching_status_t *matching_status); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns the ID of the publisher. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -struct z_entity_global_id_t z_publisher_id(const struct z_loaned_publisher_t *publisher); -#endif /** * Returns the key expression of the publisher. */ @@ -3891,14 +2854,6 @@ z_result_t z_querier_get_with_parameters_substr(const struct z_loaned_querier_t size_t parameters_len, struct z_moved_closure_reply_t *callback, struct z_querier_get_options_t *options); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns the ID of the querier. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -struct z_entity_global_id_t z_querier_id(const struct z_loaned_querier_t *querier); -#endif /** * @brief Returns the key expression of the querier. */ @@ -4093,14 +3048,6 @@ ZENOHC_API enum z_query_target_t z_query_target_default(void); * This is equivalent to calling `z_undeclare_queryable()` and discarding its return value. */ ZENOHC_API void z_queryable_drop(struct z_moved_queryable_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns the ID of the queryable. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -struct z_entity_global_id_t z_queryable_id(const struct z_loaned_queryable_t *queryable); -#endif /** * @brief Returns the key expression of the queryable. */ @@ -4132,22 +3079,6 @@ ZENOHC_API uint64_t z_random_u64(void); * Generates random `uint8_t`. */ ZENOHC_API uint8_t z_random_u8(void); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Reference the global client storage. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_ref_shm_client_storage_global(struct z_owned_shm_client_storage_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns the default value for `reliability`. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -enum z_reliability_t z_reliability_default(void); -#endif /** * Constructs an owned shallow copy of reply in provided uninitialized memory location. */ @@ -4226,16 +3157,6 @@ ZENOHC_API const struct z_loaned_sample_t *z_reply_ok(const struct z_loaned_repl * Returns `NULL` if reply does not contain a sample (i. e. if `z_reply_is_ok` returns ``false``). */ ZENOHC_API struct z_loaned_sample_t *z_reply_ok_mut(struct z_loaned_reply_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Gets the global id of the zenoh entity that answered this Reply. - * @return `true` if id is present. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool z_reply_replier_id(const struct z_loaned_reply_t *this_, - struct z_entity_global_id_t *out_id); -#endif /** * Takes ownership of the mutably borrowed reply */ @@ -4395,22 +3316,6 @@ ZENOHC_API struct z_loaned_bytes_t *z_sample_payload_mut(struct z_loaned_sample_ * Returns sample qos priority value. */ ZENOHC_API enum z_priority_t z_sample_priority(const struct z_loaned_sample_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns the reliability setting the sample was delivered with. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -enum z_reliability_t z_sample_reliability(const struct z_loaned_sample_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns the sample source_info. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -const struct z_loaned_source_info_t *z_sample_source_info(const struct z_loaned_sample_t *this_); -#endif /** * Takes ownership of the mutably borrowed sample. */ @@ -4456,451 +3361,36 @@ ZENOHC_API bool z_session_is_closed(const struct z_loaned_session_t *session); ZENOHC_API const struct z_loaned_session_t *z_session_loan(const struct z_owned_session_t *this_); ZENOHC_API struct z_loaned_session_t *z_session_loan_mut(struct z_owned_session_t *this_); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Deletes SHM Client. + * Puts current thread to sleep for specified amount of milliseconds. */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_client_drop(struct z_moved_shm_client_t *this_); -#endif +ZENOHC_API z_result_t z_sleep_ms(size_t time); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Creates a new SHM Client. + * Puts current thread to sleep for specified amount of seconds. */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_client_new(struct z_owned_shm_client_t *this_, - struct zc_threadsafe_context_t context, - struct zc_shm_client_callbacks_t callbacks); -#endif +ZENOHC_API z_result_t z_sleep_s(size_t time); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Performs a shallow copy of SHM Client Storage. + * Puts current thread to sleep for specified amount of microseconds. */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_client_storage_clone(struct z_owned_shm_client_storage_t *this_, - const struct z_loaned_shm_client_storage_t *from); -#endif +ZENOHC_API z_result_t z_sleep_us(size_t time); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Derefs SHM Client Storage. + * Constructs an owned copy of a slice. */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_client_storage_drop(struct z_moved_shm_client_storage_t *this_); -#endif +ZENOHC_API void z_slice_clone(struct z_owned_slice_t *dst, const struct z_loaned_slice_t *this_); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Borrows SHM Client Storage. + * Constructs a slice by copying a `len` bytes long sequence starting at `start`. + * + * @return -1 if `start == NULL` and `len > 0` (creating an empty slice), 0 otherwise. */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) ZENOHC_API -const struct z_loaned_shm_client_storage_t *z_shm_client_storage_loan(const struct z_owned_shm_client_storage_t *this_); -#endif +z_result_t z_slice_copy_from_buf(struct z_owned_slice_t *this_, + const uint8_t *start, + size_t len); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Create a new client storage object. + * @return the pointer to the slice data. */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_shm_client_storage_new(struct z_owned_shm_client_storage_t *this_, - const struct zc_loaned_shm_client_list_t *clients, - bool add_default_client_set); -#endif +ZENOHC_API const uint8_t *z_slice_data(const struct z_loaned_slice_t *this_); /** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Construct client storage with default client set. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_client_storage_new_default(struct z_owned_shm_client_storage_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Converts borrowed ZShm slice to owned ZShm slice by performing a shallow SHM reference copy. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_clone(struct z_owned_shm_t *out, - const struct z_loaned_shm_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return the pointer of the ZShm slice. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -const unsigned char *z_shm_data(const struct z_loaned_shm_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Deletes ZShm slice. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_drop(struct z_moved_shm_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs ZShm slice from ZShmMut slice. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_from_mut(struct z_owned_shm_t *this_, - struct z_moved_shm_mut_t *that); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return the length of the ZShm slice. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -size_t z_shm_len(const struct z_loaned_shm_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Borrows ZShm slice. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -const struct z_loaned_shm_t *z_shm_loan(const struct z_owned_shm_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Mutably borrows ZShm slice. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -struct z_loaned_shm_t *z_shm_loan_mut(struct z_owned_shm_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return the immutable pointer to the underlying data. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -const unsigned char *z_shm_mut_data(const struct z_loaned_shm_mut_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return the mutable pointer to the underlying data. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -unsigned char *z_shm_mut_data_mut(struct z_loaned_shm_mut_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Deletes ZShmMut slice. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_mut_drop(struct z_moved_shm_mut_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @return the length of the ZShmMut slice. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -size_t z_shm_mut_len(const struct z_loaned_shm_mut_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Borrows ZShmMut slice. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -const struct z_loaned_shm_mut_t *z_shm_mut_loan(const struct z_owned_shm_mut_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Mutably borrows ZShmMut slice. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -struct z_loaned_shm_mut_t *z_shm_mut_loan_mut(struct z_owned_shm_mut_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Tries to obtain mutable SHM buffer instead of immutable one. - * @param this_: mutable SHM buffer to be initialized upon success - * @param that: immutable SHM buffer - * @param immut: immutable SHM buffer returned back to caller's side - * ONLY in case of Z_EUNAVAILABLE failure - * @return Z_OK in case of success, Z_EUNAVAILABLE in case of unsuccessful write access, - * Z_EINVAL if moved value is incorrect. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_shm_mut_try_from_immut(struct z_owned_shm_mut_t *this_, - struct z_moved_shm_t *that, - struct z_owned_shm_t *immut); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make allocation without any additional actions. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_provider_alloc(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, - size_t size); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make aligned allocation without any additional actions. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_provider_alloc_aligned(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, - size_t size, - struct z_alloc_alignment_t alignment); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make allocation performing garbage collection if needed. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_provider_alloc_gc(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, - size_t size); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make aligned allocation performing garbage collection if needed. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_provider_alloc_gc_aligned(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, - size_t size, - struct z_alloc_alignment_t alignment); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make allocation performing garbage collection and/or defragmentation if needed. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_provider_alloc_gc_defrag(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, - size_t size); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make aligned allocation performing garbage collection and/or defragmentation if needed. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_provider_alloc_gc_defrag_aligned(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, - size_t size, - struct z_alloc_alignment_t alignment); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make aligned allocation performing garbage collection and/or defragmentation in async manner. Will return Z_EINVAL - * if used with non-threadsafe SHM Provider. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_shm_provider_alloc_gc_defrag_aligned_async(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, - size_t size, - struct z_alloc_alignment_t alignment, - struct zc_threadsafe_context_t result_context, - void (*result_callback)(void*, - struct z_buf_layout_alloc_result_t*)); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make allocation performing garbage collection and/or defragmentation in async manner. Will return Z_EINVAL - * if used with non-threadsafe SHM Provider. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_shm_provider_alloc_gc_defrag_async(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, - size_t size, - struct zc_threadsafe_context_t result_context, - void (*result_callback)(void*, - struct z_buf_layout_alloc_result_t*)); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make allocation performing garbage collection and/or defragmentation and/or blocking if needed. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_provider_alloc_gc_defrag_blocking(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, - size_t size); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make aligned allocation performing garbage collection and/or defragmentation and/or blocking if needed. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_provider_alloc_gc_defrag_blocking_aligned(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, - size_t size, - struct z_alloc_alignment_t alignment); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make allocation performing garbage collection and/or defragmentation and/or forced deallocation if needed. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_provider_alloc_gc_defrag_dealloc(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, - size_t size); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Make aligned allocation performing garbage collection and/or defragmentation and/or forced deallocation if needed. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_provider_alloc_gc_defrag_dealloc_aligned(struct z_buf_layout_alloc_result_t *out_result, - const struct z_loaned_shm_provider_t *provider, - size_t size, - struct z_alloc_alignment_t alignment); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Return the memory size available in the provider. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -size_t z_shm_provider_available(const struct z_loaned_shm_provider_t *provider); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Creates a new SHM Provider ith default backend. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_shm_provider_default_new(struct z_owned_shm_provider_t *this_, - size_t size); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Perform memory defragmentation. The real operations taken depend on the provider's backend allocator - * implementation. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -size_t z_shm_provider_defragment(const struct z_loaned_shm_provider_t *provider); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Deletes SHM Provider. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_provider_drop(struct z_moved_shm_provider_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Perform memory garbage collection and reclaim all dereferenced SHM buffers. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -size_t z_shm_provider_garbage_collect(const struct z_loaned_shm_provider_t *provider); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Borrows SHM Provider. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -const struct z_loaned_shm_provider_t *z_shm_provider_loan(const struct z_owned_shm_provider_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Map the preallocated data chunk into SHM buffer. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t z_shm_provider_map(struct z_owned_shm_mut_t *out_result, - const struct z_loaned_shm_provider_t *provider, - struct z_allocated_chunk_t allocated_chunk, - size_t len); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Creates a new SHM Provider. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_provider_new(struct z_owned_shm_provider_t *this_, - struct zc_context_t context, - struct zc_shm_provider_backend_callbacks_t callbacks); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Creates a new threadsafe SHM Provider. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void z_shm_provider_threadsafe_new(struct z_owned_shm_provider_t *this_, - struct zc_threadsafe_context_t context, - struct zc_shm_provider_backend_callbacks_t callbacks); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Mutably borrows ZShm slice as borrowed ZShmMut slice. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -struct z_loaned_shm_mut_t *z_shm_try_mut(struct z_owned_shm_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Tries to reborrow mutably-borrowed ZShm slice as borrowed ZShmMut slice. - * @return borrowed ZShmMut slice in case of success, NULL otherwise. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -struct z_loaned_shm_mut_t *z_shm_try_reloan_mut(struct z_loaned_shm_t *this_); -#endif -/** - * Puts current thread to sleep for specified amount of milliseconds. - */ -ZENOHC_API z_result_t z_sleep_ms(size_t time); -/** - * Puts current thread to sleep for specified amount of seconds. - */ -ZENOHC_API z_result_t z_sleep_s(size_t time); -/** - * Puts current thread to sleep for specified amount of microseconds. - */ -ZENOHC_API z_result_t z_sleep_us(size_t time); -/** - * Constructs an owned copy of a slice. - */ -ZENOHC_API void z_slice_clone(struct z_owned_slice_t *dst, const struct z_loaned_slice_t *this_); -/** - * Constructs a slice by copying a `len` bytes long sequence starting at `start`. - * - * @return -1 if `start == NULL` and `len > 0` (creating an empty slice), 0 otherwise. - */ -ZENOHC_API -z_result_t z_slice_copy_from_buf(struct z_owned_slice_t *this_, - const uint8_t *start, - size_t len); -/** - * @return the pointer to the slice data. - */ -ZENOHC_API const uint8_t *z_slice_data(const struct z_loaned_slice_t *this_); -/** - * Frees the memory and invalidates the slice. + * Frees the memory and invalidates the slice. */ ZENOHC_API void z_slice_drop(struct z_moved_slice_t *this_); /** @@ -4935,48 +3425,6 @@ ZENOHC_API size_t z_slice_len(const struct z_loaned_slice_t *this_); * Borrows slice. */ ZENOHC_API const struct z_loaned_slice_t *z_slice_loan(const struct z_owned_slice_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Frees the memory and invalidates the source info, resetting it to a gravestone state. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void z_source_info_drop(struct z_moved_source_info_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns the source_id of the source info. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -struct z_entity_global_id_t z_source_info_id(const struct z_loaned_source_info_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Borrows source info. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -const struct z_loaned_source_info_t *z_source_info_loan(const struct z_owned_source_info_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Creates source info. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t z_source_info_new(struct z_owned_source_info_t *this_, - const struct z_entity_global_id_t *source_id, - uint32_t source_sn); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns the source_sn of the source info. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -uint32_t z_source_info_sn(const struct z_loaned_source_info_t *this_); -#endif /** * Constructs an owned copy of a string array. */ @@ -5097,14 +3545,6 @@ ZENOHC_API const struct z_loaned_string_t *z_string_loan(const struct z_owned_st * This is equivalent to calling `z_undeclare_subscriber()` and discarding its return value. */ ZENOHC_API void z_subscriber_drop(struct z_moved_subscriber_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns the ID of the subscriber. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -struct z_entity_global_id_t z_subscriber_id(const struct z_loaned_subscriber_t *subscriber); -#endif /** * Returns the key expression of the subscriber. */ @@ -5369,25 +3809,6 @@ ZENOHC_API const struct z_loaned_string_t *z_view_string_loan(const struct z_vie ZENOHC_API z_result_t z_whatami_to_view_string(enum z_whatami_t whatami, struct z_view_string_t *str_out); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Linux: Trigger cleanup for orphaned SHM segments - * If process that created named SHM segment crashes or exits by a signal, the segment persists in the system - * disregarding if it is used by other Zenoh processes or not. This is the detail of POSIX specification for - * shared memory that is hard to bypass. To deal with this we developed a cleanup routine that enumerates all - * segments and tries to find processes that are using it. If no such process found, segment will be removed. - * There is no ideal signal to trigger this cleanup, so by default, zenoh triggers it in the following moments: - * - first POSIX SHM segment creation - * - process exit via exit() call or return from maint function - * - * It is OK to additionally trigger this function at any time, but be aware that this can be costly. - * - * For non-linux platforms this function currently does nothing - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void zc_cleanup_orphaned_shm_segments(void); -#endif /** * @brief Constructs closure. * @@ -5427,24 +3848,11 @@ ZENOHC_API void zc_closure_log_drop(struct zc_moved_closure_log_t *closure_); ZENOHC_API const struct zc_loaned_closure_log_t *zc_closure_log_loan(const struct zc_owned_closure_log_t *closure); /** - * @brief Drops the close handle. The concurrent close task will not be interrupted. + * Constructs a configuration by parsing a file path stored in ZENOH_CONFIG environmental variable. + * + * Returns 0 in case of success, negative error code otherwise. */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API void zc_concurrent_close_handle_drop(struct zc_moved_concurrent_close_handle_t *this_); -#endif -/** - * @brief Blocking wait on close handle to complete. Returns `Z_EIO` if close finishes with error. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t zc_concurrent_close_handle_wait(struct zc_moved_concurrent_close_handle_t *handle); -#endif -/** - * Constructs a configuration by parsing a file path stored in ZENOH_CONFIG environmental variable. - * - * Returns 0 in case of success, negative error code otherwise. - */ -ZENOHC_API z_result_t zc_config_from_env(struct z_owned_config_t *this_); +ZENOHC_API z_result_t zc_config_from_env(struct z_owned_config_t *this_); /** * Constructs a configuration by parsing a file at `path` null-terminated string. Currently supported format is JSON5, a superset of JSON. * @@ -5522,21 +3930,12 @@ z_result_t zc_config_insert_json5_from_substr(struct z_loaned_config_t *this_, ZENOHC_API z_result_t zc_config_to_string(const struct z_loaned_config_t *config, struct z_owned_string_t *out_config_string); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs a view string on last error message. - * The view string only remains valid until next faillable zenoh API call from the same thread. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void zc_get_last_error(struct z_view_string_t *out); -#endif /** * Initializes the zenoh runtime logger, using rust environment settings or the provided fallback level. * E.g.: `RUST_LOG=info` will enable logging at info level. Similarly, you can set the variable to `error` or `debug`. * * Note that if the environment variable is not set, then fallback filter will be used instead. - * See https://docs.rs/env_logger/latest/env_logger/index.html for accepted filter format. + * See for accepted filter format. * * @param fallback_filter: The fallback filter if the `RUST_LOG` environment variable is not set. */ @@ -5560,94 +3959,15 @@ ZENOHC_API bool zc_internal_closure_log_check(const struct zc_owned_closure_log_ * Constructs a closure in a gravestone state. */ ZENOHC_API void zc_internal_closure_log_null(struct zc_owned_closure_log_t *this_); -/** - * @brief Returns ``true`` if concurrent close handle is valid, ``false`` if it is in gravestone state. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool zc_internal_concurrent_close_handle_check(const struct zc_owned_concurrent_close_handle_t *this_); -#endif -/** - * @brief Constructs concurrent close handle in its gravestone state. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void zc_internal_concurrent_close_handle_null(struct zc_owned_concurrent_close_handle_t *this_); -#endif ZENOHC_API void zc_internal_encoding_from_data(struct z_owned_encoding_t *this_, struct zc_internal_encoding_data_t data); ZENOHC_API struct zc_internal_encoding_data_t zc_internal_encoding_get_data(const struct z_loaned_encoding_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if `this` is valid. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -bool zc_internal_shm_client_list_check(const struct zc_owned_shm_client_list_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs SHM client list in its gravestone value. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void zc_internal_shm_client_list_null(struct zc_owned_shm_client_list_t *this_); -#endif /** * @brief Returns default value of `zc_locality_t` */ ZENOHC_API enum zc_locality_t zc_locality_default(void); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns the default value of #zc_reply_keyexpr_t. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -enum zc_reply_keyexpr_t zc_reply_keyexpr_default(void); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Add client to the list. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t zc_shm_client_list_add_client(struct zc_loaned_shm_client_list_t *this_, - struct z_moved_shm_client_t *client); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Deletes list of SHM Clients. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void zc_shm_client_list_drop(struct zc_moved_shm_client_list_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Borrows list of SHM Clients. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -const struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan(const struct zc_owned_shm_client_list_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Mutably borrows list of SHM Clients. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -struct zc_loaned_shm_client_list_t *zc_shm_client_list_loan_mut(struct zc_owned_shm_client_list_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Creates a new empty list of SHM Clients. - */ -#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -void zc_shm_client_list_new(struct zc_owned_shm_client_list_t *this_); -#endif /** * Stops all Zenoh tasks and drops all related static variables. * All Zenoh-related structures should be properly dropped/undeclared PRIOR to this call. @@ -5661,468 +3981,10 @@ void zc_stop_z_runtime(void); * E.g.: `RUST_LOG=info` will enable logging at info level. Similarly, you can set the variable to `error` or `debug`. * * Note that if the environment variable is not set, then logging will not be enabled. - * See https://docs.rs/env_logger/latest/env_logger/index.html for accepted filter format. + * See for accepted filter format. */ ZENOHC_API void zc_try_init_log_from_env(void); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs the default value for `ze_advanced_publisher_cache_options_t`. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_advanced_publisher_cache_options_default(struct ze_advanced_publisher_cache_options_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Declares a matching listener, registering a callback for notifying subscribers matching with a given advanced publisher. - * The callback will be run in the background until the corresponding publisher is dropped. - * - * @param publisher: An advanced publisher to associate with matching listener. - * @param callback: A closure that will be called every time the matching status of the publisher changes (If last subscriber disconnects or when the first subscriber connects). - * - * @return 0 in case of success, negative error code otherwise. - */ -#if (defined(Z_FEATURE_UNSTABLE_API) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t ze_advanced_publisher_declare_background_matching_listener(const struct ze_loaned_advanced_publisher_t *publisher, - struct z_moved_closure_matching_status_t *callback); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs matching listener, registering a callback for notifying subscribers matching with a given advanced publisher. - * - * @param publisher: An advanced publisher to associate with matching listener. - * @param matching_listener: An uninitialized memory location where matching listener will be constructed. The matching listener's callback will be automatically dropped when the publisher is dropped. - * @param callback: A closure that will be called every time the matching status of the publisher changes (If last subscriber disconnects or when the first subscriber connects). - * - * @return 0 in case of success, negative error code otherwise. - */ -#if (defined(Z_FEATURE_UNSTABLE_API) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t ze_advanced_publisher_declare_matching_listener(const struct ze_loaned_advanced_publisher_t *publisher, - struct z_owned_matching_listener_t *matching_listener, - struct z_moved_closure_matching_status_t *callback); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Sends a `DELETE` message onto the advanced publisher's key expression. - * - * @return 0 in case of success, negative error code in case of failure. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_advanced_publisher_delete(const struct ze_loaned_advanced_publisher_t *publisher, - struct ze_advanced_publisher_delete_options_t *options); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Constructs the default values for the delete operation via an advanced publisher entity. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_advanced_publisher_delete_options_default(struct ze_advanced_publisher_delete_options_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Frees memory and resets advanced_publisher to its gravestone state. - * This is equivalent to calling `z_undeclare_publisher()` and discarding its return value. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_advanced_publisher_drop(struct ze_moved_advanced_publisher_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Gets advanced publisher matching status - i.e. if there are any subscribers matching its key expression. - * - * @return 0 in case of success, negative error code otherwise (in this case matching_status is not updated). - */ -#if (defined(Z_FEATURE_UNSTABLE_API) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -z_result_t ze_advanced_publisher_get_matching_status(const struct ze_loaned_advanced_publisher_t *this_, - struct z_matching_status_t *matching_status); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns the ID of the advanced publisher. - */ -#if (defined(Z_FEATURE_UNSTABLE_API) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -struct z_entity_global_id_t ze_advanced_publisher_id(const struct ze_loaned_advanced_publisher_t *publisher); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Returns the key expression of the publisher. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -const struct z_loaned_keyexpr_t *ze_advanced_publisher_keyexpr(const struct ze_loaned_advanced_publisher_t *publisher); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Borrows advanced publisher. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -const struct ze_loaned_advanced_publisher_t *ze_advanced_publisher_loan(const struct ze_owned_advanced_publisher_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Mutably borrows advanced publisher. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -struct ze_loaned_advanced_publisher_t *ze_advanced_publisher_loan_mut(struct ze_owned_advanced_publisher_t *this_); -#endif -/** - * Constructs the default value for `z_publisher_options_t`. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_advanced_publisher_options_default(struct ze_advanced_publisher_options_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Sends a `PUT` message onto the advanced publisher's key expression, transfering the payload ownership. - * - * The payload and all owned options fields are consumed upon function return. - * - * @param this_: The advanced publisher. - * @param payload: The data to publish. Will be consumed. - * @param options: The advanced publisher put options. All owned fields will be consumed. - * - * @return 0 in case of success, negative error values in case of failure. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_advanced_publisher_put(const struct ze_loaned_advanced_publisher_t *this_, - struct z_moved_bytes_t *payload, - struct ze_advanced_publisher_put_options_t *options); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Constructs the default value for `ze_advanced_publisher_put_options_t`. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_advanced_publisher_put_options_default(struct ze_advanced_publisher_put_options_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs the default value for `ze_advanced_publisher_sample_miss_detection_options_t`. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_advanced_publisher_sample_miss_detection_options_default(struct ze_advanced_publisher_sample_miss_detection_options_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Declares a sample miss listener, registering a callback for notifying subscriber about missed samples. - * The callback will be run in the background until the corresponding subscriber is dropped. - * - * @param subscriber: A subscriber to associate with sample miss listener. - * @param callback: A closure that will be called every time the sample miss is detected. - * - * @return 0 in case of success, negative error code otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_advanced_subscriber_declare_background_sample_miss_listener(const struct ze_loaned_advanced_subscriber_t *subscriber, - struct ze_moved_closure_miss_t *callback); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs sample miss listener, registering a callback for notifying subscriber about missed samples. - * - * @param subscriber: A subscriber to associate with sample miss listener. - * @param sample_miss_listener: An uninitialized memory location where sample miss listener will be constructed. The sample miss listener's callback will be automatically dropped when the subscriber is dropped. - * @param callback: A closure that will be called every time the sample miss is detected. - * - * @return 0 in case of success, negative error code otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_advanced_subscriber_declare_sample_miss_listener(const struct ze_loaned_advanced_subscriber_t *subscriber, - struct ze_owned_sample_miss_listener_t *sample_miss_listener, - struct ze_moved_closure_miss_t *callback); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Declares a liveliness token listener for matching publishers detection. Only advanced publishers, enabling publisher detection can be detected. - * - * @param subscriber: The advanced subscriber instance. - * @param liveliness_subscriber: An uninitialized memory location where liveliness subscriber will be constructed. - * @param callback: The callback function that will be called each time a liveliness token status is changed. - * @param options: The options to be passed to the liveliness subscriber declaration. - * - * @return 0 in case of success, negative error values otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_advanced_subscriber_detect_publishers(const struct ze_loaned_advanced_subscriber_t *subscriber, - struct z_owned_subscriber_t *liveliness_subscriber, - struct z_moved_closure_sample_t *callback, - struct z_liveliness_subscriber_options_t *options); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Declares a background subscriber on liveliness tokens of matching publishers. Subscriber callback will be called to process the messages, - * until the corresponding session is closed or dropped. Only advanced publishers. enabling publisher detection can be detected. - * @param subscriber: The advanced subscriber instance. - * @param callback: The callback function that will be called each time a liveliness token status is changed. - * @param options: The options to be passed to the liveliness subscriber declaration. - * - * @return 0 in case of success, negative error values otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_advanced_subscriber_detect_publishers_background(const struct ze_loaned_advanced_subscriber_t *subscriber, - struct z_moved_closure_sample_t *callback, - struct z_liveliness_subscriber_options_t *options); -#endif -/** - * Undeclares advanced subscriber callback and resets it to its gravestone state. - * This is equivalent to calling `ze_undeclare_advanced_subscriber()` and discarding its return value. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_advanced_subscriber_drop(struct ze_moved_advanced_subscriber_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs the default value for `ze_advanced_subscriber_history_options_t`. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_advanced_subscriber_history_options_default(struct ze_advanced_subscriber_history_options_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns the ID of the advanced subscriber. - */ -#if (defined(Z_FEATURE_UNSTABLE_API) && defined(Z_FEATURE_UNSTABLE_API)) -ZENOHC_API -struct z_entity_global_id_t ze_advanced_subscriber_id(const struct ze_loaned_advanced_subscriber_t *subscriber); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Returns the key expression of the advanced subscriber. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -const struct z_loaned_keyexpr_t *ze_advanced_subscriber_keyexpr(const struct ze_loaned_advanced_subscriber_t *subscriber); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs the default value for `ze_advanced_subscriber_last_sample_miss_detection_options_t`. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_advanced_subscriber_last_sample_miss_detection_options_default(struct ze_advanced_subscriber_last_sample_miss_detection_options_t *this_); -#endif -/** - * Borrows subscriber. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -const struct ze_loaned_advanced_subscriber_t *ze_advanced_subscriber_loan(const struct ze_owned_advanced_subscriber_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs the default value for `ze_advanced_subscriber_options_t`. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_advanced_subscriber_options_default(struct ze_advanced_subscriber_options_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs the default value for `ze_advanced_subscriber_recovery_options_t`. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_advanced_subscriber_recovery_options_default(struct ze_advanced_subscriber_recovery_options_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * - * Closures are not guaranteed not to be called concurrently. - * - * It is guaranteed that: - * - `call` will never be called once `drop` has started. - * - `drop` will only be called **once**, and **after every** `call` has ended. - * - The two previous guarantees imply that `call` and `drop` are never called concurrently. - * - * @brief Constructs closure. - * @param this_: uninitialized memory location where new closure will be constructed. - * @param call: a closure body. - * @param drop: an optional function to be called once on closure drop. - * @param context: closure context. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_closure_miss(struct ze_owned_closure_miss_t *this_, - void (*call)(const struct ze_miss_t *matching_status, void *context), - void (*drop)(void *context), - void *context); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Calls the closure. Calling an uninitialized closure is a no-op. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_closure_miss_call(const struct ze_loaned_closure_miss_t *closure, - const struct ze_miss_t *mathing_status); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Drops the closure, resetting it to its gravestone state. Droping an uninitialized closure is a no-op. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_closure_miss_drop(struct ze_moved_closure_miss_t *closure_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Borrows closure. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -const struct ze_loaned_closure_miss_t *ze_closure_miss_loan(const struct ze_owned_closure_miss_t *closure); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Constructs and declares an advanced publisher for the given key expression. - * - * Data can be put and deleted with this publisher with the help of the - * `ze_advanced_publisher_put()` and `ze_advanced_publisher_delete()` functions. - * - * @param session: The Zenoh session. - * @param publisher: An uninitialized location in memory where advanced publisher will be constructed. - * @param key_expr: The key expression to publish to. - * @param options: Additional options for the advanced publisher. - * - * @return 0 in case of success, negative error code otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_declare_advanced_publisher(const struct z_loaned_session_t *session, - struct ze_owned_advanced_publisher_t *publisher, - const struct z_loaned_keyexpr_t *key_expr, - struct ze_advanced_publisher_options_t *options); -#endif -/** - * Constructs and declares an advanced subscriber for a given key expression. Dropping subscriber undeclares its callback. - * - * @param session: The zenoh session. - * @param subscriber: An uninitialized location in memory, where advanced subscriber will be constructed. - * @param key_expr: The key expression to subscribe. - * @param callback: The callback function that will be called each time a data matching the subscribed expression is received. - * @param options: The options to be passed to the subscriber declaration. - * - * @return 0 in case of success, negative error code otherwise (in this case subscriber will be in its gravestone state). - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_declare_advanced_subscriber(const struct z_loaned_session_t *session, - struct ze_owned_advanced_subscriber_t *subscriber, - const struct z_loaned_keyexpr_t *key_expr, - struct z_moved_closure_sample_t *callback, - struct ze_advanced_subscriber_options_t *options); -#endif -/** - * Constructs and declares a background advanced subscriber. Subscriber callback will be called to process the messages, - * until the corresponding session is closed or dropped. - * - * @param session: The zenoh session. - * @param key_expr: The key expression to subscribe. - * @param callback: The callback function that will be called each time a data matching the subscribed expression is received. - * @param options: The options to be passed to the subscriber declaration. - * - * @return 0 in case of success, negative error code otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_declare_background_advanced_subscriber(const struct z_loaned_session_t *session, - const struct z_loaned_keyexpr_t *key_expr, - struct z_moved_closure_sample_t *callback, - struct ze_advanced_subscriber_options_t *options); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_publisher. - * @brief Declares a background publication cache. It will function in background until the corresponding session is closed or dropped. - * - * @param session: A Zenoh session. - * @param key_expr: The key expression to publish to. - * @param options: Additional options for the publication cache. - * - * @returns 0 in case of success, negative error code otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_declare_background_publication_cache(const struct z_loaned_session_t *session, - const struct z_loaned_keyexpr_t *key_expr, - struct ze_publication_cache_options_t *options); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_subscriber. - * @brief Declares a background querying subscriber for a given key expression. Subscriber callback will be called to process the messages, - * until the corresponding session is closed or dropped. - * - * @param session: A Zenoh session. - * @param key_expr: A key expression to subscribe to. - * @param callback: The callback function that will be called each time a data matching the subscribed expression is received. - * @param options: Additional options for the querying subscriber. - * - * @return 0 in case of success, negative error code otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_declare_background_querying_subscriber(const struct z_loaned_session_t *session, - const struct z_loaned_keyexpr_t *key_expr, - struct z_moved_closure_sample_t *callback, - struct ze_querying_subscriber_options_t *options); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_publisher. - * @brief Constructs and declares a publication cache. - * - * @param session: A Zenoh session. - * @param pub_cache: An uninitialized location in memory where publication cache will be constructed. - * @param key_expr: The key expression to publish to. - * @param options: Additional options for the publication cache. - * - * @returns 0 in case of success, negative error code otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_declare_publication_cache(const struct z_loaned_session_t *session, - struct ze_owned_publication_cache_t *pub_cache, - const struct z_loaned_keyexpr_t *key_expr, - struct ze_publication_cache_options_t *options); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_subscriber. - * @brief Constructs and declares a querying subscriber for a given key expression. - * - * @param session: A Zenoh session. - * @param querying_subscriber: An uninitialized memory location where querying subscriber will be constructed. - * @param key_expr: A key expression to subscribe to. - * @param callback: The callback function that will be called each time a data matching the subscribed expression is received. - * @param options: Additional options for the querying subscriber. - * - * @return 0 in case of success, negative error code otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_declare_querying_subscriber(const struct z_loaned_session_t *session, - struct ze_owned_querying_subscriber_t *querying_subscriber, - const struct z_loaned_keyexpr_t *key_expr, - struct z_moved_closure_sample_t *callback, - struct ze_querying_subscriber_options_t *options); -#endif /** * @brief Deserializes into a bool. * @return 0 in case of success, negative error code otherwise. @@ -6296,96 +4158,6 @@ struct ze_deserializer_t ze_deserializer_from_bytes(const struct z_loaned_bytes_ * @return `true` if there is no more data to parse, `false` otherwise. */ ZENOHC_API bool ze_deserializer_is_done(const struct ze_deserializer_t *this_); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Returns ``true`` if advanced publisher is valid, ``false`` otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool ze_internal_advanced_publisher_check(const struct ze_owned_advanced_publisher_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Constructs an advanced publisher in a gravestone state. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_internal_advanced_publisher_null(struct ze_owned_advanced_publisher_t *this_); -#endif -/** - * Returns ``true`` if advanced subscriber is valid, ``false`` otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool ze_internal_advanced_subscriber_check(const struct ze_owned_advanced_subscriber_t *this_); -#endif -/** - * Constructs a subscriber in a gravestone state. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API void ze_internal_advanced_subscriber_null(struct ze_owned_advanced_subscriber_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool ze_internal_closure_miss_check(const struct ze_owned_closure_miss_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs a null value of 'ze_owned_closure_miss_t' type - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_internal_closure_miss_null(struct ze_owned_closure_miss_t *this_); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_publisher. - * @brief Returns ``true`` if publication cache is valid, ``false`` otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool ze_internal_publication_cache_check(const struct ze_owned_publication_cache_t *this_); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_publisher. - * @brief Constructs a publication cache in a gravestone state. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API void ze_internal_publication_cache_null(struct ze_owned_publication_cache_t *this_); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_subscriber. - * @brief Returns ``true`` if querying subscriber is valid, ``false`` otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool ze_internal_querying_subscriber_check(const struct ze_owned_querying_subscriber_t *this_); -#endif -/** - * Constructs a querying subscriber in a gravestone state. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API void ze_internal_querying_subscriber_null(struct ze_owned_querying_subscriber_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Checks the sample_miss listener is for the gravestone state - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -bool ze_internal_sample_miss_listener_check(const struct ze_owned_sample_miss_listener_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Constructs an empty sample miss listener. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_internal_sample_miss_listener_null(struct ze_owned_sample_miss_listener_t *this_); -#endif /** * @brief Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. */ @@ -6394,82 +4166,6 @@ ZENOHC_API bool ze_internal_serializer_check(const struct ze_owned_serializer_t * @brief Constructs a serializer in a gravestone state. */ ZENOHC_API void ze_internal_serializer_null(struct ze_owned_serializer_t *this_); -/** - * @warning This API is deprecated. Please use ze_advanced_publisher. - * @brief Drops publication cache and resets it to its gravestone state. - * This is equivalent to calling `ze_undeclare_publication_cache()` and discarding its return value. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API void ze_publication_cache_drop(struct ze_moved_publication_cache_t *this_); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_publisher. - * @brief Returns the key expression of the publication cache. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -const struct z_loaned_keyexpr_t *ze_publication_cache_keyexpr(const struct ze_loaned_publication_cache_t *this_); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_publisher. - * @brief Borrows publication cache. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -const struct ze_loaned_publication_cache_t *ze_publication_cache_loan(const struct ze_owned_publication_cache_t *this_); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_publisher. - * @brief Constructs the default value for `ze_publication_cache_options_t`. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API void ze_publication_cache_options_default(struct ze_publication_cache_options_t *this_); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_subscriber. - * @brief Undeclares querying subscriber callback and resets it to its gravestone state. - * This is equivalent to calling `ze_undeclare_querying_subscriber()` and discarding its return value. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_querying_subscriber_drop(struct ze_moved_querying_subscriber_t *this_); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_subscriber. - * @brief Make querying subscriber perform an additional query on a specified selector. - * The queried samples will be merged with the received publications and made available in the subscriber callback. - * @return 0 in case of success, negative error code otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_querying_subscriber_get(const struct ze_loaned_querying_subscriber_t *this_, - const struct z_loaned_keyexpr_t *selector, - struct z_get_options_t *options); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_subscriber. - * @brief Borrows querying subscriber. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -const struct ze_loaned_querying_subscriber_t *ze_querying_subscriber_loan(const struct ze_owned_querying_subscriber_t *this_); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_subscriber. - * @brief Constructs the default value for `ze_querying_subscriber_options_t`. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_querying_subscriber_options_default(struct ze_querying_subscriber_options_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Undeclares the given sample miss listener, droping and invalidating it. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -void ze_sample_miss_listener_drop(struct ze_moved_sample_miss_listener_t *this_); -#endif /** * @brief Serializes a bool. */ @@ -6698,50 +4394,3 @@ z_result_t ze_serializer_serialize_uint64(struct ze_loaned_serializer_t *this_, ZENOHC_API z_result_t ze_serializer_serialize_uint8(struct ze_loaned_serializer_t *this_, uint8_t val); -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Undeclares the given advanced publisher. - * - * @return 0 in case of success, negative error code otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_undeclare_advanced_publisher(struct ze_moved_advanced_publisher_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * Undeclares the advanced subscriber. - * - * @return 0 in case of success, negative error code otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_undeclare_advanced_subscriber(struct ze_moved_advanced_subscriber_t *this_); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_publisher. - * @brief Undeclares publication cache. - * @return 0 in case of success, negative error code otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API z_result_t ze_undeclare_publication_cache(struct ze_moved_publication_cache_t *this_); -#endif -/** - * @warning This API is deprecated. Please use ze_advanced_subscriber. - * @brief Undeclares the given querying subscriber. - * - * @return 0 in case of success, negative error code otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_undeclare_querying_subscriber(struct ze_moved_querying_subscriber_t *this_); -#endif -/** - * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - * @brief Undeclares the given sample miss listener, droping and invalidating it. - * @return 0 in case of success, negative error code otherwise. - */ -#if defined(Z_FEATURE_UNSTABLE_API) -ZENOHC_API -z_result_t ze_undeclare_sample_miss_listener(struct ze_moved_sample_miss_listener_t *this_); -#endif diff --git a/include/zenoh_concrete.h b/include/zenoh_concrete.h index bd75a5ca7..7f953ddf7 100644 --- a/include/zenoh_concrete.h +++ b/include/zenoh_concrete.h @@ -22,20 +22,23 @@ #include #include #define DEFAULT_SCOUTING_TIMEOUT 1000 +#define Z_CLIENT 4 +#define Z_ROUTER 1 +#define Z_PEER 2 +#define Z_EPOISON_MUTEX -22 +#define Z_ESESSION_CLOSED -8 #define Z_CHANNEL_DISCONNECTED 1 +#define Z_EDESERIALIZE -7 +#define Z_EUTF8 -9 +#define Z_EBUSY_MUTEX -16 #define Z_CHANNEL_NODATA 2 +#define Z_EGENERIC INT8_MIN +#define Z_EAGAIN_MUTEX -11 #define Z_OK 0 -#define Z_EINVAL -1 -#define Z_EPARSE -2 -#define Z_EIO -3 #define Z_ENETWORK -4 #define Z_ENULL -5 -#define Z_EUNAVAILABLE -6 -#define Z_EDESERIALIZE -7 -#define Z_ESESSION_CLOSED -8 -#define Z_EUTF8 -9 -#define Z_EBUSY_MUTEX -16 #define Z_EINVAL_MUTEX -22 -#define Z_EAGAIN_MUTEX -11 -#define Z_EPOISON_MUTEX -22 -#define Z_EGENERIC INT8_MIN +#define Z_EUNAVAILABLE -6 +#define Z_EIO -3 +#define Z_EPARSE -2 +#define Z_EINVAL -1 diff --git a/include/zenoh_macros.h b/include/zenoh_macros.h index 9dbd1d7cf..13005660b 100644 --- a/include/zenoh_macros.h +++ b/include/zenoh_macros.h @@ -4,10 +4,8 @@ #ifndef __cplusplus -static inline z_moved_alloc_layout_t* z_alloc_layout_move(z_owned_alloc_layout_t* x) { return (z_moved_alloc_layout_t*)(x); } static inline z_moved_bytes_t* z_bytes_move(z_owned_bytes_t* x) { return (z_moved_bytes_t*)(x); } static inline z_moved_bytes_writer_t* z_bytes_writer_move(z_owned_bytes_writer_t* x) { return (z_moved_bytes_writer_t*)(x); } -static inline z_moved_chunk_alloc_result_t* z_chunk_alloc_result_move(z_owned_chunk_alloc_result_t* x) { return (z_moved_chunk_alloc_result_t*)(x); } static inline z_moved_closure_hello_t* z_closure_hello_move(z_owned_closure_hello_t* x) { return (z_moved_closure_hello_t*)(x); } static inline z_moved_closure_matching_status_t* z_closure_matching_status_move(z_owned_closure_matching_status_t* x) { return (z_moved_closure_matching_status_t*)(x); } static inline z_moved_closure_query_t* z_closure_query_move(z_owned_closure_query_t* x) { return (z_moved_closure_query_t*)(x); } @@ -24,9 +22,7 @@ static inline z_moved_hello_t* z_hello_move(z_owned_hello_t* x) { return (z_move static inline z_moved_keyexpr_t* z_keyexpr_move(z_owned_keyexpr_t* x) { return (z_moved_keyexpr_t*)(x); } static inline z_moved_liveliness_token_t* z_liveliness_token_move(z_owned_liveliness_token_t* x) { return (z_moved_liveliness_token_t*)(x); } static inline z_moved_matching_listener_t* z_matching_listener_move(z_owned_matching_listener_t* x) { return (z_moved_matching_listener_t*)(x); } -static inline z_moved_memory_layout_t* z_memory_layout_move(z_owned_memory_layout_t* x) { return (z_moved_memory_layout_t*)(x); } static inline z_moved_mutex_t* z_mutex_move(z_owned_mutex_t* x) { return (z_moved_mutex_t*)(x); } -static inline z_moved_ptr_in_segment_t* z_ptr_in_segment_move(z_owned_ptr_in_segment_t* x) { return (z_moved_ptr_in_segment_t*)(x); } static inline z_moved_publisher_t* z_publisher_move(z_owned_publisher_t* x) { return (z_moved_publisher_t*)(x); } static inline z_moved_querier_t* z_querier_move(z_owned_querier_t* x) { return (z_moved_querier_t*)(x); } static inline z_moved_query_t* z_query_move(z_owned_query_t* x) { return (z_moved_query_t*)(x); } @@ -38,32 +34,17 @@ static inline z_moved_ring_handler_reply_t* z_ring_handler_reply_move(z_owned_ri static inline z_moved_ring_handler_sample_t* z_ring_handler_sample_move(z_owned_ring_handler_sample_t* x) { return (z_moved_ring_handler_sample_t*)(x); } static inline z_moved_sample_t* z_sample_move(z_owned_sample_t* x) { return (z_moved_sample_t*)(x); } static inline z_moved_session_t* z_session_move(z_owned_session_t* x) { return (z_moved_session_t*)(x); } -static inline z_moved_shm_client_t* z_shm_client_move(z_owned_shm_client_t* x) { return (z_moved_shm_client_t*)(x); } -static inline z_moved_shm_client_storage_t* z_shm_client_storage_move(z_owned_shm_client_storage_t* x) { return (z_moved_shm_client_storage_t*)(x); } -static inline z_moved_shm_t* z_shm_move(z_owned_shm_t* x) { return (z_moved_shm_t*)(x); } -static inline z_moved_shm_mut_t* z_shm_mut_move(z_owned_shm_mut_t* x) { return (z_moved_shm_mut_t*)(x); } -static inline z_moved_shm_provider_t* z_shm_provider_move(z_owned_shm_provider_t* x) { return (z_moved_shm_provider_t*)(x); } static inline z_moved_slice_t* z_slice_move(z_owned_slice_t* x) { return (z_moved_slice_t*)(x); } -static inline z_moved_source_info_t* z_source_info_move(z_owned_source_info_t* x) { return (z_moved_source_info_t*)(x); } static inline z_moved_string_array_t* z_string_array_move(z_owned_string_array_t* x) { return (z_moved_string_array_t*)(x); } static inline z_moved_string_t* z_string_move(z_owned_string_t* x) { return (z_moved_string_t*)(x); } static inline z_moved_subscriber_t* z_subscriber_move(z_owned_subscriber_t* x) { return (z_moved_subscriber_t*)(x); } static inline z_moved_task_t* z_task_move(z_owned_task_t* x) { return (z_moved_task_t*)(x); } static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t* x) { return (zc_moved_closure_log_t*)(x); } -static inline zc_moved_concurrent_close_handle_t* zc_concurrent_close_handle_move(zc_owned_concurrent_close_handle_t* x) { return (zc_moved_concurrent_close_handle_t*)(x); } -static inline zc_moved_shm_client_list_t* zc_shm_client_list_move(zc_owned_shm_client_list_t* x) { return (zc_moved_shm_client_list_t*)(x); } -static inline ze_moved_advanced_publisher_t* ze_advanced_publisher_move(ze_owned_advanced_publisher_t* x) { return (ze_moved_advanced_publisher_t*)(x); } -static inline ze_moved_advanced_subscriber_t* ze_advanced_subscriber_move(ze_owned_advanced_subscriber_t* x) { return (ze_moved_advanced_subscriber_t*)(x); } -static inline ze_moved_closure_miss_t* ze_closure_miss_move(ze_owned_closure_miss_t* x) { return (ze_moved_closure_miss_t*)(x); } -static inline ze_moved_publication_cache_t* ze_publication_cache_move(ze_owned_publication_cache_t* x) { return (ze_moved_publication_cache_t*)(x); } -static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_owned_querying_subscriber_t* x) { return (ze_moved_querying_subscriber_t*)(x); } -static inline ze_moved_sample_miss_listener_t* ze_sample_miss_listener_move(ze_owned_sample_miss_listener_t* x) { return (ze_moved_sample_miss_listener_t*)(x); } static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x) { return (ze_moved_serializer_t*)(x); } #define z_loan(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t : z_alloc_layout_loan, \ z_owned_bytes_t : z_bytes_loan, \ z_owned_bytes_writer_t : z_bytes_writer_loan, \ z_owned_closure_hello_t : z_closure_hello_loan, \ @@ -81,8 +62,6 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_hello_t : z_hello_loan, \ z_owned_keyexpr_t : z_keyexpr_loan, \ z_owned_liveliness_token_t : z_liveliness_token_loan, \ - z_owned_memory_layout_t : z_memory_layout_loan, \ - z_owned_ptr_in_segment_t : z_ptr_in_segment_loan, \ z_owned_publisher_t : z_publisher_loan, \ z_owned_querier_t : z_querier_loan, \ z_owned_query_t : z_query_loan, \ @@ -94,12 +73,7 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_ring_handler_sample_t : z_ring_handler_sample_loan, \ z_owned_sample_t : z_sample_loan, \ z_owned_session_t : z_session_loan, \ - z_owned_shm_client_storage_t : z_shm_client_storage_loan, \ - z_owned_shm_t : z_shm_loan, \ - z_owned_shm_mut_t : z_shm_mut_loan, \ - z_owned_shm_provider_t : z_shm_provider_loan, \ z_owned_slice_t : z_slice_loan, \ - z_owned_source_info_t : z_source_info_loan, \ z_owned_string_array_t : z_string_array_loan, \ z_owned_string_t : z_string_loan, \ z_owned_subscriber_t : z_subscriber_loan, \ @@ -107,12 +81,6 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_view_slice_t : z_view_slice_loan, \ z_view_string_t : z_view_string_loan, \ zc_owned_closure_log_t : zc_closure_log_loan, \ - zc_owned_shm_client_list_t : zc_shm_client_list_loan, \ - ze_owned_advanced_publisher_t : ze_advanced_publisher_loan, \ - ze_owned_advanced_subscriber_t : ze_advanced_subscriber_loan, \ - ze_owned_closure_miss_t : ze_closure_miss_loan, \ - ze_owned_publication_cache_t : ze_publication_cache_loan, \ - ze_owned_querying_subscriber_t : ze_querying_subscriber_loan, \ ze_owned_serializer_t : ze_serializer_loan \ )(&this_) @@ -136,20 +104,14 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_reply_t : z_reply_loan_mut, \ z_owned_sample_t : z_sample_loan_mut, \ z_owned_session_t : z_session_loan_mut, \ - z_owned_shm_t : z_shm_loan_mut, \ - z_owned_shm_mut_t : z_shm_mut_loan_mut, \ z_owned_string_array_t : z_string_array_loan_mut, \ - zc_owned_shm_client_list_t : zc_shm_client_list_loan_mut, \ - ze_owned_advanced_publisher_t : ze_advanced_publisher_loan_mut, \ ze_owned_serializer_t : ze_serializer_loan_mut \ )(&this_) #define z_drop(this_) \ _Generic((this_), \ - z_moved_alloc_layout_t* : z_alloc_layout_drop, \ z_moved_bytes_t* : z_bytes_drop, \ z_moved_bytes_writer_t* : z_bytes_writer_drop, \ - z_moved_chunk_alloc_result_t* : z_chunk_alloc_result_drop, \ z_moved_closure_hello_t* : z_closure_hello_drop, \ z_moved_closure_matching_status_t* : z_closure_matching_status_drop, \ z_moved_closure_query_t* : z_closure_query_drop, \ @@ -166,9 +128,7 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_moved_keyexpr_t* : z_keyexpr_drop, \ z_moved_liveliness_token_t* : z_liveliness_token_drop, \ z_moved_matching_listener_t* : z_matching_listener_drop, \ - z_moved_memory_layout_t* : z_memory_layout_drop, \ z_moved_mutex_t* : z_mutex_drop, \ - z_moved_ptr_in_segment_t* : z_ptr_in_segment_drop, \ z_moved_publisher_t* : z_publisher_drop, \ z_moved_querier_t* : z_querier_drop, \ z_moved_query_t* : z_query_drop, \ @@ -180,35 +140,19 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_moved_ring_handler_sample_t* : z_ring_handler_sample_drop, \ z_moved_sample_t* : z_sample_drop, \ z_moved_session_t* : z_session_drop, \ - z_moved_shm_client_t* : z_shm_client_drop, \ - z_moved_shm_client_storage_t* : z_shm_client_storage_drop, \ - z_moved_shm_t* : z_shm_drop, \ - z_moved_shm_mut_t* : z_shm_mut_drop, \ - z_moved_shm_provider_t* : z_shm_provider_drop, \ z_moved_slice_t* : z_slice_drop, \ - z_moved_source_info_t* : z_source_info_drop, \ z_moved_string_array_t* : z_string_array_drop, \ z_moved_string_t* : z_string_drop, \ z_moved_subscriber_t* : z_subscriber_drop, \ z_moved_task_t* : z_task_drop, \ zc_moved_closure_log_t* : zc_closure_log_drop, \ - zc_moved_concurrent_close_handle_t* : zc_concurrent_close_handle_drop, \ - zc_moved_shm_client_list_t* : zc_shm_client_list_drop, \ - ze_moved_advanced_publisher_t* : ze_advanced_publisher_drop, \ - ze_moved_advanced_subscriber_t* : ze_advanced_subscriber_drop, \ - ze_moved_closure_miss_t* : ze_closure_miss_drop, \ - ze_moved_publication_cache_t* : ze_publication_cache_drop, \ - ze_moved_querying_subscriber_t* : ze_querying_subscriber_drop, \ - ze_moved_sample_miss_listener_t* : ze_sample_miss_listener_drop, \ ze_moved_serializer_t* : ze_serializer_drop \ )(this_) #define z_move(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t : z_alloc_layout_move, \ z_owned_bytes_t : z_bytes_move, \ z_owned_bytes_writer_t : z_bytes_writer_move, \ - z_owned_chunk_alloc_result_t : z_chunk_alloc_result_move, \ z_owned_closure_hello_t : z_closure_hello_move, \ z_owned_closure_matching_status_t : z_closure_matching_status_move, \ z_owned_closure_query_t : z_closure_query_move, \ @@ -225,9 +169,7 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_keyexpr_t : z_keyexpr_move, \ z_owned_liveliness_token_t : z_liveliness_token_move, \ z_owned_matching_listener_t : z_matching_listener_move, \ - z_owned_memory_layout_t : z_memory_layout_move, \ z_owned_mutex_t : z_mutex_move, \ - z_owned_ptr_in_segment_t : z_ptr_in_segment_move, \ z_owned_publisher_t : z_publisher_move, \ z_owned_querier_t : z_querier_move, \ z_owned_query_t : z_query_move, \ @@ -239,35 +181,19 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_ring_handler_sample_t : z_ring_handler_sample_move, \ z_owned_sample_t : z_sample_move, \ z_owned_session_t : z_session_move, \ - z_owned_shm_client_t : z_shm_client_move, \ - z_owned_shm_client_storage_t : z_shm_client_storage_move, \ - z_owned_shm_t : z_shm_move, \ - z_owned_shm_mut_t : z_shm_mut_move, \ - z_owned_shm_provider_t : z_shm_provider_move, \ z_owned_slice_t : z_slice_move, \ - z_owned_source_info_t : z_source_info_move, \ z_owned_string_array_t : z_string_array_move, \ z_owned_string_t : z_string_move, \ z_owned_subscriber_t : z_subscriber_move, \ z_owned_task_t : z_task_move, \ zc_owned_closure_log_t : zc_closure_log_move, \ - zc_owned_concurrent_close_handle_t : zc_concurrent_close_handle_move, \ - zc_owned_shm_client_list_t : zc_shm_client_list_move, \ - ze_owned_advanced_publisher_t : ze_advanced_publisher_move, \ - ze_owned_advanced_subscriber_t : ze_advanced_subscriber_move, \ - ze_owned_closure_miss_t : ze_closure_miss_move, \ - ze_owned_publication_cache_t : ze_publication_cache_move, \ - ze_owned_querying_subscriber_t : ze_querying_subscriber_move, \ - ze_owned_sample_miss_listener_t : ze_sample_miss_listener_move, \ ze_owned_serializer_t : ze_serializer_move \ )(&this_) #define z_internal_null(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t* : z_internal_alloc_layout_null, \ z_owned_bytes_t* : z_internal_bytes_null, \ z_owned_bytes_writer_t* : z_internal_bytes_writer_null, \ - z_owned_chunk_alloc_result_t* : z_internal_chunk_alloc_result_null, \ z_owned_closure_hello_t* : z_internal_closure_hello_null, \ z_owned_closure_matching_status_t* : z_internal_closure_matching_status_null, \ z_owned_closure_query_t* : z_internal_closure_query_null, \ @@ -284,9 +210,7 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_keyexpr_t* : z_internal_keyexpr_null, \ z_owned_liveliness_token_t* : z_internal_liveliness_token_null, \ z_owned_matching_listener_t* : z_internal_matching_listener_null, \ - z_owned_memory_layout_t* : z_internal_memory_layout_null, \ z_owned_mutex_t* : z_internal_mutex_null, \ - z_owned_ptr_in_segment_t* : z_internal_ptr_in_segment_null, \ z_owned_publisher_t* : z_internal_publisher_null, \ z_owned_querier_t* : z_internal_querier_null, \ z_owned_query_t* : z_internal_query_null, \ @@ -298,33 +222,17 @@ static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x z_owned_ring_handler_sample_t* : z_internal_ring_handler_sample_null, \ z_owned_sample_t* : z_internal_sample_null, \ z_owned_session_t* : z_internal_session_null, \ - z_owned_shm_client_t* : z_internal_shm_client_null, \ - z_owned_shm_client_storage_t* : z_internal_shm_client_storage_null, \ - z_owned_shm_mut_t* : z_internal_shm_mut_null, \ - z_owned_shm_t* : z_internal_shm_null, \ - z_owned_shm_provider_t* : z_internal_shm_provider_null, \ z_owned_slice_t* : z_internal_slice_null, \ - z_owned_source_info_t* : z_internal_source_info_null, \ z_owned_string_array_t* : z_internal_string_array_null, \ z_owned_string_t* : z_internal_string_null, \ z_owned_subscriber_t* : z_internal_subscriber_null, \ z_owned_task_t* : z_internal_task_null, \ zc_owned_closure_log_t* : zc_internal_closure_log_null, \ - zc_owned_concurrent_close_handle_t* : zc_internal_concurrent_close_handle_null, \ - zc_owned_shm_client_list_t* : zc_internal_shm_client_list_null, \ - ze_owned_advanced_publisher_t* : ze_internal_advanced_publisher_null, \ - ze_owned_advanced_subscriber_t* : ze_internal_advanced_subscriber_null, \ - ze_owned_closure_miss_t* : ze_internal_closure_miss_null, \ - ze_owned_publication_cache_t* : ze_internal_publication_cache_null, \ - ze_owned_querying_subscriber_t* : ze_internal_querying_subscriber_null, \ - ze_owned_sample_miss_listener_t* : ze_internal_sample_miss_listener_null, \ ze_owned_serializer_t* : ze_internal_serializer_null \ )(this_) -static inline void z_alloc_layout_take(z_owned_alloc_layout_t* this_, z_moved_alloc_layout_t* x) { *this_ = x->_this; z_internal_alloc_layout_null(&x->_this); } static inline void z_bytes_take(z_owned_bytes_t* this_, z_moved_bytes_t* x) { *this_ = x->_this; z_internal_bytes_null(&x->_this); } static inline void z_bytes_writer_take(z_owned_bytes_writer_t* this_, z_moved_bytes_writer_t* x) { *this_ = x->_this; z_internal_bytes_writer_null(&x->_this); } -static inline void z_chunk_alloc_result_take(z_owned_chunk_alloc_result_t* this_, z_moved_chunk_alloc_result_t* x) { *this_ = x->_this; z_internal_chunk_alloc_result_null(&x->_this); } static inline void z_closure_hello_take(z_owned_closure_hello_t* this_, z_moved_closure_hello_t* x) { *this_ = x->_this; z_internal_closure_hello_null(&x->_this); } static inline void z_closure_matching_status_take(z_owned_closure_matching_status_t* closure_, z_moved_closure_matching_status_t* x) { *closure_ = x->_this; z_internal_closure_matching_status_null(&x->_this); } static inline void z_closure_query_take(z_owned_closure_query_t* closure_, z_moved_closure_query_t* x) { *closure_ = x->_this; z_internal_closure_query_null(&x->_this); } @@ -341,9 +249,7 @@ static inline void z_hello_take(z_owned_hello_t* this_, z_moved_hello_t* x) { *t static inline void z_keyexpr_take(z_owned_keyexpr_t* this_, z_moved_keyexpr_t* x) { *this_ = x->_this; z_internal_keyexpr_null(&x->_this); } static inline void z_liveliness_token_take(z_owned_liveliness_token_t* this_, z_moved_liveliness_token_t* x) { *this_ = x->_this; z_internal_liveliness_token_null(&x->_this); } static inline void z_matching_listener_take(z_owned_matching_listener_t* this_, z_moved_matching_listener_t* x) { *this_ = x->_this; z_internal_matching_listener_null(&x->_this); } -static inline void z_memory_layout_take(z_owned_memory_layout_t* this_, z_moved_memory_layout_t* x) { *this_ = x->_this; z_internal_memory_layout_null(&x->_this); } static inline void z_mutex_take(z_owned_mutex_t* this_, z_moved_mutex_t* x) { *this_ = x->_this; z_internal_mutex_null(&x->_this); } -static inline void z_ptr_in_segment_take(z_owned_ptr_in_segment_t* this_, z_moved_ptr_in_segment_t* x) { *this_ = x->_this; z_internal_ptr_in_segment_null(&x->_this); } static inline void z_publisher_take(z_owned_publisher_t* this_, z_moved_publisher_t* x) { *this_ = x->_this; z_internal_publisher_null(&x->_this); } static inline void z_querier_take(z_owned_querier_t* this_, z_moved_querier_t* x) { *this_ = x->_this; z_internal_querier_null(&x->_this); } static inline void z_query_take(z_owned_query_t* this_, z_moved_query_t* x) { *this_ = x->_this; z_internal_query_null(&x->_this); } @@ -355,35 +261,19 @@ static inline void z_ring_handler_reply_take(z_owned_ring_handler_reply_t* this_ static inline void z_ring_handler_sample_take(z_owned_ring_handler_sample_t* this_, z_moved_ring_handler_sample_t* x) { *this_ = x->_this; z_internal_ring_handler_sample_null(&x->_this); } static inline void z_sample_take(z_owned_sample_t* this_, z_moved_sample_t* x) { *this_ = x->_this; z_internal_sample_null(&x->_this); } static inline void z_session_take(z_owned_session_t* this_, z_moved_session_t* x) { *this_ = x->_this; z_internal_session_null(&x->_this); } -static inline void z_shm_client_take(z_owned_shm_client_t* this_, z_moved_shm_client_t* x) { *this_ = x->_this; z_internal_shm_client_null(&x->_this); } -static inline void z_shm_client_storage_take(z_owned_shm_client_storage_t* this_, z_moved_shm_client_storage_t* x) { *this_ = x->_this; z_internal_shm_client_storage_null(&x->_this); } -static inline void z_shm_take(z_owned_shm_t* this_, z_moved_shm_t* x) { *this_ = x->_this; z_internal_shm_null(&x->_this); } -static inline void z_shm_mut_take(z_owned_shm_mut_t* this_, z_moved_shm_mut_t* x) { *this_ = x->_this; z_internal_shm_mut_null(&x->_this); } -static inline void z_shm_provider_take(z_owned_shm_provider_t* this_, z_moved_shm_provider_t* x) { *this_ = x->_this; z_internal_shm_provider_null(&x->_this); } static inline void z_slice_take(z_owned_slice_t* this_, z_moved_slice_t* x) { *this_ = x->_this; z_internal_slice_null(&x->_this); } -static inline void z_source_info_take(z_owned_source_info_t* this_, z_moved_source_info_t* x) { *this_ = x->_this; z_internal_source_info_null(&x->_this); } static inline void z_string_array_take(z_owned_string_array_t* this_, z_moved_string_array_t* x) { *this_ = x->_this; z_internal_string_array_null(&x->_this); } static inline void z_string_take(z_owned_string_t* this_, z_moved_string_t* x) { *this_ = x->_this; z_internal_string_null(&x->_this); } static inline void z_subscriber_take(z_owned_subscriber_t* this_, z_moved_subscriber_t* x) { *this_ = x->_this; z_internal_subscriber_null(&x->_this); } static inline void z_task_take(z_owned_task_t* this_, z_moved_task_t* x) { *this_ = x->_this; z_internal_task_null(&x->_this); } static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) { *closure_ = x->_this; zc_internal_closure_log_null(&x->_this); } -static inline void zc_concurrent_close_handle_take(zc_owned_concurrent_close_handle_t* this_, zc_moved_concurrent_close_handle_t* x) { *this_ = x->_this; zc_internal_concurrent_close_handle_null(&x->_this); } -static inline void zc_shm_client_list_take(zc_owned_shm_client_list_t* this_, zc_moved_shm_client_list_t* x) { *this_ = x->_this; zc_internal_shm_client_list_null(&x->_this); } -static inline void ze_advanced_publisher_take(ze_owned_advanced_publisher_t* this_, ze_moved_advanced_publisher_t* x) { *this_ = x->_this; ze_internal_advanced_publisher_null(&x->_this); } -static inline void ze_advanced_subscriber_take(ze_owned_advanced_subscriber_t* this_, ze_moved_advanced_subscriber_t* x) { *this_ = x->_this; ze_internal_advanced_subscriber_null(&x->_this); } -static inline void ze_closure_miss_take(ze_owned_closure_miss_t* closure_, ze_moved_closure_miss_t* x) { *closure_ = x->_this; ze_internal_closure_miss_null(&x->_this); } -static inline void ze_publication_cache_take(ze_owned_publication_cache_t* this_, ze_moved_publication_cache_t* x) { *this_ = x->_this; ze_internal_publication_cache_null(&x->_this); } -static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* this_, ze_moved_querying_subscriber_t* x) { *this_ = x->_this; ze_internal_querying_subscriber_null(&x->_this); } -static inline void ze_sample_miss_listener_take(ze_owned_sample_miss_listener_t* this_, ze_moved_sample_miss_listener_t* x) { *this_ = x->_this; ze_internal_sample_miss_listener_null(&x->_this); } static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_serializer_t* x) { *this_ = x->_this; ze_internal_serializer_null(&x->_this); } #define z_take(this_, x) \ _Generic((this_), \ - z_owned_alloc_layout_t* : z_alloc_layout_take, \ z_owned_bytes_t* : z_bytes_take, \ z_owned_bytes_writer_t* : z_bytes_writer_take, \ - z_owned_chunk_alloc_result_t* : z_chunk_alloc_result_take, \ z_owned_closure_hello_t* : z_closure_hello_take, \ z_owned_closure_matching_status_t* : z_closure_matching_status_take, \ z_owned_closure_query_t* : z_closure_query_take, \ @@ -400,9 +290,7 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser z_owned_keyexpr_t* : z_keyexpr_take, \ z_owned_liveliness_token_t* : z_liveliness_token_take, \ z_owned_matching_listener_t* : z_matching_listener_take, \ - z_owned_memory_layout_t* : z_memory_layout_take, \ z_owned_mutex_t* : z_mutex_take, \ - z_owned_ptr_in_segment_t* : z_ptr_in_segment_take, \ z_owned_publisher_t* : z_publisher_take, \ z_owned_querier_t* : z_querier_take, \ z_owned_query_t* : z_query_take, \ @@ -414,26 +302,12 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser z_owned_ring_handler_sample_t* : z_ring_handler_sample_take, \ z_owned_sample_t* : z_sample_take, \ z_owned_session_t* : z_session_take, \ - z_owned_shm_client_t* : z_shm_client_take, \ - z_owned_shm_client_storage_t* : z_shm_client_storage_take, \ - z_owned_shm_t* : z_shm_take, \ - z_owned_shm_mut_t* : z_shm_mut_take, \ - z_owned_shm_provider_t* : z_shm_provider_take, \ z_owned_slice_t* : z_slice_take, \ - z_owned_source_info_t* : z_source_info_take, \ z_owned_string_array_t* : z_string_array_take, \ z_owned_string_t* : z_string_take, \ z_owned_subscriber_t* : z_subscriber_take, \ z_owned_task_t* : z_task_take, \ zc_owned_closure_log_t* : zc_closure_log_take, \ - zc_owned_concurrent_close_handle_t* : zc_concurrent_close_handle_take, \ - zc_owned_shm_client_list_t* : zc_shm_client_list_take, \ - ze_owned_advanced_publisher_t* : ze_advanced_publisher_take, \ - ze_owned_advanced_subscriber_t* : ze_advanced_subscriber_take, \ - ze_owned_closure_miss_t* : ze_closure_miss_take, \ - ze_owned_publication_cache_t* : ze_publication_cache_take, \ - ze_owned_querying_subscriber_t* : ze_querying_subscriber_take, \ - ze_owned_sample_miss_listener_t* : ze_sample_miss_listener_take, \ ze_owned_serializer_t* : ze_serializer_take \ )(this_, x) @@ -447,10 +321,8 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser #define z_internal_check(this_) \ _Generic((this_), \ - z_owned_alloc_layout_t : z_internal_alloc_layout_check, \ z_owned_bytes_t : z_internal_bytes_check, \ z_owned_bytes_writer_t : z_internal_bytes_writer_check, \ - z_owned_chunk_alloc_result_t : z_internal_chunk_alloc_result_check, \ z_owned_closure_hello_t : z_internal_closure_hello_check, \ z_owned_closure_matching_status_t : z_internal_closure_matching_status_check, \ z_owned_closure_query_t : z_internal_closure_query_check, \ @@ -467,9 +339,7 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser z_owned_keyexpr_t : z_internal_keyexpr_check, \ z_owned_liveliness_token_t : z_internal_liveliness_token_check, \ z_owned_matching_listener_t : z_internal_matching_listener_check, \ - z_owned_memory_layout_t : z_internal_memory_layout_check, \ z_owned_mutex_t : z_internal_mutex_check, \ - z_owned_ptr_in_segment_t : z_internal_ptr_in_segment_check, \ z_owned_publisher_t : z_internal_publisher_check, \ z_owned_querier_t : z_internal_querier_check, \ z_owned_query_t : z_internal_query_check, \ @@ -481,26 +351,12 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser z_owned_ring_handler_sample_t : z_internal_ring_handler_sample_check, \ z_owned_sample_t : z_internal_sample_check, \ z_owned_session_t : z_internal_session_check, \ - z_owned_shm_t : z_internal_shm_check, \ - z_owned_shm_client_t : z_internal_shm_client_check, \ - z_owned_shm_client_storage_t : z_internal_shm_client_storage_check, \ - z_owned_shm_mut_t : z_internal_shm_mut_check, \ - z_owned_shm_provider_t : z_internal_shm_provider_check, \ z_owned_slice_t : z_internal_slice_check, \ - z_owned_source_info_t : z_internal_source_info_check, \ z_owned_string_array_t : z_internal_string_array_check, \ z_owned_string_t : z_internal_string_check, \ z_owned_subscriber_t : z_internal_subscriber_check, \ z_owned_task_t : z_internal_task_check, \ zc_owned_closure_log_t : zc_internal_closure_log_check, \ - zc_owned_concurrent_close_handle_t : zc_internal_concurrent_close_handle_check, \ - zc_owned_shm_client_list_t : zc_internal_shm_client_list_check, \ - ze_owned_advanced_publisher_t : ze_internal_advanced_publisher_check, \ - ze_owned_advanced_subscriber_t : ze_internal_advanced_subscriber_check, \ - ze_owned_closure_miss_t : ze_internal_closure_miss_check, \ - ze_owned_publication_cache_t : ze_internal_publication_cache_check, \ - ze_owned_querying_subscriber_t : ze_internal_querying_subscriber_check, \ - ze_owned_sample_miss_listener_t : ze_internal_sample_miss_listener_check, \ ze_owned_serializer_t : ze_internal_serializer_check \ )(&this_) @@ -511,8 +367,7 @@ static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_ser const z_loaned_closure_query_t* : z_closure_query_call, \ const z_loaned_closure_reply_t* : z_closure_reply_call, \ const z_loaned_closure_sample_t* : z_closure_sample_call, \ - const z_loaned_closure_zid_t* : z_closure_zid_call, \ - const ze_loaned_closure_miss_t* : ze_closure_miss_call \ + const z_loaned_closure_zid_t* : z_closure_zid_call \ )(closure, hello) typedef void(*z_closure_drop_callback_t)(void *context); @@ -523,7 +378,6 @@ typedef void(*z_closure_reply_callback_t)(z_loaned_reply_t *reply, void *context typedef void(*z_closure_sample_callback_t)(z_loaned_sample_t *sample, void *context); typedef void(*z_closure_zid_callback_t)(const z_id_t *z_id, void *context); typedef void(*zc_closure_log_callback_t)(zc_log_severity_t severity, const z_loaned_string_t *msg, void *context); -typedef void(*ze_closure_miss_callback_t)(const ze_miss_t *matching_status, void *context); #define z_closure(this_, call, drop, context) \ _Generic((this_), \ @@ -533,8 +387,7 @@ typedef void(*ze_closure_miss_callback_t)(const ze_miss_t *matching_status, void z_owned_closure_reply_t* : z_closure_reply, \ z_owned_closure_sample_t* : z_closure_sample, \ z_owned_closure_zid_t* : z_closure_zid, \ - zc_owned_closure_log_t* : zc_closure_log, \ - ze_owned_closure_miss_t* : ze_closure_miss \ + zc_owned_closure_log_t* : zc_closure_log \ )(this_, call, drop, context) #define z_try_recv(this_, query) \ @@ -564,13 +417,10 @@ typedef void(*ze_closure_miss_callback_t)(const ze_miss_t *matching_status, void z_owned_encoding_t* : z_encoding_clone, \ z_owned_hello_t* : z_hello_clone, \ z_owned_keyexpr_t* : z_keyexpr_clone, \ - z_owned_ptr_in_segment_t* : z_ptr_in_segment_clone, \ z_owned_query_t* : z_query_clone, \ z_owned_reply_t* : z_reply_clone, \ z_owned_reply_err_t* : z_reply_err_clone, \ z_owned_sample_t* : z_sample_clone, \ - z_owned_shm_client_storage_t* : z_shm_client_storage_clone, \ - z_owned_shm_t* : z_shm_clone, \ z_owned_slice_t* : z_slice_clone, \ z_owned_string_array_t* : z_string_array_clone, \ z_owned_string_t* : z_string_clone \ @@ -578,10 +428,8 @@ typedef void(*ze_closure_miss_callback_t)(const ze_miss_t *matching_status, void #else // #ifndef __cplusplus -static inline z_moved_alloc_layout_t* z_alloc_layout_move(z_owned_alloc_layout_t* x) { return reinterpret_cast(x); } static inline z_moved_bytes_t* z_bytes_move(z_owned_bytes_t* x) { return reinterpret_cast(x); } static inline z_moved_bytes_writer_t* z_bytes_writer_move(z_owned_bytes_writer_t* x) { return reinterpret_cast(x); } -static inline z_moved_chunk_alloc_result_t* z_chunk_alloc_result_move(z_owned_chunk_alloc_result_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_hello_t* z_closure_hello_move(z_owned_closure_hello_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_matching_status_t* z_closure_matching_status_move(z_owned_closure_matching_status_t* x) { return reinterpret_cast(x); } static inline z_moved_closure_query_t* z_closure_query_move(z_owned_closure_query_t* x) { return reinterpret_cast(x); } @@ -598,9 +446,7 @@ static inline z_moved_hello_t* z_hello_move(z_owned_hello_t* x) { return reinter static inline z_moved_keyexpr_t* z_keyexpr_move(z_owned_keyexpr_t* x) { return reinterpret_cast(x); } static inline z_moved_liveliness_token_t* z_liveliness_token_move(z_owned_liveliness_token_t* x) { return reinterpret_cast(x); } static inline z_moved_matching_listener_t* z_matching_listener_move(z_owned_matching_listener_t* x) { return reinterpret_cast(x); } -static inline z_moved_memory_layout_t* z_memory_layout_move(z_owned_memory_layout_t* x) { return reinterpret_cast(x); } static inline z_moved_mutex_t* z_mutex_move(z_owned_mutex_t* x) { return reinterpret_cast(x); } -static inline z_moved_ptr_in_segment_t* z_ptr_in_segment_move(z_owned_ptr_in_segment_t* x) { return reinterpret_cast(x); } static inline z_moved_publisher_t* z_publisher_move(z_owned_publisher_t* x) { return reinterpret_cast(x); } static inline z_moved_querier_t* z_querier_move(z_owned_querier_t* x) { return reinterpret_cast(x); } static inline z_moved_query_t* z_query_move(z_owned_query_t* x) { return reinterpret_cast(x); } @@ -612,31 +458,16 @@ static inline z_moved_ring_handler_reply_t* z_ring_handler_reply_move(z_owned_ri static inline z_moved_ring_handler_sample_t* z_ring_handler_sample_move(z_owned_ring_handler_sample_t* x) { return reinterpret_cast(x); } static inline z_moved_sample_t* z_sample_move(z_owned_sample_t* x) { return reinterpret_cast(x); } static inline z_moved_session_t* z_session_move(z_owned_session_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_client_t* z_shm_client_move(z_owned_shm_client_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_client_storage_t* z_shm_client_storage_move(z_owned_shm_client_storage_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_t* z_shm_move(z_owned_shm_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_mut_t* z_shm_mut_move(z_owned_shm_mut_t* x) { return reinterpret_cast(x); } -static inline z_moved_shm_provider_t* z_shm_provider_move(z_owned_shm_provider_t* x) { return reinterpret_cast(x); } static inline z_moved_slice_t* z_slice_move(z_owned_slice_t* x) { return reinterpret_cast(x); } -static inline z_moved_source_info_t* z_source_info_move(z_owned_source_info_t* x) { return reinterpret_cast(x); } static inline z_moved_string_array_t* z_string_array_move(z_owned_string_array_t* x) { return reinterpret_cast(x); } static inline z_moved_string_t* z_string_move(z_owned_string_t* x) { return reinterpret_cast(x); } static inline z_moved_subscriber_t* z_subscriber_move(z_owned_subscriber_t* x) { return reinterpret_cast(x); } static inline z_moved_task_t* z_task_move(z_owned_task_t* x) { return reinterpret_cast(x); } static inline zc_moved_closure_log_t* zc_closure_log_move(zc_owned_closure_log_t* x) { return reinterpret_cast(x); } -static inline zc_moved_concurrent_close_handle_t* zc_concurrent_close_handle_move(zc_owned_concurrent_close_handle_t* x) { return reinterpret_cast(x); } -static inline zc_moved_shm_client_list_t* zc_shm_client_list_move(zc_owned_shm_client_list_t* x) { return reinterpret_cast(x); } -static inline ze_moved_advanced_publisher_t* ze_advanced_publisher_move(ze_owned_advanced_publisher_t* x) { return reinterpret_cast(x); } -static inline ze_moved_advanced_subscriber_t* ze_advanced_subscriber_move(ze_owned_advanced_subscriber_t* x) { return reinterpret_cast(x); } -static inline ze_moved_closure_miss_t* ze_closure_miss_move(ze_owned_closure_miss_t* x) { return reinterpret_cast(x); } -static inline ze_moved_publication_cache_t* ze_publication_cache_move(ze_owned_publication_cache_t* x) { return reinterpret_cast(x); } -static inline ze_moved_querying_subscriber_t* ze_querying_subscriber_move(ze_owned_querying_subscriber_t* x) { return reinterpret_cast(x); } -static inline ze_moved_sample_miss_listener_t* ze_sample_miss_listener_move(ze_owned_sample_miss_listener_t* x) { return reinterpret_cast(x); } static inline ze_moved_serializer_t* ze_serializer_move(ze_owned_serializer_t* x) { return reinterpret_cast(x); } -inline const z_loaned_alloc_layout_t* z_loan(const z_owned_alloc_layout_t& this_) { return z_alloc_layout_loan(&this_); }; inline const z_loaned_bytes_t* z_loan(const z_owned_bytes_t& this_) { return z_bytes_loan(&this_); }; inline const z_loaned_bytes_writer_t* z_loan(const z_owned_bytes_writer_t& this_) { return z_bytes_writer_loan(&this_); }; inline const z_loaned_closure_hello_t* z_loan(const z_owned_closure_hello_t& closure) { return z_closure_hello_loan(&closure); }; @@ -654,8 +485,6 @@ inline const z_loaned_fifo_handler_sample_t* z_loan(const z_owned_fifo_handler_s inline const z_loaned_hello_t* z_loan(const z_owned_hello_t& this_) { return z_hello_loan(&this_); }; inline const z_loaned_keyexpr_t* z_loan(const z_owned_keyexpr_t& this_) { return z_keyexpr_loan(&this_); }; inline const z_loaned_liveliness_token_t* z_loan(const z_owned_liveliness_token_t& this_) { return z_liveliness_token_loan(&this_); }; -inline const z_loaned_memory_layout_t* z_loan(const z_owned_memory_layout_t& this_) { return z_memory_layout_loan(&this_); }; -inline const z_loaned_ptr_in_segment_t* z_loan(const z_owned_ptr_in_segment_t& this_) { return z_ptr_in_segment_loan(&this_); }; inline const z_loaned_publisher_t* z_loan(const z_owned_publisher_t& this_) { return z_publisher_loan(&this_); }; inline const z_loaned_querier_t* z_loan(const z_owned_querier_t& this_) { return z_querier_loan(&this_); }; inline const z_loaned_query_t* z_loan(const z_owned_query_t& this_) { return z_query_loan(&this_); }; @@ -667,12 +496,7 @@ inline const z_loaned_ring_handler_reply_t* z_loan(const z_owned_ring_handler_re inline const z_loaned_ring_handler_sample_t* z_loan(const z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_loan(&this_); }; inline const z_loaned_sample_t* z_loan(const z_owned_sample_t& this_) { return z_sample_loan(&this_); }; inline const z_loaned_session_t* z_loan(const z_owned_session_t& this_) { return z_session_loan(&this_); }; -inline const z_loaned_shm_client_storage_t* z_loan(const z_owned_shm_client_storage_t& this_) { return z_shm_client_storage_loan(&this_); }; -inline const z_loaned_shm_t* z_loan(const z_owned_shm_t& this_) { return z_shm_loan(&this_); }; -inline const z_loaned_shm_mut_t* z_loan(const z_owned_shm_mut_t& this_) { return z_shm_mut_loan(&this_); }; -inline const z_loaned_shm_provider_t* z_loan(const z_owned_shm_provider_t& this_) { return z_shm_provider_loan(&this_); }; inline const z_loaned_slice_t* z_loan(const z_owned_slice_t& this_) { return z_slice_loan(&this_); }; -inline const z_loaned_source_info_t* z_loan(const z_owned_source_info_t& this_) { return z_source_info_loan(&this_); }; inline const z_loaned_string_array_t* z_loan(const z_owned_string_array_t& this_) { return z_string_array_loan(&this_); }; inline const z_loaned_string_t* z_loan(const z_owned_string_t& this_) { return z_string_loan(&this_); }; inline const z_loaned_subscriber_t* z_loan(const z_owned_subscriber_t& this_) { return z_subscriber_loan(&this_); }; @@ -680,12 +504,6 @@ inline const z_loaned_keyexpr_t* z_loan(const z_view_keyexpr_t& this_) { return inline const z_loaned_slice_t* z_loan(const z_view_slice_t& this_) { return z_view_slice_loan(&this_); }; inline const z_loaned_string_t* z_loan(const z_view_string_t& this_) { return z_view_string_loan(&this_); }; inline const zc_loaned_closure_log_t* z_loan(const zc_owned_closure_log_t& closure) { return zc_closure_log_loan(&closure); }; -inline const zc_loaned_shm_client_list_t* z_loan(const zc_owned_shm_client_list_t& this_) { return zc_shm_client_list_loan(&this_); }; -inline const ze_loaned_advanced_publisher_t* z_loan(const ze_owned_advanced_publisher_t& this_) { return ze_advanced_publisher_loan(&this_); }; -inline const ze_loaned_advanced_subscriber_t* z_loan(const ze_owned_advanced_subscriber_t& this_) { return ze_advanced_subscriber_loan(&this_); }; -inline const ze_loaned_closure_miss_t* z_loan(const ze_owned_closure_miss_t& closure) { return ze_closure_miss_loan(&closure); }; -inline const ze_loaned_publication_cache_t* z_loan(const ze_owned_publication_cache_t& this_) { return ze_publication_cache_loan(&this_); }; -inline const ze_loaned_querying_subscriber_t* z_loan(const ze_owned_querying_subscriber_t& this_) { return ze_querying_subscriber_loan(&this_); }; inline const ze_loaned_serializer_t* z_loan(const ze_owned_serializer_t& this_) { return ze_serializer_loan(&this_); }; @@ -707,18 +525,12 @@ inline z_loaned_reply_err_t* z_loan_mut(z_owned_reply_err_t& this_) { return z_r inline z_loaned_reply_t* z_loan_mut(z_owned_reply_t& this_) { return z_reply_loan_mut(&this_); }; inline z_loaned_sample_t* z_loan_mut(z_owned_sample_t& this_) { return z_sample_loan_mut(&this_); }; inline z_loaned_session_t* z_loan_mut(z_owned_session_t& this_) { return z_session_loan_mut(&this_); }; -inline z_loaned_shm_t* z_loan_mut(z_owned_shm_t& this_) { return z_shm_loan_mut(&this_); }; -inline z_loaned_shm_mut_t* z_loan_mut(z_owned_shm_mut_t& this_) { return z_shm_mut_loan_mut(&this_); }; inline z_loaned_string_array_t* z_loan_mut(z_owned_string_array_t& this_) { return z_string_array_loan_mut(&this_); }; -inline zc_loaned_shm_client_list_t* z_loan_mut(zc_owned_shm_client_list_t& this_) { return zc_shm_client_list_loan_mut(&this_); }; -inline ze_loaned_advanced_publisher_t* z_loan_mut(ze_owned_advanced_publisher_t& this_) { return ze_advanced_publisher_loan_mut(&this_); }; inline ze_loaned_serializer_t* z_loan_mut(ze_owned_serializer_t& this_) { return ze_serializer_loan_mut(&this_); }; -inline void z_drop(z_moved_alloc_layout_t* this_) { z_alloc_layout_drop(this_); }; inline void z_drop(z_moved_bytes_t* this_) { z_bytes_drop(this_); }; inline void z_drop(z_moved_bytes_writer_t* this_) { z_bytes_writer_drop(this_); }; -inline void z_drop(z_moved_chunk_alloc_result_t* this_) { z_chunk_alloc_result_drop(this_); }; inline void z_drop(z_moved_closure_hello_t* this_) { z_closure_hello_drop(this_); }; inline void z_drop(z_moved_closure_matching_status_t* closure_) { z_closure_matching_status_drop(closure_); }; inline void z_drop(z_moved_closure_query_t* closure_) { z_closure_query_drop(closure_); }; @@ -735,9 +547,7 @@ inline void z_drop(z_moved_hello_t* this_) { z_hello_drop(this_); }; inline void z_drop(z_moved_keyexpr_t* this_) { z_keyexpr_drop(this_); }; inline void z_drop(z_moved_liveliness_token_t* this_) { z_liveliness_token_drop(this_); }; inline void z_drop(z_moved_matching_listener_t* this_) { z_matching_listener_drop(this_); }; -inline void z_drop(z_moved_memory_layout_t* this_) { z_memory_layout_drop(this_); }; inline void z_drop(z_moved_mutex_t* this_) { z_mutex_drop(this_); }; -inline void z_drop(z_moved_ptr_in_segment_t* this_) { z_ptr_in_segment_drop(this_); }; inline void z_drop(z_moved_publisher_t* this_) { z_publisher_drop(this_); }; inline void z_drop(z_moved_querier_t* this_) { z_querier_drop(this_); }; inline void z_drop(z_moved_query_t* this_) { z_query_drop(this_); }; @@ -749,33 +559,17 @@ inline void z_drop(z_moved_ring_handler_reply_t* this_) { z_ring_handler_reply_d inline void z_drop(z_moved_ring_handler_sample_t* this_) { z_ring_handler_sample_drop(this_); }; inline void z_drop(z_moved_sample_t* this_) { z_sample_drop(this_); }; inline void z_drop(z_moved_session_t* this_) { z_session_drop(this_); }; -inline void z_drop(z_moved_shm_client_t* this_) { z_shm_client_drop(this_); }; -inline void z_drop(z_moved_shm_client_storage_t* this_) { z_shm_client_storage_drop(this_); }; -inline void z_drop(z_moved_shm_t* this_) { z_shm_drop(this_); }; -inline void z_drop(z_moved_shm_mut_t* this_) { z_shm_mut_drop(this_); }; -inline void z_drop(z_moved_shm_provider_t* this_) { z_shm_provider_drop(this_); }; inline void z_drop(z_moved_slice_t* this_) { z_slice_drop(this_); }; -inline void z_drop(z_moved_source_info_t* this_) { z_source_info_drop(this_); }; inline void z_drop(z_moved_string_array_t* this_) { z_string_array_drop(this_); }; inline void z_drop(z_moved_string_t* this_) { z_string_drop(this_); }; inline void z_drop(z_moved_subscriber_t* this_) { z_subscriber_drop(this_); }; inline void z_drop(z_moved_task_t* this_) { z_task_drop(this_); }; inline void z_drop(zc_moved_closure_log_t* closure_) { zc_closure_log_drop(closure_); }; -inline void z_drop(zc_moved_concurrent_close_handle_t* this_) { zc_concurrent_close_handle_drop(this_); }; -inline void z_drop(zc_moved_shm_client_list_t* this_) { zc_shm_client_list_drop(this_); }; -inline void z_drop(ze_moved_advanced_publisher_t* this_) { ze_advanced_publisher_drop(this_); }; -inline void z_drop(ze_moved_advanced_subscriber_t* this_) { ze_advanced_subscriber_drop(this_); }; -inline void z_drop(ze_moved_closure_miss_t* closure_) { ze_closure_miss_drop(closure_); }; -inline void z_drop(ze_moved_publication_cache_t* this_) { ze_publication_cache_drop(this_); }; -inline void z_drop(ze_moved_querying_subscriber_t* this_) { ze_querying_subscriber_drop(this_); }; -inline void z_drop(ze_moved_sample_miss_listener_t* this_) { ze_sample_miss_listener_drop(this_); }; inline void z_drop(ze_moved_serializer_t* this_) { ze_serializer_drop(this_); }; -inline z_moved_alloc_layout_t* z_move(z_owned_alloc_layout_t& this_) { return z_alloc_layout_move(&this_); }; inline z_moved_bytes_t* z_move(z_owned_bytes_t& this_) { return z_bytes_move(&this_); }; inline z_moved_bytes_writer_t* z_move(z_owned_bytes_writer_t& this_) { return z_bytes_writer_move(&this_); }; -inline z_moved_chunk_alloc_result_t* z_move(z_owned_chunk_alloc_result_t& this_) { return z_chunk_alloc_result_move(&this_); }; inline z_moved_closure_hello_t* z_move(z_owned_closure_hello_t& this_) { return z_closure_hello_move(&this_); }; inline z_moved_closure_matching_status_t* z_move(z_owned_closure_matching_status_t& closure_) { return z_closure_matching_status_move(&closure_); }; inline z_moved_closure_query_t* z_move(z_owned_closure_query_t& closure_) { return z_closure_query_move(&closure_); }; @@ -792,9 +586,7 @@ inline z_moved_hello_t* z_move(z_owned_hello_t& this_) { return z_hello_move(&th inline z_moved_keyexpr_t* z_move(z_owned_keyexpr_t& this_) { return z_keyexpr_move(&this_); }; inline z_moved_liveliness_token_t* z_move(z_owned_liveliness_token_t& this_) { return z_liveliness_token_move(&this_); }; inline z_moved_matching_listener_t* z_move(z_owned_matching_listener_t& this_) { return z_matching_listener_move(&this_); }; -inline z_moved_memory_layout_t* z_move(z_owned_memory_layout_t& this_) { return z_memory_layout_move(&this_); }; inline z_moved_mutex_t* z_move(z_owned_mutex_t& this_) { return z_mutex_move(&this_); }; -inline z_moved_ptr_in_segment_t* z_move(z_owned_ptr_in_segment_t& this_) { return z_ptr_in_segment_move(&this_); }; inline z_moved_publisher_t* z_move(z_owned_publisher_t& this_) { return z_publisher_move(&this_); }; inline z_moved_querier_t* z_move(z_owned_querier_t& this_) { return z_querier_move(&this_); }; inline z_moved_query_t* z_move(z_owned_query_t& this_) { return z_query_move(&this_); }; @@ -806,33 +598,17 @@ inline z_moved_ring_handler_reply_t* z_move(z_owned_ring_handler_reply_t& this_) inline z_moved_ring_handler_sample_t* z_move(z_owned_ring_handler_sample_t& this_) { return z_ring_handler_sample_move(&this_); }; inline z_moved_sample_t* z_move(z_owned_sample_t& this_) { return z_sample_move(&this_); }; inline z_moved_session_t* z_move(z_owned_session_t& this_) { return z_session_move(&this_); }; -inline z_moved_shm_client_t* z_move(z_owned_shm_client_t& this_) { return z_shm_client_move(&this_); }; -inline z_moved_shm_client_storage_t* z_move(z_owned_shm_client_storage_t& this_) { return z_shm_client_storage_move(&this_); }; -inline z_moved_shm_t* z_move(z_owned_shm_t& this_) { return z_shm_move(&this_); }; -inline z_moved_shm_mut_t* z_move(z_owned_shm_mut_t& this_) { return z_shm_mut_move(&this_); }; -inline z_moved_shm_provider_t* z_move(z_owned_shm_provider_t& this_) { return z_shm_provider_move(&this_); }; inline z_moved_slice_t* z_move(z_owned_slice_t& this_) { return z_slice_move(&this_); }; -inline z_moved_source_info_t* z_move(z_owned_source_info_t& this_) { return z_source_info_move(&this_); }; inline z_moved_string_array_t* z_move(z_owned_string_array_t& this_) { return z_string_array_move(&this_); }; inline z_moved_string_t* z_move(z_owned_string_t& this_) { return z_string_move(&this_); }; inline z_moved_subscriber_t* z_move(z_owned_subscriber_t& this_) { return z_subscriber_move(&this_); }; inline z_moved_task_t* z_move(z_owned_task_t& this_) { return z_task_move(&this_); }; inline zc_moved_closure_log_t* z_move(zc_owned_closure_log_t& closure_) { return zc_closure_log_move(&closure_); }; -inline zc_moved_concurrent_close_handle_t* z_move(zc_owned_concurrent_close_handle_t& this_) { return zc_concurrent_close_handle_move(&this_); }; -inline zc_moved_shm_client_list_t* z_move(zc_owned_shm_client_list_t& this_) { return zc_shm_client_list_move(&this_); }; -inline ze_moved_advanced_publisher_t* z_move(ze_owned_advanced_publisher_t& this_) { return ze_advanced_publisher_move(&this_); }; -inline ze_moved_advanced_subscriber_t* z_move(ze_owned_advanced_subscriber_t& this_) { return ze_advanced_subscriber_move(&this_); }; -inline ze_moved_closure_miss_t* z_move(ze_owned_closure_miss_t& closure_) { return ze_closure_miss_move(&closure_); }; -inline ze_moved_publication_cache_t* z_move(ze_owned_publication_cache_t& this_) { return ze_publication_cache_move(&this_); }; -inline ze_moved_querying_subscriber_t* z_move(ze_owned_querying_subscriber_t& this_) { return ze_querying_subscriber_move(&this_); }; -inline ze_moved_sample_miss_listener_t* z_move(ze_owned_sample_miss_listener_t& this_) { return ze_sample_miss_listener_move(&this_); }; inline ze_moved_serializer_t* z_move(ze_owned_serializer_t& this_) { return ze_serializer_move(&this_); }; -inline void z_internal_null(z_owned_alloc_layout_t* this_) { z_internal_alloc_layout_null(this_); }; inline void z_internal_null(z_owned_bytes_t* this_) { z_internal_bytes_null(this_); }; inline void z_internal_null(z_owned_bytes_writer_t* this_) { z_internal_bytes_writer_null(this_); }; -inline void z_internal_null(z_owned_chunk_alloc_result_t* this_) { z_internal_chunk_alloc_result_null(this_); }; inline void z_internal_null(z_owned_closure_hello_t* this_) { z_internal_closure_hello_null(this_); }; inline void z_internal_null(z_owned_closure_matching_status_t* this_) { z_internal_closure_matching_status_null(this_); }; inline void z_internal_null(z_owned_closure_query_t* this_) { z_internal_closure_query_null(this_); }; @@ -849,9 +625,7 @@ inline void z_internal_null(z_owned_hello_t* this_) { z_internal_hello_null(this inline void z_internal_null(z_owned_keyexpr_t* this_) { z_internal_keyexpr_null(this_); }; inline void z_internal_null(z_owned_liveliness_token_t* this_) { z_internal_liveliness_token_null(this_); }; inline void z_internal_null(z_owned_matching_listener_t* this_) { z_internal_matching_listener_null(this_); }; -inline void z_internal_null(z_owned_memory_layout_t* this_) { z_internal_memory_layout_null(this_); }; inline void z_internal_null(z_owned_mutex_t* this_) { z_internal_mutex_null(this_); }; -inline void z_internal_null(z_owned_ptr_in_segment_t* this_) { z_internal_ptr_in_segment_null(this_); }; inline void z_internal_null(z_owned_publisher_t* this_) { z_internal_publisher_null(this_); }; inline void z_internal_null(z_owned_querier_t* this_) { z_internal_querier_null(this_); }; inline void z_internal_null(z_owned_query_t* this_) { z_internal_query_null(this_); }; @@ -863,32 +637,16 @@ inline void z_internal_null(z_owned_ring_handler_reply_t* this_) { z_internal_ri inline void z_internal_null(z_owned_ring_handler_sample_t* this_) { z_internal_ring_handler_sample_null(this_); }; inline void z_internal_null(z_owned_sample_t* this_) { z_internal_sample_null(this_); }; inline void z_internal_null(z_owned_session_t* this_) { z_internal_session_null(this_); }; -inline void z_internal_null(z_owned_shm_client_t* this_) { z_internal_shm_client_null(this_); }; -inline void z_internal_null(z_owned_shm_client_storage_t* this_) { z_internal_shm_client_storage_null(this_); }; -inline void z_internal_null(z_owned_shm_mut_t* this_) { z_internal_shm_mut_null(this_); }; -inline void z_internal_null(z_owned_shm_t* this_) { z_internal_shm_null(this_); }; -inline void z_internal_null(z_owned_shm_provider_t* this_) { z_internal_shm_provider_null(this_); }; inline void z_internal_null(z_owned_slice_t* this_) { z_internal_slice_null(this_); }; -inline void z_internal_null(z_owned_source_info_t* this_) { z_internal_source_info_null(this_); }; inline void z_internal_null(z_owned_string_array_t* this_) { z_internal_string_array_null(this_); }; inline void z_internal_null(z_owned_string_t* this_) { z_internal_string_null(this_); }; inline void z_internal_null(z_owned_subscriber_t* this_) { z_internal_subscriber_null(this_); }; inline void z_internal_null(z_owned_task_t* this_) { z_internal_task_null(this_); }; inline void z_internal_null(zc_owned_closure_log_t* this_) { zc_internal_closure_log_null(this_); }; -inline void z_internal_null(zc_owned_concurrent_close_handle_t* this_) { zc_internal_concurrent_close_handle_null(this_); }; -inline void z_internal_null(zc_owned_shm_client_list_t* this_) { zc_internal_shm_client_list_null(this_); }; -inline void z_internal_null(ze_owned_advanced_publisher_t* this_) { ze_internal_advanced_publisher_null(this_); }; -inline void z_internal_null(ze_owned_advanced_subscriber_t* this_) { ze_internal_advanced_subscriber_null(this_); }; -inline void z_internal_null(ze_owned_closure_miss_t* this_) { ze_internal_closure_miss_null(this_); }; -inline void z_internal_null(ze_owned_publication_cache_t* this_) { ze_internal_publication_cache_null(this_); }; -inline void z_internal_null(ze_owned_querying_subscriber_t* this_) { ze_internal_querying_subscriber_null(this_); }; -inline void z_internal_null(ze_owned_sample_miss_listener_t* this_) { ze_internal_sample_miss_listener_null(this_); }; inline void z_internal_null(ze_owned_serializer_t* this_) { ze_internal_serializer_null(this_); }; -static inline void z_alloc_layout_take(z_owned_alloc_layout_t* this_, z_moved_alloc_layout_t* x) { *this_ = x->_this; z_internal_alloc_layout_null(&x->_this); } static inline void z_bytes_take(z_owned_bytes_t* this_, z_moved_bytes_t* x) { *this_ = x->_this; z_internal_bytes_null(&x->_this); } static inline void z_bytes_writer_take(z_owned_bytes_writer_t* this_, z_moved_bytes_writer_t* x) { *this_ = x->_this; z_internal_bytes_writer_null(&x->_this); } -static inline void z_chunk_alloc_result_take(z_owned_chunk_alloc_result_t* this_, z_moved_chunk_alloc_result_t* x) { *this_ = x->_this; z_internal_chunk_alloc_result_null(&x->_this); } static inline void z_closure_hello_take(z_owned_closure_hello_t* this_, z_moved_closure_hello_t* x) { *this_ = x->_this; z_internal_closure_hello_null(&x->_this); } static inline void z_closure_matching_status_take(z_owned_closure_matching_status_t* closure_, z_moved_closure_matching_status_t* x) { *closure_ = x->_this; z_internal_closure_matching_status_null(&x->_this); } static inline void z_closure_query_take(z_owned_closure_query_t* closure_, z_moved_closure_query_t* x) { *closure_ = x->_this; z_internal_closure_query_null(&x->_this); } @@ -905,9 +663,7 @@ static inline void z_hello_take(z_owned_hello_t* this_, z_moved_hello_t* x) { *t static inline void z_keyexpr_take(z_owned_keyexpr_t* this_, z_moved_keyexpr_t* x) { *this_ = x->_this; z_internal_keyexpr_null(&x->_this); } static inline void z_liveliness_token_take(z_owned_liveliness_token_t* this_, z_moved_liveliness_token_t* x) { *this_ = x->_this; z_internal_liveliness_token_null(&x->_this); } static inline void z_matching_listener_take(z_owned_matching_listener_t* this_, z_moved_matching_listener_t* x) { *this_ = x->_this; z_internal_matching_listener_null(&x->_this); } -static inline void z_memory_layout_take(z_owned_memory_layout_t* this_, z_moved_memory_layout_t* x) { *this_ = x->_this; z_internal_memory_layout_null(&x->_this); } static inline void z_mutex_take(z_owned_mutex_t* this_, z_moved_mutex_t* x) { *this_ = x->_this; z_internal_mutex_null(&x->_this); } -static inline void z_ptr_in_segment_take(z_owned_ptr_in_segment_t* this_, z_moved_ptr_in_segment_t* x) { *this_ = x->_this; z_internal_ptr_in_segment_null(&x->_this); } static inline void z_publisher_take(z_owned_publisher_t* this_, z_moved_publisher_t* x) { *this_ = x->_this; z_internal_publisher_null(&x->_this); } static inline void z_querier_take(z_owned_querier_t* this_, z_moved_querier_t* x) { *this_ = x->_this; z_internal_querier_null(&x->_this); } static inline void z_query_take(z_owned_query_t* this_, z_moved_query_t* x) { *this_ = x->_this; z_internal_query_null(&x->_this); } @@ -919,42 +675,22 @@ static inline void z_ring_handler_reply_take(z_owned_ring_handler_reply_t* this_ static inline void z_ring_handler_sample_take(z_owned_ring_handler_sample_t* this_, z_moved_ring_handler_sample_t* x) { *this_ = x->_this; z_internal_ring_handler_sample_null(&x->_this); } static inline void z_sample_take(z_owned_sample_t* this_, z_moved_sample_t* x) { *this_ = x->_this; z_internal_sample_null(&x->_this); } static inline void z_session_take(z_owned_session_t* this_, z_moved_session_t* x) { *this_ = x->_this; z_internal_session_null(&x->_this); } -static inline void z_shm_client_take(z_owned_shm_client_t* this_, z_moved_shm_client_t* x) { *this_ = x->_this; z_internal_shm_client_null(&x->_this); } -static inline void z_shm_client_storage_take(z_owned_shm_client_storage_t* this_, z_moved_shm_client_storage_t* x) { *this_ = x->_this; z_internal_shm_client_storage_null(&x->_this); } -static inline void z_shm_take(z_owned_shm_t* this_, z_moved_shm_t* x) { *this_ = x->_this; z_internal_shm_null(&x->_this); } -static inline void z_shm_mut_take(z_owned_shm_mut_t* this_, z_moved_shm_mut_t* x) { *this_ = x->_this; z_internal_shm_mut_null(&x->_this); } -static inline void z_shm_provider_take(z_owned_shm_provider_t* this_, z_moved_shm_provider_t* x) { *this_ = x->_this; z_internal_shm_provider_null(&x->_this); } static inline void z_slice_take(z_owned_slice_t* this_, z_moved_slice_t* x) { *this_ = x->_this; z_internal_slice_null(&x->_this); } -static inline void z_source_info_take(z_owned_source_info_t* this_, z_moved_source_info_t* x) { *this_ = x->_this; z_internal_source_info_null(&x->_this); } static inline void z_string_array_take(z_owned_string_array_t* this_, z_moved_string_array_t* x) { *this_ = x->_this; z_internal_string_array_null(&x->_this); } static inline void z_string_take(z_owned_string_t* this_, z_moved_string_t* x) { *this_ = x->_this; z_internal_string_null(&x->_this); } static inline void z_subscriber_take(z_owned_subscriber_t* this_, z_moved_subscriber_t* x) { *this_ = x->_this; z_internal_subscriber_null(&x->_this); } static inline void z_task_take(z_owned_task_t* this_, z_moved_task_t* x) { *this_ = x->_this; z_internal_task_null(&x->_this); } static inline void zc_closure_log_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) { *closure_ = x->_this; zc_internal_closure_log_null(&x->_this); } -static inline void zc_concurrent_close_handle_take(zc_owned_concurrent_close_handle_t* this_, zc_moved_concurrent_close_handle_t* x) { *this_ = x->_this; zc_internal_concurrent_close_handle_null(&x->_this); } -static inline void zc_shm_client_list_take(zc_owned_shm_client_list_t* this_, zc_moved_shm_client_list_t* x) { *this_ = x->_this; zc_internal_shm_client_list_null(&x->_this); } -static inline void ze_advanced_publisher_take(ze_owned_advanced_publisher_t* this_, ze_moved_advanced_publisher_t* x) { *this_ = x->_this; ze_internal_advanced_publisher_null(&x->_this); } -static inline void ze_advanced_subscriber_take(ze_owned_advanced_subscriber_t* this_, ze_moved_advanced_subscriber_t* x) { *this_ = x->_this; ze_internal_advanced_subscriber_null(&x->_this); } -static inline void ze_closure_miss_take(ze_owned_closure_miss_t* closure_, ze_moved_closure_miss_t* x) { *closure_ = x->_this; ze_internal_closure_miss_null(&x->_this); } -static inline void ze_publication_cache_take(ze_owned_publication_cache_t* this_, ze_moved_publication_cache_t* x) { *this_ = x->_this; ze_internal_publication_cache_null(&x->_this); } -static inline void ze_querying_subscriber_take(ze_owned_querying_subscriber_t* this_, ze_moved_querying_subscriber_t* x) { *this_ = x->_this; ze_internal_querying_subscriber_null(&x->_this); } -static inline void ze_sample_miss_listener_take(ze_owned_sample_miss_listener_t* this_, ze_moved_sample_miss_listener_t* x) { *this_ = x->_this; ze_internal_sample_miss_listener_null(&x->_this); } static inline void ze_serializer_take(ze_owned_serializer_t* this_, ze_moved_serializer_t* x) { *this_ = x->_this; ze_internal_serializer_null(&x->_this); } -inline void z_take(z_owned_alloc_layout_t* this_, z_moved_alloc_layout_t* x) { - z_alloc_layout_take(this_, x); -}; inline void z_take(z_owned_bytes_t* this_, z_moved_bytes_t* x) { z_bytes_take(this_, x); }; inline void z_take(z_owned_bytes_writer_t* this_, z_moved_bytes_writer_t* x) { z_bytes_writer_take(this_, x); }; -inline void z_take(z_owned_chunk_alloc_result_t* this_, z_moved_chunk_alloc_result_t* x) { - z_chunk_alloc_result_take(this_, x); -}; inline void z_take(z_owned_closure_hello_t* this_, z_moved_closure_hello_t* x) { z_closure_hello_take(this_, x); }; @@ -1003,15 +739,9 @@ inline void z_take(z_owned_liveliness_token_t* this_, z_moved_liveliness_token_t inline void z_take(z_owned_matching_listener_t* this_, z_moved_matching_listener_t* x) { z_matching_listener_take(this_, x); }; -inline void z_take(z_owned_memory_layout_t* this_, z_moved_memory_layout_t* x) { - z_memory_layout_take(this_, x); -}; inline void z_take(z_owned_mutex_t* this_, z_moved_mutex_t* x) { z_mutex_take(this_, x); }; -inline void z_take(z_owned_ptr_in_segment_t* this_, z_moved_ptr_in_segment_t* x) { - z_ptr_in_segment_take(this_, x); -}; inline void z_take(z_owned_publisher_t* this_, z_moved_publisher_t* x) { z_publisher_take(this_, x); }; @@ -1045,27 +775,9 @@ inline void z_take(z_owned_sample_t* this_, z_moved_sample_t* x) { inline void z_take(z_owned_session_t* this_, z_moved_session_t* x) { z_session_take(this_, x); }; -inline void z_take(z_owned_shm_client_t* this_, z_moved_shm_client_t* x) { - z_shm_client_take(this_, x); -}; -inline void z_take(z_owned_shm_client_storage_t* this_, z_moved_shm_client_storage_t* x) { - z_shm_client_storage_take(this_, x); -}; -inline void z_take(z_owned_shm_t* this_, z_moved_shm_t* x) { - z_shm_take(this_, x); -}; -inline void z_take(z_owned_shm_mut_t* this_, z_moved_shm_mut_t* x) { - z_shm_mut_take(this_, x); -}; -inline void z_take(z_owned_shm_provider_t* this_, z_moved_shm_provider_t* x) { - z_shm_provider_take(this_, x); -}; inline void z_take(z_owned_slice_t* this_, z_moved_slice_t* x) { z_slice_take(this_, x); }; -inline void z_take(z_owned_source_info_t* this_, z_moved_source_info_t* x) { - z_source_info_take(this_, x); -}; inline void z_take(z_owned_string_array_t* this_, z_moved_string_array_t* x) { z_string_array_take(this_, x); }; @@ -1081,30 +793,6 @@ inline void z_take(z_owned_task_t* this_, z_moved_task_t* x) { inline void z_take(zc_owned_closure_log_t* closure_, zc_moved_closure_log_t* x) { zc_closure_log_take(closure_, x); }; -inline void z_take(zc_owned_concurrent_close_handle_t* this_, zc_moved_concurrent_close_handle_t* x) { - zc_concurrent_close_handle_take(this_, x); -}; -inline void z_take(zc_owned_shm_client_list_t* this_, zc_moved_shm_client_list_t* x) { - zc_shm_client_list_take(this_, x); -}; -inline void z_take(ze_owned_advanced_publisher_t* this_, ze_moved_advanced_publisher_t* x) { - ze_advanced_publisher_take(this_, x); -}; -inline void z_take(ze_owned_advanced_subscriber_t* this_, ze_moved_advanced_subscriber_t* x) { - ze_advanced_subscriber_take(this_, x); -}; -inline void z_take(ze_owned_closure_miss_t* closure_, ze_moved_closure_miss_t* x) { - ze_closure_miss_take(closure_, x); -}; -inline void z_take(ze_owned_publication_cache_t* this_, ze_moved_publication_cache_t* x) { - ze_publication_cache_take(this_, x); -}; -inline void z_take(ze_owned_querying_subscriber_t* this_, ze_moved_querying_subscriber_t* x) { - ze_querying_subscriber_take(this_, x); -}; -inline void z_take(ze_owned_sample_miss_listener_t* this_, ze_moved_sample_miss_listener_t* x) { - ze_sample_miss_listener_take(this_, x); -}; inline void z_take(ze_owned_serializer_t* this_, ze_moved_serializer_t* x) { ze_serializer_take(this_, x); }; @@ -1124,10 +812,8 @@ inline void z_take_from_loaned(z_owned_sample_t* dst, z_loaned_sample_t* src) { }; -inline bool z_internal_check(const z_owned_alloc_layout_t& this_) { return z_internal_alloc_layout_check(&this_); }; inline bool z_internal_check(const z_owned_bytes_t& this_) { return z_internal_bytes_check(&this_); }; inline bool z_internal_check(const z_owned_bytes_writer_t& this_) { return z_internal_bytes_writer_check(&this_); }; -inline bool z_internal_check(const z_owned_chunk_alloc_result_t& this_) { return z_internal_chunk_alloc_result_check(&this_); }; inline bool z_internal_check(const z_owned_closure_hello_t& this_) { return z_internal_closure_hello_check(&this_); }; inline bool z_internal_check(const z_owned_closure_matching_status_t& this_) { return z_internal_closure_matching_status_check(&this_); }; inline bool z_internal_check(const z_owned_closure_query_t& this_) { return z_internal_closure_query_check(&this_); }; @@ -1144,9 +830,7 @@ inline bool z_internal_check(const z_owned_hello_t& this_) { return z_internal_h inline bool z_internal_check(const z_owned_keyexpr_t& this_) { return z_internal_keyexpr_check(&this_); }; inline bool z_internal_check(const z_owned_liveliness_token_t& this_) { return z_internal_liveliness_token_check(&this_); }; inline bool z_internal_check(const z_owned_matching_listener_t& this_) { return z_internal_matching_listener_check(&this_); }; -inline bool z_internal_check(const z_owned_memory_layout_t& this_) { return z_internal_memory_layout_check(&this_); }; inline bool z_internal_check(const z_owned_mutex_t& this_) { return z_internal_mutex_check(&this_); }; -inline bool z_internal_check(const z_owned_ptr_in_segment_t& this_) { return z_internal_ptr_in_segment_check(&this_); }; inline bool z_internal_check(const z_owned_publisher_t& this_) { return z_internal_publisher_check(&this_); }; inline bool z_internal_check(const z_owned_querier_t& this_) { return z_internal_querier_check(&this_); }; inline bool z_internal_check(const z_owned_query_t& query) { return z_internal_query_check(&query); }; @@ -1158,26 +842,12 @@ inline bool z_internal_check(const z_owned_ring_handler_reply_t& this_) { return inline bool z_internal_check(const z_owned_ring_handler_sample_t& this_) { return z_internal_ring_handler_sample_check(&this_); }; inline bool z_internal_check(const z_owned_sample_t& this_) { return z_internal_sample_check(&this_); }; inline bool z_internal_check(const z_owned_session_t& this_) { return z_internal_session_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_t& this_) { return z_internal_shm_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_client_t& this_) { return z_internal_shm_client_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_client_storage_t& this_) { return z_internal_shm_client_storage_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_mut_t& this_) { return z_internal_shm_mut_check(&this_); }; -inline bool z_internal_check(const z_owned_shm_provider_t& this_) { return z_internal_shm_provider_check(&this_); }; inline bool z_internal_check(const z_owned_slice_t& this_) { return z_internal_slice_check(&this_); }; -inline bool z_internal_check(const z_owned_source_info_t& this_) { return z_internal_source_info_check(&this_); }; inline bool z_internal_check(const z_owned_string_array_t& this_) { return z_internal_string_array_check(&this_); }; inline bool z_internal_check(const z_owned_string_t& this_) { return z_internal_string_check(&this_); }; inline bool z_internal_check(const z_owned_subscriber_t& this_) { return z_internal_subscriber_check(&this_); }; inline bool z_internal_check(const z_owned_task_t& this_) { return z_internal_task_check(&this_); }; inline bool z_internal_check(const zc_owned_closure_log_t& this_) { return zc_internal_closure_log_check(&this_); }; -inline bool z_internal_check(const zc_owned_concurrent_close_handle_t& this_) { return zc_internal_concurrent_close_handle_check(&this_); }; -inline bool z_internal_check(const zc_owned_shm_client_list_t& this_) { return zc_internal_shm_client_list_check(&this_); }; -inline bool z_internal_check(const ze_owned_advanced_publisher_t& this_) { return ze_internal_advanced_publisher_check(&this_); }; -inline bool z_internal_check(const ze_owned_advanced_subscriber_t& this_) { return ze_internal_advanced_subscriber_check(&this_); }; -inline bool z_internal_check(const ze_owned_closure_miss_t& this_) { return ze_internal_closure_miss_check(&this_); }; -inline bool z_internal_check(const ze_owned_publication_cache_t& this_) { return ze_internal_publication_cache_check(&this_); }; -inline bool z_internal_check(const ze_owned_querying_subscriber_t& this_) { return ze_internal_querying_subscriber_check(&this_); }; -inline bool z_internal_check(const ze_owned_sample_miss_listener_t& this_) { return ze_internal_sample_miss_listener_check(&this_); }; inline bool z_internal_check(const ze_owned_serializer_t& this_) { return ze_internal_serializer_check(&this_); }; @@ -1199,9 +869,6 @@ inline void z_call(const z_loaned_closure_sample_t* closure, z_loaned_sample_t* inline void z_call(const z_loaned_closure_zid_t* closure, const z_id_t* z_id) { z_closure_zid_call(closure, z_id); }; -inline void z_call(const ze_loaned_closure_miss_t* closure, const ze_miss_t* mathing_status) { - ze_closure_miss_call(closure, mathing_status); -}; extern "C" using z_closure_drop_callback_t = void(void* context); extern "C" using z_closure_hello_callback_t = void(z_loaned_hello_t *hello, void *context); @@ -1211,7 +878,6 @@ extern "C" using z_closure_reply_callback_t = void(z_loaned_reply_t *reply, void extern "C" using z_closure_sample_callback_t = void(z_loaned_sample_t *sample, void *context); extern "C" using z_closure_zid_callback_t = void(const z_id_t *z_id, void *context); extern "C" using zc_closure_log_callback_t = void(zc_log_severity_t severity, const z_loaned_string_t *msg, void *context); -extern "C" using ze_closure_miss_callback_t = void(const ze_miss_t *matching_status, void *context); inline void z_closure(z_owned_closure_hello_t* this_, z_closure_hello_callback_t* call, z_closure_drop_callback_t* drop, void* context) { @@ -1241,10 +907,6 @@ inline void z_closure(zc_owned_closure_log_t* this_, zc_closure_log_callback_t* z_closure_drop_callback_t* drop, void* context) { zc_closure_log(this_, call, drop, context); }; -inline void z_closure(ze_owned_closure_miss_t* this_, ze_closure_miss_callback_t* call, - z_closure_drop_callback_t* drop, void* context) { - ze_closure_miss(this_, call, drop, context); -}; inline z_result_t z_try_recv(const z_loaned_fifo_handler_query_t* this_, z_owned_query_t* query) { @@ -1302,9 +964,6 @@ inline void z_clone(z_owned_hello_t* dst, z_loaned_hello_t* this_) { inline void z_clone(z_owned_keyexpr_t* dst, z_loaned_keyexpr_t* this_) { z_keyexpr_clone(dst, this_); }; -inline void z_clone(z_owned_ptr_in_segment_t* out, z_loaned_ptr_in_segment_t* this_) { - z_ptr_in_segment_clone(out, this_); -}; inline void z_clone(z_owned_query_t* dst, z_loaned_query_t* this_) { z_query_clone(dst, this_); }; @@ -1317,12 +976,6 @@ inline void z_clone(z_owned_reply_err_t* dst, z_loaned_reply_err_t* this_) { inline void z_clone(z_owned_sample_t* dst, z_loaned_sample_t* this_) { z_sample_clone(dst, this_); }; -inline void z_clone(z_owned_shm_client_storage_t* this_, z_loaned_shm_client_storage_t* from) { - z_shm_client_storage_clone(this_, from); -}; -inline void z_clone(z_owned_shm_t* out, z_loaned_shm_t* this_) { - z_shm_clone(out, this_); -}; inline void z_clone(z_owned_slice_t* dst, z_loaned_slice_t* this_) { z_slice_clone(dst, this_); }; @@ -1335,8 +988,6 @@ inline void z_clone(z_owned_string_t* dst, z_loaned_string_t* this_) { template struct z_loaned_to_owned_type_t {}; template struct z_owned_to_loaned_type_t {}; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_alloc_layout_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_alloc_layout_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_bytes_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_bytes_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_bytes_writer_t type; }; @@ -1371,10 +1022,6 @@ template<> struct z_loaned_to_owned_type_t { typedef z_owned template<> struct z_owned_to_loaned_type_t { typedef z_loaned_keyexpr_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_liveliness_token_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_liveliness_token_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_memory_layout_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_memory_layout_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_ptr_in_segment_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_ptr_in_segment_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_publisher_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_publisher_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_querier_t type; }; @@ -1397,18 +1044,8 @@ template<> struct z_loaned_to_owned_type_t { typedef z_owned_ template<> struct z_owned_to_loaned_type_t { typedef z_loaned_sample_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_session_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_session_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_client_storage_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_client_storage_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_mut_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_mut_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_shm_provider_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_shm_provider_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_slice_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_slice_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_source_info_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_source_info_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_string_array_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_string_array_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_string_t type; }; @@ -1417,18 +1054,6 @@ template<> struct z_loaned_to_owned_type_t { typedef z_ow template<> struct z_owned_to_loaned_type_t { typedef z_loaned_subscriber_t type; }; template<> struct z_loaned_to_owned_type_t { typedef zc_owned_closure_log_t type; }; template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_closure_log_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef zc_owned_shm_client_list_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_shm_client_list_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef ze_owned_advanced_publisher_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef ze_loaned_advanced_publisher_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef ze_owned_advanced_subscriber_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef ze_loaned_advanced_subscriber_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef ze_owned_closure_miss_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef ze_loaned_closure_miss_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef ze_owned_publication_cache_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef ze_loaned_publication_cache_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef ze_owned_querying_subscriber_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef ze_loaned_querying_subscriber_t type; }; template<> struct z_loaned_to_owned_type_t { typedef ze_owned_serializer_t type; }; template<> struct z_owned_to_loaned_type_t { typedef ze_loaned_serializer_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_mutex_t type; }; diff --git a/prebindgen-project-root/Cargo.toml b/prebindgen-project-root/Cargo.toml new file mode 100644 index 000000000..26dd59cd1 --- /dev/null +++ b/prebindgen-project-root/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "prebindgen-project-root" +version = "0.4.0" +edition = "2021" +license = "MIT OR Apache-2.0" +description = "Utility to expose the workspace project root at build time" +publish = false + +[build-dependencies] +project-root = "0.2" +quote = "1" diff --git a/prebindgen-project-root/build.rs b/prebindgen-project-root/build.rs new file mode 100644 index 000000000..e99ce085a --- /dev/null +++ b/prebindgen-project-root/build.rs @@ -0,0 +1,25 @@ +use std::path::PathBuf; + +fn main() { + // If the crate is located under CARGO_HOME (i.e., used as a dependency outside the workspace), + // we cannot infer the workspace root reliably. Panic with guidance. + let cargo_home = if let Ok(ch) = std::env::var("CARGO_HOME") { + PathBuf::from(ch) + } else if let Ok(home) = std::env::var("HOME") { + PathBuf::from(home).join(".cargo") + } else { + panic!("Unable to determine CARGO_HOME and HOME is not set"); + }; + + let manifest_dir = + PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set")); + + if manifest_dir.starts_with(&cargo_home) { + println!("cargo:rustc-env=PROJECT_ROOT="); + println!("cargo:warning=prebindgen-project-root is not located inside your workspace"); + } else { + let workspace_root = project_root::get_project_root() + .unwrap_or_else(|e| panic!("Failed to determine workspace root: {e}")); + println!("cargo:rustc-env=PROJECT_ROOT={}", workspace_root.display()); + } +} diff --git a/prebindgen-project-root/src/lib.rs b/prebindgen-project-root/src/lib.rs new file mode 100644 index 000000000..49d5ee066 --- /dev/null +++ b/prebindgen-project-root/src/lib.rs @@ -0,0 +1,23 @@ +use std::path::PathBuf; + +/// Returns the absolute path to the cargo workspace root that built this crate. +/// +/// This works only if this crate is included in a Cargo workspace. In the opposite case, +/// it will return an error, explaining how to correctly configure the crate. +pub fn get_project_root() -> Result { + let project_root = env!("PROJECT_ROOT"); + if project_root.is_empty() { + let error = + "The crate `prebindgen-project-root` is being used as a regular Cargo dependency.\n\ + Because it is not located within your workspace, it cannot determine the path to the workspace root.\n\ + Please add `prebindgen-project-root` as a member of your workspace and patch your dependencies to use the local path.\n\n\ + You can do this with the helper tool:\n\n\ + cargo install prebindgen-project-root\n\ + cargo prebindgen-project-root install \n\n\ + where `` is the path to your workspace root.\n\n\ + If the patch is already applied and the error persists, verify the version of the patched crate."; + Err(error) + } else { + Ok(project_root.into()) + } +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml index c1bc0a694..e88baf106 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.85.0" +channel = "1.88.0" diff --git a/src/advanced_publisher.rs b/src/advanced_publisher.rs deleted file mode 100644 index fe69bc975..000000000 --- a/src/advanced_publisher.rs +++ /dev/null @@ -1,537 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::{mem::MaybeUninit, time::Duration}; - -use zenoh::{ - handlers::Callback, - matching::MatchingStatus, - qos::{CongestionControl, Priority}, - session::SessionClosedError, - Wait, -}; -use zenoh_ext::{AdvancedPublisherBuilderExt, CacheConfig, MissDetectionConfig}; - -use crate::{ - _apply_pubisher_delete_options, _apply_pubisher_put_options, _declare_publisher_inner, - result::{self}, - transmute::{IntoCType, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_closure_matching_status_call, z_closure_matching_status_loan, z_congestion_control_t, - z_entity_global_id_t, z_loaned_keyexpr_t, z_loaned_session_t, z_matching_status_t, - z_moved_bytes_t, z_moved_closure_matching_status_t, z_owned_matching_listener_t, z_priority_t, - z_publisher_delete_options_t, z_publisher_options_t, z_publisher_put_options_t, -}; - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Setting for advanced publisher's cache. The cache allows advanced subscribers to recover history and/or lost samples. -#[repr(C)] -pub struct ze_advanced_publisher_cache_options_t { - /// Must be set to ``true``, to enable the cache. - pub is_enabled: bool, - /// Number of samples to keep for each resource. - pub max_samples: usize, - /// The congestion control to apply to replies. - pub congestion_control: z_congestion_control_t, - /// The priority of replies. - pub priority: z_priority_t, - /// If set to ``true``, this cache replies will not be batched. This usually has a positive impact on latency but negative impact on throughput. - pub is_express: bool, -} - -impl Default for ze_advanced_publisher_cache_options_t { - fn default() -> Self { - Self { - is_enabled: true, - max_samples: 1, - congestion_control: CongestionControl::DEFAULT_PUSH.into(), - priority: Priority::default().into(), - is_express: false, - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs the default value for `ze_advanced_publisher_cache_options_t`. -#[no_mangle] -pub extern "C" fn ze_advanced_publisher_cache_options_default( - this: &mut MaybeUninit, -) { - this.write(ze_advanced_publisher_cache_options_t::default()); -} - -impl From<&ze_advanced_publisher_cache_options_t> for CacheConfig { - fn from(val: &ze_advanced_publisher_cache_options_t) -> CacheConfig { - let mut c = CacheConfig::default(); - c = c.max_samples(val.max_samples); - let qos = zenoh_ext::RepliesConfig::default() - .congestion_control(val.congestion_control.into()) - .express(val.is_express) - .priority(val.priority.into()); - c = c.replies_config(qos); - c - } -} - -#[allow(non_camel_case_types)] -#[repr(C)] -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub enum ze_advanced_publisher_heartbeat_mode_t { - /// Disable heartbeat-based last sample miss detection. - NONE = 0, - /// Allow last sample miss detection through periodic heartbeat. - /// Periodically send the last published Sample's sequence number to allow last sample recovery. - PERIODIC = 1, - /// Allow last sample miss detection through sporadic heartbeat. - /// Each period, the last published Sample's sequence number is sent with `z_congestion_control_t::BLOCK` - /// but only if it changed since last period. - SPORADIC = 2, -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Settings for sample miss detection on Advanced Publisher. -#[repr(C)] -pub struct ze_advanced_publisher_sample_miss_detection_options_t { - /// Must be set to ``true``, to enable sample miss detection by adding sequence numbers. - pub is_enabled: bool, - /// Allow last sample miss detection through sporadic or periodic heartbeat. - pub heartbeat_mode: ze_advanced_publisher_heartbeat_mode_t, - /// If heartbeat_mode is not NONE, the publisher will send heartbeats with the specified period, which - /// can be used by Advanced Subscribers for last sample(s) miss detection (if last sample miss detection with zero query period is enabled). - pub heartbeat_period_ms: u64, -} - -impl Default for ze_advanced_publisher_sample_miss_detection_options_t { - fn default() -> Self { - Self { - is_enabled: true, - heartbeat_mode: ze_advanced_publisher_heartbeat_mode_t::NONE, - heartbeat_period_ms: 0, - } - } -} - -impl From<&ze_advanced_publisher_sample_miss_detection_options_t> for MissDetectionConfig { - fn from(val: &ze_advanced_publisher_sample_miss_detection_options_t) -> Self { - let mut m = MissDetectionConfig::default(); - if val.heartbeat_mode == ze_advanced_publisher_heartbeat_mode_t::SPORADIC { - m = m.sporadic_heartbeat(Duration::from_millis(val.heartbeat_period_ms)) - } else if val.heartbeat_mode == ze_advanced_publisher_heartbeat_mode_t::PERIODIC { - m = m.heartbeat(Duration::from_millis(val.heartbeat_period_ms)) - } else if val.heartbeat_period_ms > 0 { - tracing::warn!("ze_advanced_publisher_sample_miss_detection_options_t: heartbeat_mode=NONE but heartbeat_period_ms={}. heartbeat_mode=PERIODIC is used instead, but this behavor will be removed later", val.heartbeat_period_ms); - m = m.heartbeat(Duration::from_millis(val.heartbeat_period_ms)) - } - m - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs the default value for `ze_advanced_publisher_sample_miss_detection_options_t`. -#[no_mangle] -pub extern "C" fn ze_advanced_publisher_sample_miss_detection_options_default( - this: &mut MaybeUninit, -) { - this.write(ze_advanced_publisher_sample_miss_detection_options_t::default()); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Options passed to the `ze_declare_advanced_publisher()` function. -#[repr(C)] -pub struct ze_advanced_publisher_options_t { - /// Base publisher options. - pub publisher_options: z_publisher_options_t, - /// Publisher cache settings. - pub cache: ze_advanced_publisher_cache_options_t, - /// Settings to allow matching Subscribers to detect lost samples and optionally ask for retransimission. - /// - /// Retransmission can only be done if cache is enabled. - pub sample_miss_detection: ze_advanced_publisher_sample_miss_detection_options_t, - /// Allow this publisher to be detected through liveliness. - pub publisher_detection: bool, - /// An optional key expression to be added to the liveliness token key expression. - /// It can be used to convey meta data. - pub publisher_detection_metadata: Option<&'static z_loaned_keyexpr_t>, -} - -/// Constructs the default value for `z_publisher_options_t`. -#[no_mangle] -pub extern "C" fn ze_advanced_publisher_options_default( - this_: &mut MaybeUninit, -) { - let cache = ze_advanced_publisher_cache_options_t { - is_enabled: false, - ..Default::default() - }; - let sample_miss_detection = ze_advanced_publisher_sample_miss_detection_options_t { - is_enabled: false, - ..Default::default() - }; - this_.write(ze_advanced_publisher_options_t { - publisher_options: z_publisher_options_t::default(), - cache, - sample_miss_detection, - publisher_detection: false, - publisher_detection_metadata: None, - }); -} - -pub use crate::opaque_types::{ - ze_loaned_advanced_publisher_t, ze_moved_advanced_publisher_t, ze_owned_advanced_publisher_t, -}; -decl_c_type!( - owned(ze_owned_advanced_publisher_t, option zenoh_ext::AdvancedPublisher<'static>), - loaned(ze_loaned_advanced_publisher_t), -); - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Constructs and declares an advanced publisher for the given key expression. -/// -/// Data can be put and deleted with this publisher with the help of the -/// `ze_advanced_publisher_put()` and `ze_advanced_publisher_delete()` functions. -/// -/// @param session: The Zenoh session. -/// @param publisher: An uninitialized location in memory where advanced publisher will be constructed. -/// @param key_expr: The key expression to publish to. -/// @param options: Additional options for the advanced publisher. -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_declare_advanced_publisher( - session: &'static z_loaned_session_t, - publisher: &'static mut MaybeUninit, - key_expr: &'static z_loaned_keyexpr_t, - mut options: Option<&'static mut ze_advanced_publisher_options_t>, -) -> result::z_result_t { - let this = publisher.as_rust_type_mut_uninit(); - let p = _declare_publisher_inner( - session, - key_expr, - options.as_mut().map(|o| &mut o.publisher_options), - ); - let mut p = p.advanced(); - if let Some(options) = options { - if options.publisher_detection { - p = p.publisher_detection(); - } - if options.sample_miss_detection.is_enabled { - p = p.sample_miss_detection((&options.sample_miss_detection).into()); - } - if let Some(pub_detection_metadata) = &options.publisher_detection_metadata { - p = p.publisher_detection_metadata(pub_detection_metadata.as_rust_type_ref()); - } - if options.cache.is_enabled { - p = p.cache((&options.cache).into()); - } - } - match p.wait() { - Err(e) => { - crate::report_error!("{}", e); - this.write(None); - result::Z_EGENERIC - } - Ok(publisher) => { - this.write(Some(publisher)); - result::Z_OK - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Constructs an advanced publisher in a gravestone state. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_internal_advanced_publisher_null( - this_: &mut MaybeUninit, -) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Returns ``true`` if advanced publisher is valid, ``false`` otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub extern "C" fn ze_internal_advanced_publisher_check( - this_: &ze_owned_advanced_publisher_t, -) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Borrows advanced publisher. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_advanced_publisher_loan( - this_: &ze_owned_advanced_publisher_t, -) -> &ze_loaned_advanced_publisher_t { - this_ - .as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Mutably borrows advanced publisher. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_advanced_publisher_loan_mut( - this: &mut ze_owned_advanced_publisher_t, -) -> &mut ze_loaned_advanced_publisher_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Options passed to the `ze_advanced_publisher_put()` function. -#[repr(C)] -pub struct ze_advanced_publisher_put_options_t { - /// Base put options. - put_options: z_publisher_put_options_t, -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Constructs the default value for `ze_advanced_publisher_put_options_t`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_advanced_publisher_put_options_default( - this: &mut MaybeUninit, -) { - this.write(ze_advanced_publisher_put_options_t { - put_options: z_publisher_put_options_t::default(), - }); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Sends a `PUT` message onto the advanced publisher's key expression, transfering the payload ownership. -/// -/// The payload and all owned options fields are consumed upon function return. -/// -/// @param this_: The advanced publisher. -/// @param payload: The data to publish. Will be consumed. -/// @param options: The advanced publisher put options. All owned fields will be consumed. -/// -/// @return 0 in case of success, negative error values in case of failure. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_advanced_publisher_put( - this: &ze_loaned_advanced_publisher_t, - payload: &mut z_moved_bytes_t, - options: Option<&mut ze_advanced_publisher_put_options_t>, -) -> result::z_result_t { - let publisher = this.as_rust_type_ref(); - let payload = payload.take_rust_type(); - let mut put = publisher.put(payload); - if let Some(options) = options { - put = _apply_pubisher_put_options(put, &mut options.put_options); - } - match put.wait() { - Ok(_) => result::Z_OK, - Err(e) if e.downcast_ref::().is_some() => result::Z_ESESSION_CLOSED, - Err(e) => { - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Represents the set of options that can be applied to the delete operation by a previously declared advanced publisher, -/// whenever issued via `ze_advanced_publisher_delete()`. -#[repr(C)] -pub struct ze_advanced_publisher_delete_options_t { - /// Base delete options. - pub delete_options: z_publisher_delete_options_t, -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Constructs the default values for the delete operation via an advanced publisher entity. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_advanced_publisher_delete_options_default( - this: &mut MaybeUninit, -) { - this.write(ze_advanced_publisher_delete_options_t { - delete_options: z_publisher_delete_options_t::default(), - }); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Sends a `DELETE` message onto the advanced publisher's key expression. -/// -/// @return 0 in case of success, negative error code in case of failure. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_advanced_publisher_delete( - publisher: &ze_loaned_advanced_publisher_t, - options: Option<&mut ze_advanced_publisher_delete_options_t>, -) -> result::z_result_t { - let publisher = publisher.as_rust_type_ref(); - let mut del = publisher.delete(); - if let Some(options) = options { - del = _apply_pubisher_delete_options(del, &mut options.delete_options) - } - if let Err(e) = del.wait() { - crate::report_error!("{}", e); - result::Z_EGENERIC - } else { - result::Z_OK - } -} -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns the ID of the advanced publisher. -#[no_mangle] -pub extern "C" fn ze_advanced_publisher_id( - publisher: &ze_loaned_advanced_publisher_t, -) -> z_entity_global_id_t { - publisher.as_rust_type_ref().id().into_c_type() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Returns the key expression of the publisher. -#[no_mangle] -pub extern "C" fn ze_advanced_publisher_keyexpr( - publisher: &ze_loaned_advanced_publisher_t, -) -> &z_loaned_keyexpr_t { - publisher - .as_rust_type_ref() - .key_expr() - .as_loaned_c_type_ref() -} - -#[cfg(feature = "unstable")] -fn _advanced_publisher_matching_listener_declare_inner<'a>( - publisher: &'a ze_loaned_advanced_publisher_t, - callback: &mut z_moved_closure_matching_status_t, -) -> zenoh::matching::MatchingListenerBuilder<'a, Callback> { - let publisher = publisher.as_rust_type_ref(); - let callback = callback.take_rust_type(); - let listener = publisher - .matching_listener() - .callback_mut(move |matching_status| { - let status = z_matching_status_t { - matching: matching_status.matching(), - }; - z_closure_matching_status_call(z_closure_matching_status_loan(&callback), &status); - }); - listener -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs matching listener, registering a callback for notifying subscribers matching with a given advanced publisher. -/// -/// @param publisher: An advanced publisher to associate with matching listener. -/// @param matching_listener: An uninitialized memory location where matching listener will be constructed. The matching listener's callback will be automatically dropped when the publisher is dropped. -/// @param callback: A closure that will be called every time the matching status of the publisher changes (If last subscriber disconnects or when the first subscriber connects). -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_advanced_publisher_declare_matching_listener( - publisher: &'static ze_loaned_advanced_publisher_t, - matching_listener: &mut MaybeUninit, - callback: &mut z_moved_closure_matching_status_t, -) -> result::z_result_t { - let this = matching_listener.as_rust_type_mut_uninit(); - let listener = _advanced_publisher_matching_listener_declare_inner(publisher, callback); - match listener.wait() { - Ok(listener) => { - this.write(Some(listener)); - result::Z_OK - } - Err(e) => { - this.write(None); - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Declares a matching listener, registering a callback for notifying subscribers matching with a given advanced publisher. -/// The callback will be run in the background until the corresponding publisher is dropped. -/// -/// @param publisher: An advanced publisher to associate with matching listener. -/// @param callback: A closure that will be called every time the matching status of the publisher changes (If last subscriber disconnects or when the first subscriber connects). -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_advanced_publisher_declare_background_matching_listener( - publisher: &'static ze_loaned_advanced_publisher_t, - callback: &mut z_moved_closure_matching_status_t, -) -> result::z_result_t { - let listener = _advanced_publisher_matching_listener_declare_inner(publisher, callback); - match listener.background().wait() { - Ok(_) => result::Z_OK, - Err(e) => { - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Gets advanced publisher matching status - i.e. if there are any subscribers matching its key expression. -/// -/// @return 0 in case of success, negative error code otherwise (in this case matching_status is not updated). -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_advanced_publisher_get_matching_status( - this: &'static ze_loaned_advanced_publisher_t, - matching_status: &mut MaybeUninit, -) -> result::z_result_t { - match this.as_rust_type_ref().matching_status().wait() { - Ok(s) => { - matching_status.write(z_matching_status_t { - matching: s.matching(), - }); - result::Z_OK - } - Err(e) => { - crate::report_error!("{}", e); - result::Z_ENETWORK - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Frees memory and resets advanced_publisher to its gravestone state. -/// This is equivalent to calling `z_undeclare_publisher()` and discarding its return value. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_advanced_publisher_drop(this: &mut ze_moved_advanced_publisher_t) { - std::mem::drop(this.take_rust_type()) -} - -#[no_mangle] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Undeclares the given advanced publisher. -/// -/// @return 0 in case of success, negative error code otherwise. -pub extern "C" fn ze_undeclare_advanced_publisher( - this_: &mut ze_moved_advanced_publisher_t, -) -> result::z_result_t { - if let Some(p) = this_.take_rust_type() { - if let Err(e) = p.undeclare().wait() { - crate::report_error!("{}", e); - return result::Z_ENETWORK; - } - } - result::Z_OK -} diff --git a/src/advanced_subscriber.rs b/src/advanced_subscriber.rs deleted file mode 100644 index 45c16b8e2..000000000 --- a/src/advanced_subscriber.rs +++ /dev/null @@ -1,579 +0,0 @@ -// -// Copyright (c) 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::{mem::MaybeUninit, time::Duration}; - -use zenoh::{handlers::Callback, liveliness::LivelinessSubscriberBuilder, sample::Sample, Wait}; -use zenoh_ext::{AdvancedSubscriberBuilderExt, HistoryConfig, RecoveryConfig, SampleMissListener}; - -use crate::{ - _declare_subscriber_inner, result, - transmute::{IntoCType, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_closure_sample_call, z_closure_sample_loan, z_entity_global_id_t, - z_liveliness_subscriber_options_t, z_loaned_keyexpr_t, z_loaned_session_t, - z_moved_closure_sample_t, z_owned_subscriber_t, z_subscriber_options_t, ze_closure_miss_call, - ze_closure_miss_loan, ze_loaned_advanced_subscriber_t, ze_moved_advanced_subscriber_t, - ze_moved_closure_miss_t, ze_moved_sample_miss_listener_t, ze_owned_advanced_subscriber_t, - ze_owned_sample_miss_listener_t, -}; - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Settings for retrievieng historical data for Advanced Subscriber. -#[repr(C)] -pub struct ze_advanced_subscriber_history_options_t { - /// Must be set to ``true``, to enable the history data recovery. - pub is_enabled: bool, - /// Enable detection of late joiner publishers and query for their historical data. - /// Late joiner detection can only be achieved for Publishers that enable publisher_detection. - /// History can only be retransmitted by Publishers that enable caching. - pub detect_late_publishers: bool, - /// Number of samples to query for each resource. ``0`` corresponds to no limit on number of samples. - pub max_samples: usize, - /// Maximum age of samples to query. ``0`` corresponds to no limit on samples' age. - pub max_age_ms: u64, -} - -impl Default for ze_advanced_subscriber_history_options_t { - fn default() -> Self { - Self { - is_enabled: true, - detect_late_publishers: false, - max_samples: 0, - max_age_ms: 0, - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs the default value for `ze_advanced_subscriber_history_options_t`. -#[no_mangle] -pub extern "C" fn ze_advanced_subscriber_history_options_default( - this: &mut MaybeUninit, -) { - this.write(ze_advanced_subscriber_history_options_t::default()); -} - -impl From<&ze_advanced_subscriber_history_options_t> for HistoryConfig { - fn from(val: &ze_advanced_subscriber_history_options_t) -> Self { - let mut h = HistoryConfig::default(); - if val.detect_late_publishers { - h = h.detect_late_publishers(); - } - if val.max_samples > 0 { - h = h.max_samples(val.max_samples) - } - if val.max_age_ms > 0 { - h = h.max_age(val.max_age_ms as f64 / 1000.0f64) - } - h - } -} - -#[repr(C)] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Settings for detection of the last sample(s) miss by Advanced Subscriber. -pub struct ze_advanced_subscriber_last_sample_miss_detection_options_t { - /// Must be set to ``true``, to enable the last sample(s) miss detection. - pub is_enabled: bool, - /// Period for queries for not yet received Samples. - /// - /// These queries allow to retrieve the last Sample(s) if the last Sample(s) is/are lost. - /// So it is useful for sporadic publications but useless for periodic publications - /// with a period smaller or equal to this period. If set to 0, the last sample(s) miss detection will be performed - /// based on publisher's heartbeat if the latter is enabled. - pub periodic_queries_period_ms: u64, -} - -impl Default for ze_advanced_subscriber_last_sample_miss_detection_options_t { - fn default() -> Self { - Self { - is_enabled: true, - periodic_queries_period_ms: 0, - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs the default value for `ze_advanced_subscriber_last_sample_miss_detection_options_t`. -#[no_mangle] -pub extern "C" fn ze_advanced_subscriber_last_sample_miss_detection_options_default( - this: &mut MaybeUninit, -) { - this.write(ze_advanced_subscriber_last_sample_miss_detection_options_t::default()); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Settings for recovering lost messages for Advanced Subscriber. -#[repr(C)] -pub struct ze_advanced_subscriber_recovery_options_t { - /// Must be set to ``true``, to enable the lost sample recovery. - pub is_enabled: bool, - /// Setting for detecting last sample(s) miss. - /// Note that it does not affect intermediate sample miss detection/retrieval (which is performed automatically as long as recovery is enabled). - /// If this option is disabled, subscriber will be unable to detect/request retransmission of missed sample until it receives a more recent one from the same publisher. - pub last_sample_miss_detection: ze_advanced_subscriber_last_sample_miss_detection_options_t, -} - -impl Default for ze_advanced_subscriber_recovery_options_t { - fn default() -> Self { - Self { - is_enabled: true, - last_sample_miss_detection: - ze_advanced_subscriber_last_sample_miss_detection_options_t { - is_enabled: false, - ..Default::default() - }, - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs the default value for `ze_advanced_subscriber_recovery_options_t`. -#[no_mangle] -pub extern "C" fn ze_advanced_subscriber_recovery_options_default( - this: &mut MaybeUninit, -) { - this.write(ze_advanced_subscriber_recovery_options_t::default()); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Options passed to the `ze_declare_advanced_subscriber()` function. -#[repr(C)] -pub struct ze_advanced_subscriber_options_t { - /// Base subscriber options. - pub subscriber_options: z_subscriber_options_t, - /// Settings for querying historical data. History can only be retransmitted by Publishers that enable caching. - pub history: ze_advanced_subscriber_history_options_t, - /// Settings for retransmission of detected lost Samples. Retransmission of lost samples can only be done by Publishers that enable - /// caching and sample_miss_detection. - pub recovery: ze_advanced_subscriber_recovery_options_t, - /// Timeout to be used for history and recovery queries. - /// Default value will be used if set to ``0``. - pub query_timeout_ms: u64, - /// Allow this subscriber to be detected through liveliness. - pub subscriber_detection: bool, - /// An optional key expression to be added to the liveliness token key expression. - /// It can be used to convey meta data. - pub subscriber_detection_metadata: Option<&'static z_loaned_keyexpr_t>, -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs the default value for `ze_advanced_subscriber_options_t`. -#[no_mangle] -pub extern "C" fn ze_advanced_subscriber_options_default( - this: &mut MaybeUninit, -) { - let history = ze_advanced_subscriber_history_options_t { - is_enabled: false, - ..Default::default() - }; - let recovery = ze_advanced_subscriber_recovery_options_t { - is_enabled: false, - ..Default::default() - }; - this.write(ze_advanced_subscriber_options_t { - subscriber_options: z_subscriber_options_t::default(), - history, - recovery, - query_timeout_ms: 0, - subscriber_detection: false, - subscriber_detection_metadata: None, - }); -} - -fn _declare_advanced_subscriber_inner( - session: &'static z_loaned_session_t, - key_expr: &'static z_loaned_keyexpr_t, - callback: &mut z_moved_closure_sample_t, - mut options: Option<&'static mut ze_advanced_subscriber_options_t>, -) -> zenoh_ext::AdvancedSubscriberBuilder<'static, 'static, 'static, Callback> { - let sub = _declare_subscriber_inner( - session, - key_expr, - callback, - options.as_mut().map(|o| &mut o.subscriber_options), - ); - let mut sub = sub.advanced(); - if let Some(options) = options { - if options.query_timeout_ms > 0 { - sub = sub.query_timeout(Duration::from_millis(options.query_timeout_ms)); - } - if options.subscriber_detection { - sub = sub.subscriber_detection() - } - if let Some(sub_detection_metadata) = &options.subscriber_detection_metadata { - sub = sub.subscriber_detection_metadata(sub_detection_metadata.as_rust_type_ref()); - } - if options.history.is_enabled { - sub = sub.history((&options.history).into()); - } - if options.recovery.is_enabled { - if options.recovery.last_sample_miss_detection.is_enabled { - sub = match options - .recovery - .last_sample_miss_detection - .periodic_queries_period_ms - { - 0 => sub.recovery(RecoveryConfig::default().heartbeat()), - p => sub.recovery( - RecoveryConfig::default().periodic_queries(Duration::from_millis(p)), - ), - }; - } else { - sub = sub.recovery(RecoveryConfig::default()) - } - } - } - sub -} - -decl_c_type!( - owned(ze_owned_advanced_subscriber_t, option zenoh_ext::AdvancedSubscriber<()>), - loaned(ze_loaned_advanced_subscriber_t), -); - -/// Constructs a subscriber in a gravestone state. -#[no_mangle] -pub extern "C" fn ze_internal_advanced_subscriber_null( - this_: &mut MaybeUninit, -) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// Borrows subscriber. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_advanced_subscriber_loan( - this_: &ze_owned_advanced_subscriber_t, -) -> &ze_loaned_advanced_subscriber_t { - this_ - .as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// Undeclares advanced subscriber callback and resets it to its gravestone state. -/// This is equivalent to calling `ze_undeclare_advanced_subscriber()` and discarding its return value. -#[no_mangle] -pub extern "C" fn ze_advanced_subscriber_drop(this_: &mut ze_moved_advanced_subscriber_t) { - std::mem::drop(this_.take_rust_type()) -} - -/// Returns ``true`` if advanced subscriber is valid, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn ze_internal_advanced_subscriber_check( - this_: &ze_owned_advanced_subscriber_t, -) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// Constructs and declares an advanced subscriber for a given key expression. Dropping subscriber undeclares its callback. -/// -/// @param session: The zenoh session. -/// @param subscriber: An uninitialized location in memory, where advanced subscriber will be constructed. -/// @param key_expr: The key expression to subscribe. -/// @param callback: The callback function that will be called each time a data matching the subscribed expression is received. -/// @param options: The options to be passed to the subscriber declaration. -/// -/// @return 0 in case of success, negative error code otherwise (in this case subscriber will be in its gravestone state). -#[no_mangle] -pub extern "C" fn ze_declare_advanced_subscriber( - session: &'static z_loaned_session_t, - subscriber: &'static mut MaybeUninit, - key_expr: &'static z_loaned_keyexpr_t, - callback: &'static mut z_moved_closure_sample_t, - options: Option<&'static mut ze_advanced_subscriber_options_t>, -) -> result::z_result_t { - let this = subscriber.as_rust_type_mut_uninit(); - let s = _declare_advanced_subscriber_inner(session, key_expr, callback, options); - match s.wait() { - Ok(sub) => { - this.write(Some(sub)); - result::Z_OK - } - Err(e) => { - crate::report_error!("{}", e); - this.write(None); - result::Z_EGENERIC - } - } -} - -/// Constructs and declares a background advanced subscriber. Subscriber callback will be called to process the messages, -/// until the corresponding session is closed or dropped. -/// -/// @param session: The zenoh session. -/// @param key_expr: The key expression to subscribe. -/// @param callback: The callback function that will be called each time a data matching the subscribed expression is received. -/// @param options: The options to be passed to the subscriber declaration. -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_declare_background_advanced_subscriber( - session: &'static z_loaned_session_t, - key_expr: &'static z_loaned_keyexpr_t, - callback: &'static mut z_moved_closure_sample_t, - options: Option<&'static mut ze_advanced_subscriber_options_t>, -) -> result::z_result_t { - let subscriber = _declare_advanced_subscriber_inner(session, key_expr, callback, options); - match subscriber.background().wait() { - Ok(_) => result::Z_OK, - Err(e) => { - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Undeclares the advanced subscriber. -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_undeclare_advanced_subscriber( - this_: &mut ze_moved_advanced_subscriber_t, -) -> result::z_result_t { - if let Some(s) = this_.take_rust_type() { - if let Err(e) = s.undeclare().wait() { - crate::report_error!("{}", e); - return result::Z_EGENERIC; - } - } - result::Z_OK -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A struct that represents missed samples. -#[repr(C)] -pub struct ze_miss_t { - /// The source of missed samples. - pub source: z_entity_global_id_t, - /// The number of missed samples. - pub nb: u32, -} - -decl_c_type!( - owned(ze_owned_sample_miss_listener_t, option SampleMissListener<()>), -); - -#[no_mangle] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs an empty sample miss listener. -pub extern "C" fn ze_internal_sample_miss_listener_null( - this_: &mut MaybeUninit, -) { - this_.as_rust_type_mut_uninit().write(None); -} - -#[no_mangle] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Checks the sample_miss listener is for the gravestone state -pub extern "C" fn ze_internal_sample_miss_listener_check( - this_: &ze_owned_sample_miss_listener_t, -) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Undeclares the given sample miss listener, droping and invalidating it. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_sample_miss_listener_drop(this: &mut ze_moved_sample_miss_listener_t) { - std::mem::drop(this.take_rust_type()) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Undeclares the given sample miss listener, droping and invalidating it. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_undeclare_sample_miss_listener( - this: &mut ze_moved_sample_miss_listener_t, -) -> result::z_result_t { - if let Some(m) = this.take_rust_type() { - if let Err(e) = m.undeclare().wait() { - crate::report_error!("{}", e); - return result::Z_ENETWORK; - } - } - result::Z_OK -} - -fn _advanced_subscriber_sample_miss_listener_declare_inner<'a>( - subscriber: &'a ze_loaned_advanced_subscriber_t, - callback: &mut ze_moved_closure_miss_t, -) -> zenoh_ext::SampleMissListenerBuilder<'a, Callback> { - let subscriber = subscriber.as_rust_type_ref(); - let callback = callback.take_rust_type(); - let listener = subscriber.sample_miss_listener().callback_mut(move |miss| { - let miss = ze_miss_t { - source: miss.source().into_c_type(), - nb: miss.nb(), - }; - ze_closure_miss_call(ze_closure_miss_loan(&callback), &miss); - }); - listener -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs sample miss listener, registering a callback for notifying subscriber about missed samples. -/// -/// @param subscriber: A subscriber to associate with sample miss listener. -/// @param sample_miss_listener: An uninitialized memory location where sample miss listener will be constructed. The sample miss listener's callback will be automatically dropped when the subscriber is dropped. -/// @param callback: A closure that will be called every time the sample miss is detected. -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_advanced_subscriber_declare_sample_miss_listener( - subscriber: &'static ze_loaned_advanced_subscriber_t, - sample_miss_listener: &mut MaybeUninit, - callback: &mut ze_moved_closure_miss_t, -) -> result::z_result_t { - let this = sample_miss_listener.as_rust_type_mut_uninit(); - let listener = _advanced_subscriber_sample_miss_listener_declare_inner(subscriber, callback); - match listener.wait() { - Ok(listener) => { - this.write(Some(listener)); - result::Z_OK - } - Err(e) => { - this.write(None); - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Declares a sample miss listener, registering a callback for notifying subscriber about missed samples. -/// The callback will be run in the background until the corresponding subscriber is dropped. -/// -/// @param subscriber: A subscriber to associate with sample miss listener. -/// @param callback: A closure that will be called every time the sample miss is detected. -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_advanced_subscriber_declare_background_sample_miss_listener( - subscriber: &'static ze_loaned_advanced_subscriber_t, - callback: &mut ze_moved_closure_miss_t, -) -> result::z_result_t { - let listener = _advanced_subscriber_sample_miss_listener_declare_inner(subscriber, callback); - match listener.background().wait() { - Ok(_) => result::Z_OK, - Err(e) => { - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -fn _advanced_subscriber_detect_publishers_inner( - subscriber: &'static ze_loaned_advanced_subscriber_t, - callback: &'static mut z_moved_closure_sample_t, - options: Option<&'static mut z_liveliness_subscriber_options_t>, -) -> LivelinessSubscriberBuilder<'static, 'static, Callback> { - let subscriber = subscriber.as_rust_type_ref(); - let callback = callback.take_rust_type(); - let sub = subscriber - .detect_publishers() - .history(options.is_some_and(|o| o.history)) - .callback(move |sample| { - let mut owned_sample = Some(sample); - z_closure_sample_call(z_closure_sample_loan(&callback), unsafe { - owned_sample - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() - }) - }); - sub -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Declares a liveliness token listener for matching publishers detection. Only advanced publishers, enabling publisher detection can be detected. -/// -/// @param subscriber: The advanced subscriber instance. -/// @param liveliness_subscriber: An uninitialized memory location where liveliness subscriber will be constructed. -/// @param callback: The callback function that will be called each time a liveliness token status is changed. -/// @param options: The options to be passed to the liveliness subscriber declaration. -/// -/// @return 0 in case of success, negative error values otherwise. -#[no_mangle] -pub extern "C" fn ze_advanced_subscriber_detect_publishers( - subscriber: &'static ze_loaned_advanced_subscriber_t, - liveliness_subscriber: &mut MaybeUninit, - callback: &'static mut z_moved_closure_sample_t, - options: Option<&'static mut z_liveliness_subscriber_options_t>, -) -> result::z_result_t { - let liveliness_subscriber = liveliness_subscriber.as_rust_type_mut_uninit(); - let builder = _advanced_subscriber_detect_publishers_inner(subscriber, callback, options); - match builder.wait() { - Ok(s) => { - liveliness_subscriber.write(Some(s)); - result::Z_OK - } - Err(e) => { - crate::report_error!("Failed to subscribe to liveliness: {e}"); - liveliness_subscriber.write(None); - result::Z_EGENERIC - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Declares a background subscriber on liveliness tokens of matching publishers. Subscriber callback will be called to process the messages, -/// until the corresponding session is closed or dropped. Only advanced publishers. enabling publisher detection can be detected. -/// @param subscriber: The advanced subscriber instance. -/// @param callback: The callback function that will be called each time a liveliness token status is changed. -/// @param options: The options to be passed to the liveliness subscriber declaration. -/// -/// @return 0 in case of success, negative error values otherwise. -#[no_mangle] -pub extern "C" fn ze_advanced_subscriber_detect_publishers_background( - subscriber: &'static ze_loaned_advanced_subscriber_t, - callback: &'static mut z_moved_closure_sample_t, - options: Option<&'static mut z_liveliness_subscriber_options_t>, -) -> result::z_result_t { - let builder = _advanced_subscriber_detect_publishers_inner(subscriber, callback, options); - match builder.background().wait() { - Ok(_) => result::Z_OK, - Err(e) => { - crate::report_error!("Failed to subscribe to liveliness: {e}"); - result::Z_EGENERIC - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Returns the key expression of the advanced subscriber. -#[no_mangle] -pub extern "C" fn ze_advanced_subscriber_keyexpr( - subscriber: &ze_loaned_advanced_subscriber_t, -) -> &z_loaned_keyexpr_t { - subscriber - .as_rust_type_ref() - .key_expr() - .as_loaned_c_type_ref() -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns the ID of the advanced subscriber. -#[no_mangle] -pub extern "C" fn ze_advanced_subscriber_id( - subscriber: &ze_loaned_advanced_subscriber_t, -) -> z_entity_global_id_t { - subscriber.as_rust_type_ref().id().into_c_type() -} diff --git a/src/close.rs b/src/close.rs deleted file mode 100644 index dd067bf38..000000000 --- a/src/close.rs +++ /dev/null @@ -1,65 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::mem::MaybeUninit; - -use zenoh::{internal::builders::close::NolocalJoinHandle, Wait}; - -use crate::{ - opaque_types::zc_owned_concurrent_close_handle_t, - result::{z_result_t, Z_EIO, Z_OK}, - transmute::{RustTypeRef, RustTypeRefUninit, TakeRustType}, - zc_moved_concurrent_close_handle_t, -}; - -decl_c_type!( - owned(zc_owned_concurrent_close_handle_t, option NolocalJoinHandle>), -); - -/// @brief Blocking wait on close handle to complete. Returns `Z_EIO` if close finishes with error. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn zc_concurrent_close_handle_wait( - handle: &mut zc_moved_concurrent_close_handle_t, -) -> z_result_t { - match handle.take_rust_type().unwrap_unchecked().wait() { - Ok(_) => Z_OK, - Err(e) => { - crate::report_error!("Close error: {}", e); - Z_EIO - } - } -} - -/// @brief Drops the close handle. The concurrent close task will not be interrupted. -#[no_mangle] -pub extern "C" fn zc_concurrent_close_handle_drop(this_: &mut zc_moved_concurrent_close_handle_t) { - let _ = this_.take_rust_type(); -} - -/// @brief Returns ``true`` if concurrent close handle is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn zc_internal_concurrent_close_handle_check( - this_: &zc_owned_concurrent_close_handle_t, -) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @brief Constructs concurrent close handle in its gravestone state. -#[no_mangle] -pub extern "C" fn zc_internal_concurrent_close_handle_null( - this_: &mut MaybeUninit, -) { - this_.as_rust_type_mut_uninit().write(None); -} diff --git a/src/closures/hello_closure.rs b/src/closures/hello_closure.rs deleted file mode 100644 index deee64a0c..000000000 --- a/src/closures/hello_closure.rs +++ /dev/null @@ -1,174 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::mem::MaybeUninit; - -use libc::c_void; - -use crate::{ - transmute::{LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, - z_loaned_hello_t, -}; -/// @brief A hello message-processing closure. -/// -/// A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks. -#[repr(C)] -pub struct z_owned_closure_hello_t { - _context: *mut c_void, - _call: Option, - _drop: Option, -} - -/// Loaned closure. -#[repr(C)] -pub struct z_loaned_closure_hello_t { - _0: usize, - _1: usize, - _2: usize, -} - -/// Moved closure. -#[repr(C)] -pub struct z_moved_closure_hello_t { - _this: z_owned_closure_hello_t, -} - -decl_c_type!( - owned(z_owned_closure_hello_t), - loaned(z_loaned_closure_hello_t), - moved(z_moved_closure_hello_t), -); - -impl Default for z_owned_closure_hello_t { - fn default() -> Self { - z_owned_closure_hello_t { - _context: std::ptr::null_mut(), - _call: None, - _drop: None, - } - } -} -impl z_owned_closure_hello_t { - pub fn is_empty(&self) -> bool { - self._call.is_none() && self._drop.is_none() && self._context.is_null() - } -} -unsafe impl Send for z_owned_closure_hello_t {} -unsafe impl Sync for z_owned_closure_hello_t {} -impl Drop for z_owned_closure_hello_t { - fn drop(&mut self) { - if let Some(drop) = self._drop { - drop(self._context) - } - } -} -/// Constructs a closure in a gravestone state. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_internal_closure_hello_null( - this_: &mut MaybeUninit, -) { - this_.write(z_owned_closure_hello_t::default()); -} -/// Calls the closure. Calling an uninitialized closure is a no-op. -#[no_mangle] -pub extern "C" fn z_closure_hello_call( - closure: &z_loaned_closure_hello_t, - hello: &mut z_loaned_hello_t, -) { - let closure = closure.as_owned_c_type_ref(); - match closure._call { - Some(call) => call(hello, closure._context), - None => { - crate::report_error!("Attempted to call an uninitialized closure!"); - } - } -} -/// Drops the closure. Droping an uninitialized closure is a no-op. -#[no_mangle] -pub extern "C" fn z_closure_hello_drop(this_: &mut z_moved_closure_hello_t) { - let _ = this_.take_rust_type(); -} - -impl From for z_owned_closure_hello_t { - fn from(f: F) -> Self { - let this = Box::into_raw(Box::new(f)) as _; - extern "C" fn call( - response: &mut z_loaned_hello_t, - this: *mut c_void, - ) { - let this = unsafe { &*(this as *const F) }; - this(response) - } - extern "C" fn drop(this: *mut c_void) { - std::mem::drop(unsafe { Box::from_raw(this as *mut F) }) - } - z_owned_closure_hello_t { - _context: this, - _call: Some(call::), - _drop: Some(drop::), - } - } -} - -/// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_closure_hello_check(this_: &z_owned_closure_hello_t) -> bool { - !this_.is_empty() -} - -/// Borrows closure. -#[no_mangle] -pub extern "C" fn z_closure_hello_loan( - closure: &z_owned_closure_hello_t, -) -> &z_loaned_closure_hello_t { - closure.as_loaned_c_type_ref() -} - -/// Mutably norrows closure. -#[no_mangle] -pub extern "C" fn z_closure_hello_loan_mut( - closure: &mut z_owned_closure_hello_t, -) -> &mut z_loaned_closure_hello_t { - closure.as_loaned_c_type_mut() -} - -/// @brief Constructs closure. -/// A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks: -/// -/// Closures are not guaranteed not to be called concurrently. -/// -/// It is guaranteed that: -/// -/// - `call` will never be called once `drop` has started. -/// - `drop` will only be called **once**, and **after every** `call` has ended. -/// - The two previous guarantees imply that `call` and `drop` are never called concurrently. -/// -/// @param this_: uninitialized memory location where new closure will be constructed. -/// @param call: a closure body. -/// @param drop: an optional function to be called once on closure drop. -/// @param context: closure context. -#[no_mangle] -pub extern "C" fn z_closure_hello( - this: &mut MaybeUninit, - call: Option, - drop: Option, - context: *mut c_void, -) { - this.write(z_owned_closure_hello_t { - _context: context, - _call: call, - _drop: drop, - }); -} diff --git a/src/closures/log_closure.rs b/src/closures/log_closure.rs deleted file mode 100644 index cc198a72d..000000000 --- a/src/closures/log_closure.rs +++ /dev/null @@ -1,215 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::mem::MaybeUninit; - -use libc::c_void; - -use crate::{ - transmute::{LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, - z_loaned_string_t, -}; - -#[repr(C)] -#[derive(PartialOrd, PartialEq)] -/// Severity level of Zenoh log message. -pub enum zc_log_severity_t { - /// The `trace` level. - /// - /// Designates very low priority, often extremely verbose, information. - TRACE = 0, - /// The "debug" level. - /// - /// Designates lower priority information. - DEBUG = 1, - /// The "info" level. - /// - /// Designates useful information. - INFO = 2, - /// The "warn" level. - /// - /// Designates hazardous situations. - WARN = 3, - /// The "error" level. - /// - /// Designates very serious errors. - ERROR = 4, -} - -impl From for tracing::Level { - fn from(value: zc_log_severity_t) -> Self { - match value { - zc_log_severity_t::TRACE => tracing::Level::TRACE, - zc_log_severity_t::DEBUG => tracing::Level::DEBUG, - zc_log_severity_t::INFO => tracing::Level::INFO, - zc_log_severity_t::WARN => tracing::Level::WARN, - zc_log_severity_t::ERROR => tracing::Level::ERROR, - } - } -} - -impl From for zc_log_severity_t { - fn from(value: tracing::Level) -> Self { - match value { - tracing::Level::TRACE => zc_log_severity_t::TRACE, - tracing::Level::DEBUG => zc_log_severity_t::DEBUG, - tracing::Level::INFO => zc_log_severity_t::INFO, - tracing::Level::WARN => zc_log_severity_t::WARN, - tracing::Level::ERROR => zc_log_severity_t::ERROR, - } - } -} -/// @brief A log-processing closure. -/// -/// A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks. -#[repr(C)] -pub struct zc_owned_closure_log_t { - _context: *mut libc::c_void, - _call: Option< - extern "C" fn( - severity: zc_log_severity_t, - msg: &z_loaned_string_t, - context: *mut libc::c_void, - ), - >, - _drop: Option, -} - -/// Loaned closure. -#[repr(C)] -pub struct zc_loaned_closure_log_t { - _0: usize, - _1: usize, - _2: usize, -} - -/// Moved closure. -#[repr(C)] -pub struct zc_moved_closure_log_t { - _this: zc_owned_closure_log_t, -} - -decl_c_type!( - owned(zc_owned_closure_log_t), - loaned(zc_loaned_closure_log_t), - moved(zc_moved_closure_log_t), -); - -impl Default for zc_owned_closure_log_t { - fn default() -> Self { - zc_owned_closure_log_t { - _context: std::ptr::null_mut(), - _call: None, - _drop: None, - } - } -} - -impl zc_owned_closure_log_t { - pub fn empty() -> Self { - zc_owned_closure_log_t { - _context: std::ptr::null_mut(), - _call: None, - _drop: None, - } - } - - pub fn is_empty(&self) -> bool { - self._call.is_none() && self._drop.is_none() && self._context.is_null() - } -} -unsafe impl Send for zc_owned_closure_log_t {} -unsafe impl Sync for zc_owned_closure_log_t {} -impl Drop for zc_owned_closure_log_t { - fn drop(&mut self) { - if let Some(drop) = self._drop { - drop(self._context) - } - } -} -/// Constructs a closure in a gravestone state. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn zc_internal_closure_log_null( - this_: &mut MaybeUninit, -) { - this_.write(zc_owned_closure_log_t::default()); -} -/// Calls the closure. Calling an uninitialized closure is a no-op. -#[no_mangle] -pub extern "C" fn zc_closure_log_call( - closure: &zc_loaned_closure_log_t, - severity: zc_log_severity_t, - msg: &z_loaned_string_t, -) { - let closure = closure.as_owned_c_type_ref(); - match closure._call { - Some(call) => call(severity, msg, closure._context), - None => { - crate::report_error!("Attempted to call an uninitialized closure!"); - } - } -} -/// Drops the closure. Droping an uninitialized closure is a no-op. -#[no_mangle] -pub extern "C" fn zc_closure_log_drop(closure_: &mut zc_moved_closure_log_t) { - let _ = closure_.take_rust_type(); -} - -/// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn zc_internal_closure_log_check(this_: &zc_owned_closure_log_t) -> bool { - !this_.is_empty() -} - -/// Borrows closure. -#[no_mangle] -pub extern "C" fn zc_closure_log_loan( - closure: &zc_owned_closure_log_t, -) -> &zc_loaned_closure_log_t { - closure.as_loaned_c_type_ref() -} - -/// @brief Constructs closure. -/// -/// Closures are not guaranteed not to be called concurrently. -/// -/// It is guaranteed that: -/// - `call` will never be called once `drop` has started. -/// - `drop` will only be called **once**, and **after every** `call` has ended. -/// - The two previous guarantees imply that `call` and `drop` are never called concurrently. -/// -/// @param this_: uninitialized memory location where new closure will be constructed. -/// @param call: a closure body. -/// @param drop: an optional function to be called once on closure drop. -/// @param context: closure context. -#[no_mangle] -pub extern "C" fn zc_closure_log( - this: &mut MaybeUninit, - call: Option< - extern "C" fn( - severity: zc_log_severity_t, - msg: &z_loaned_string_t, - context: *mut libc::c_void, - ), - >, - drop: Option, - context: *mut c_void, -) { - this.write(zc_owned_closure_log_t { - _context: context, - _call: call, - _drop: drop, - }); -} diff --git a/src/closures/matching_status_closure.rs b/src/closures/matching_status_closure.rs deleted file mode 100644 index 15e2fc64f..000000000 --- a/src/closures/matching_status_closure.rs +++ /dev/null @@ -1,177 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// -use std::mem::MaybeUninit; - -use libc::c_void; - -use crate::{ - transmute::{LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, - z_matching_status_t, -}; -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A matching status-processing closure. -/// -/// A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks. -#[repr(C)] -pub struct z_owned_closure_matching_status_t { - _context: *mut c_void, - _call: Option, - _drop: Option, -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Loaned closure. -#[repr(C)] -pub struct z_loaned_closure_matching_status_t { - _0: usize, - _1: usize, - _2: usize, -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Moved closure. -#[repr(C)] -pub struct z_moved_closure_matching_status_t { - _this: z_owned_closure_matching_status_t, -} - -decl_c_type!( - owned(z_owned_closure_matching_status_t), - loaned(z_loaned_closure_matching_status_t), - moved(z_moved_closure_matching_status_t), -); - -impl Default for z_owned_closure_matching_status_t { - fn default() -> Self { - z_owned_closure_matching_status_t { - _context: std::ptr::null_mut(), - _call: None, - _drop: None, - } - } -} - -impl z_owned_closure_matching_status_t { - pub fn is_empty(&self) -> bool { - self._call.is_none() && self._drop.is_none() && self._context.is_null() - } -} -unsafe impl Send for z_owned_closure_matching_status_t {} -unsafe impl Sync for z_owned_closure_matching_status_t {} -impl Drop for z_owned_closure_matching_status_t { - fn drop(&mut self) { - if let Some(drop) = self._drop { - drop(self._context) - } - } -} -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs a null value of 'z_owned_closure_matching_status_t' type -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_internal_closure_matching_status_null( - this: &mut MaybeUninit, -) { - this.write(z_owned_closure_matching_status_t::default()); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_closure_matching_status_check( - this: &z_owned_closure_matching_status_t, -) -> bool { - !this.is_empty() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Calls the closure. Calling an uninitialized closure is a no-op. -#[no_mangle] -pub extern "C" fn z_closure_matching_status_call( - closure: &z_loaned_closure_matching_status_t, - mathing_status: &z_matching_status_t, -) { - let closure = closure.as_owned_c_type_ref(); - match closure._call { - Some(call) => call(mathing_status, closure._context), - None => { - crate::report_error!("Attempted to call an uninitialized closure!"); - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Drops the closure, resetting it to its gravestone state. Droping an uninitialized closure is a no-op. -#[no_mangle] -pub extern "C" fn z_closure_matching_status_drop(closure_: &mut z_moved_closure_matching_status_t) { - let _ = closure_.take_rust_type(); -} - -impl From for z_owned_closure_matching_status_t { - fn from(f: F) -> Self { - let this = Box::into_raw(Box::new(f)) as _; - extern "C" fn call( - response: &z_matching_status_t, - this: *mut c_void, - ) { - let this = unsafe { &*(this as *const F) }; - this(response) - } - extern "C" fn drop(this: *mut c_void) { - std::mem::drop(unsafe { Box::from_raw(this as *mut F) }) - } - z_owned_closure_matching_status_t { - _context: this, - _call: Some(call::), - _drop: Some(drop::), - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Borrows closure. -#[no_mangle] -pub extern "C" fn z_closure_matching_status_loan( - closure: &z_owned_closure_matching_status_t, -) -> &z_loaned_closure_matching_status_t { - closure.as_loaned_c_type_ref() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// -/// Closures are not guaranteed not to be called concurrently. -/// -/// It is guaranteed that: -/// - `call` will never be called once `drop` has started. -/// - `drop` will only be called **once**, and **after every** `call` has ended. -/// - The two previous guarantees imply that `call` and `drop` are never called concurrently. -/// -/// @brief Constructs closure. -/// @param this_: uninitialized memory location where new closure will be constructed. -/// @param call: a closure body. -/// @param drop: an optional function to be called once on closure drop. -/// @param context: closure context. -#[no_mangle] -pub extern "C" fn z_closure_matching_status( - this: &mut MaybeUninit, - call: Option, - drop: Option, - context: *mut c_void, -) { - this.write(z_owned_closure_matching_status_t { - _context: context, - _call: call, - _drop: drop, - }); -} diff --git a/src/closures/miss_closure.rs b/src/closures/miss_closure.rs deleted file mode 100644 index 5ae06dc5d..000000000 --- a/src/closures/miss_closure.rs +++ /dev/null @@ -1,172 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// -use std::mem::MaybeUninit; - -use libc::c_void; - -use crate::{ - transmute::{LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, - ze_miss_t, -}; -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A sample miss-processing closure. -/// -/// A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks. -#[repr(C)] -pub struct ze_owned_closure_miss_t { - _context: *mut c_void, - _call: Option, - _drop: Option, -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Loaned closure. -#[repr(C)] -pub struct ze_loaned_closure_miss_t { - _0: usize, - _1: usize, - _2: usize, -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Moved closure. -#[repr(C)] -pub struct ze_moved_closure_miss_t { - _this: ze_owned_closure_miss_t, -} - -decl_c_type!( - owned(ze_owned_closure_miss_t), - loaned(ze_loaned_closure_miss_t), - moved(ze_moved_closure_miss_t), -); - -impl Default for ze_owned_closure_miss_t { - fn default() -> Self { - ze_owned_closure_miss_t { - _context: std::ptr::null_mut(), - _call: None, - _drop: None, - } - } -} - -impl ze_owned_closure_miss_t { - pub fn is_empty(&self) -> bool { - self._call.is_none() && self._drop.is_none() && self._context.is_null() - } -} -unsafe impl Send for ze_owned_closure_miss_t {} -unsafe impl Sync for ze_owned_closure_miss_t {} -impl Drop for ze_owned_closure_miss_t { - fn drop(&mut self) { - if let Some(drop) = self._drop { - drop(self._context) - } - } -} -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs a null value of 'ze_owned_closure_miss_t' type -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_internal_closure_miss_null( - this: &mut MaybeUninit, -) { - this.write(ze_owned_closure_miss_t::default()); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn ze_internal_closure_miss_check(this: &ze_owned_closure_miss_t) -> bool { - !this.is_empty() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Calls the closure. Calling an uninitialized closure is a no-op. -#[no_mangle] -pub extern "C" fn ze_closure_miss_call( - closure: &ze_loaned_closure_miss_t, - mathing_status: &ze_miss_t, -) { - let closure = closure.as_owned_c_type_ref(); - match closure._call { - Some(call) => call(mathing_status, closure._context), - None => { - crate::report_error!("Attempted to call an uninitialized closure!"); - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Drops the closure, resetting it to its gravestone state. Droping an uninitialized closure is a no-op. -#[no_mangle] -pub extern "C" fn ze_closure_miss_drop(closure_: &mut ze_moved_closure_miss_t) { - let _ = closure_.take_rust_type(); -} - -impl From for ze_owned_closure_miss_t { - fn from(f: F) -> Self { - let this = Box::into_raw(Box::new(f)) as _; - extern "C" fn call(response: &ze_miss_t, this: *mut c_void) { - let this = unsafe { &*(this as *const F) }; - this(response) - } - extern "C" fn drop(this: *mut c_void) { - std::mem::drop(unsafe { Box::from_raw(this as *mut F) }) - } - ze_owned_closure_miss_t { - _context: this, - _call: Some(call::), - _drop: Some(drop::), - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Borrows closure. -#[no_mangle] -pub extern "C" fn ze_closure_miss_loan( - closure: &ze_owned_closure_miss_t, -) -> &ze_loaned_closure_miss_t { - closure.as_loaned_c_type_ref() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// -/// Closures are not guaranteed not to be called concurrently. -/// -/// It is guaranteed that: -/// - `call` will never be called once `drop` has started. -/// - `drop` will only be called **once**, and **after every** `call` has ended. -/// - The two previous guarantees imply that `call` and `drop` are never called concurrently. -/// -/// @brief Constructs closure. -/// @param this_: uninitialized memory location where new closure will be constructed. -/// @param call: a closure body. -/// @param drop: an optional function to be called once on closure drop. -/// @param context: closure context. -#[no_mangle] -pub extern "C" fn ze_closure_miss( - this: &mut MaybeUninit, - call: Option, - drop: Option, - context: *mut c_void, -) { - this.write(ze_owned_closure_miss_t { - _context: context, - _call: call, - _drop: drop, - }); -} diff --git a/src/closures/mod.rs b/src/closures/mod.rs deleted file mode 100644 index 95d460c06..000000000 --- a/src/closures/mod.rs +++ /dev/null @@ -1,47 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// -pub use sample_closure::*; -mod sample_closure; - -pub use query_closure::*; -mod query_closure; - -pub use reply_closure::*; -mod reply_closure; - -pub use zenohid_closure::*; -mod zenohid_closure; - -pub use response_channel::*; -mod response_channel; - -pub use query_channel::*; -mod query_channel; - -pub use sample_channel::*; -mod sample_channel; - -pub use hello_closure::*; -mod hello_closure; - -pub use log_closure::*; -mod log_closure; - -pub use matching_status_closure::*; -mod matching_status_closure; - -#[cfg(feature = "unstable")] -pub use miss_closure::*; -#[cfg(feature = "unstable")] -mod miss_closure; diff --git a/src/closures/query_channel.rs b/src/closures/query_channel.rs deleted file mode 100644 index abad54c1a..000000000 --- a/src/closures/query_channel.rs +++ /dev/null @@ -1,258 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::{mem::MaybeUninit, sync::Arc}; - -use libc::c_void; -use zenoh::{ - handlers::{self, FifoChannelHandler, IntoHandler, RingChannelHandler}, - query::Query, -}; - -pub use crate::opaque_types::{ - z_loaned_fifo_handler_query_t, z_moved_fifo_handler_query_t, z_owned_fifo_handler_query_t, -}; -use crate::{ - result::{self, z_result_t}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_loaned_query_t, z_owned_closure_query_t, z_owned_query_t, -}; -decl_c_type!( - owned(z_owned_fifo_handler_query_t, option FifoChannelHandler ), - loaned(z_loaned_fifo_handler_query_t), -); - -/// Drops the handler and resets it to a gravestone state. -#[no_mangle] -pub extern "C" fn z_fifo_handler_query_drop(this_: &mut z_moved_fifo_handler_query_t) { - let _ = this_.take_rust_type(); -} - -/// Constructs a handler in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_fifo_handler_query_null( - this_: &mut MaybeUninit, -) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_fifo_handler_query_check( - this_: &z_owned_fifo_handler_query_t, -) -> bool { - this_.as_rust_type_ref().is_some() -} - -extern "C" fn __z_handler_query_send(query: &mut z_loaned_query_t, context: *mut c_void) { - unsafe { - let f = (context as *mut std::sync::Arc) - .as_mut() - .unwrap_unchecked(); - let owned_ref: &mut Option = std::mem::transmute(query); - (f)(std::mem::take(owned_ref).unwrap_unchecked()); - } -} - -extern "C" fn __z_handler_query_drop(context: *mut c_void) { - unsafe { - let f = Box::from_raw(context as *mut Arc); - std::mem::drop(f); - } -} - -/// Constructs send and recieve ends of the fifo channel -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_fifo_channel_query_new( - callback: &mut MaybeUninit, - handler: &mut MaybeUninit, - capacity: usize, -) { - let fifo = handlers::FifoChannel::new(capacity); - let (cb, h) = fifo.into_handler(); - let cb_ptr = Box::into_raw(Box::new(cb)) as *mut libc::c_void; - handler.as_rust_type_mut_uninit().write(Some(h)); - callback.write(z_owned_closure_query_t { - _call: Some(__z_handler_query_send), - _context: cb_ptr, - _drop: Some(__z_handler_query_drop), - }); -} - -/// Borrows handler. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_fifo_handler_query_loan( - this: &z_owned_fifo_handler_query_t, -) -> &z_loaned_fifo_handler_query_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// Returns query from the fifo buffer. If there are no more pending queries will block until next query is received, or until -/// the channel is dropped (normally when Queryable is dropped). -/// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state), -/// `Z_CHANNEL_NODATA` if the channel is still alive, but its buffer is empty (the query will be in the gravestone state). -#[no_mangle] -pub extern "C" fn z_fifo_handler_query_recv( - this: &z_loaned_fifo_handler_query_t, - query: &mut MaybeUninit, -) -> z_result_t { - match this.as_rust_type_ref().recv() { - Ok(q) => { - query.as_rust_type_mut_uninit().write(Some(q)); - result::Z_OK - } - Err(_) => { - query.as_rust_type_mut_uninit().write(None); - result::Z_CHANNEL_DISCONNECTED - } - } -} - -/// Returns query from the fifo buffer. If there are no more pending queries will return immediately (with query set to its gravestone state). -/// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state), -/// `Z_CHANNEL_NODATA` if the channel is still alive, but its buffer is empty (the query will be in the gravestone state). -#[no_mangle] -pub extern "C" fn z_fifo_handler_query_try_recv( - this: &z_loaned_fifo_handler_query_t, - query: &mut MaybeUninit, -) -> z_result_t { - match this.as_rust_type_ref().try_recv() { - Ok(Some(q)) => { - query.as_rust_type_mut_uninit().write(Some(q)); - result::Z_OK - } - Ok(None) => { - query.as_rust_type_mut_uninit().write(None); - result::Z_CHANNEL_NODATA - } - Err(_) => { - query.as_rust_type_mut_uninit().write(None); - result::Z_CHANNEL_DISCONNECTED - } - } -} - -pub use crate::opaque_types::{ - z_loaned_ring_handler_query_t, z_moved_ring_handler_query_t, z_owned_ring_handler_query_t, -}; -decl_c_type!( - owned( - z_owned_ring_handler_query_t, - option RingChannelHandler, - ), - loaned(z_loaned_ring_handler_query_t), -); - -/// Drops the handler and resets it to a gravestone state. -#[no_mangle] -pub extern "C" fn z_ring_handler_query_drop(this_: &mut z_moved_ring_handler_query_t) { - let _ = this_.take_rust_type(); -} - -/// Constructs a handler in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_ring_handler_query_null( - this_: &mut MaybeUninit, -) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_ring_handler_query_check( - this_: &z_owned_ring_handler_query_t, -) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// Constructs send and recieve ends of the ring channel -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_ring_channel_query_new( - callback: &mut MaybeUninit, - handler: &mut MaybeUninit, - capacity: usize, -) { - let ring = handlers::RingChannel::new(capacity); - let (cb, h) = ring.into_handler(); - let cb_ptr = Box::into_raw(Box::new(cb)) as *mut libc::c_void; - handler.as_rust_type_mut_uninit().write(Some(h)); - callback.write(z_owned_closure_query_t { - _call: Some(__z_handler_query_send), - _context: cb_ptr, - _drop: Some(__z_handler_query_drop), - }); -} - -/// Borrows handler. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_ring_handler_query_loan( - this: &z_owned_ring_handler_query_t, -) -> &z_loaned_ring_handler_query_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// Returns query from the ring buffer. If there are no more pending queries will block until next query is received, or until -/// the channel is dropped (normally when Queryable is dropped). -/// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state). -#[no_mangle] -pub extern "C" fn z_ring_handler_query_recv( - this: &z_loaned_ring_handler_query_t, - query: &mut MaybeUninit, -) -> z_result_t { - match this.as_rust_type_ref().recv() { - Ok(q) => { - query.as_rust_type_mut_uninit().write(Some(q)); - result::Z_OK - } - Err(_) => { - query.as_rust_type_mut_uninit().write(None); - result::Z_CHANNEL_DISCONNECTED - } - } -} - -/// Returns query from the ring buffer. If there are no more pending queries will return immediately (with query set to its gravestone state). -/// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the query will be in the gravestone state), -/// Z_CHANNEL_NODATA if the channel is still alive, but its buffer is empty (the query will be in the gravestone state). -#[no_mangle] -pub extern "C" fn z_ring_handler_query_try_recv( - this: &z_loaned_ring_handler_query_t, - query: &mut MaybeUninit, -) -> z_result_t { - match this.as_rust_type_ref().try_recv() { - Ok(q) => { - let r = if q.is_some() { - result::Z_OK - } else { - result::Z_CHANNEL_NODATA - }; - query.as_rust_type_mut_uninit().write(q); - r - } - Err(_) => { - query.as_rust_type_mut_uninit().write(None); - result::Z_CHANNEL_DISCONNECTED - } - } -} diff --git a/src/closures/query_closure.rs b/src/closures/query_closure.rs deleted file mode 100644 index 9ebd30557..000000000 --- a/src/closures/query_closure.rs +++ /dev/null @@ -1,172 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::mem::MaybeUninit; - -use libc::c_void; - -use crate::{ - transmute::{LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, - z_loaned_query_t, -}; -/// @brief A query-processing closure. -/// -/// A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks. -#[repr(C)] -pub struct z_owned_closure_query_t { - pub _context: *mut c_void, - pub _call: Option, - pub _drop: Option, -} - -/// Loaned closure. -#[repr(C)] -pub struct z_loaned_closure_query_t { - _0: usize, - _1: usize, - _2: usize, -} - -/// Moved closure. -#[repr(C)] -pub struct z_moved_closure_query_t { - _this: z_owned_closure_query_t, -} - -decl_c_type!( - owned(z_owned_closure_query_t), - loaned(z_loaned_closure_query_t), - moved(z_moved_closure_query_t), -); - -impl Default for z_owned_closure_query_t { - fn default() -> Self { - z_owned_closure_query_t { - _context: std::ptr::null_mut(), - _call: None, - _drop: None, - } - } -} - -impl z_owned_closure_query_t { - pub fn is_empty(&self) -> bool { - self._call.is_none() && self._drop.is_none() && self._context.is_null() - } -} -unsafe impl Send for z_owned_closure_query_t {} -unsafe impl Sync for z_owned_closure_query_t {} -impl Drop for z_owned_closure_query_t { - fn drop(&mut self) { - if let Some(drop) = self._drop { - drop(self._context) - } - } -} -/// Constructs a closure in its gravestone state. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_internal_closure_query_null( - this_: &mut MaybeUninit, -) { - this_.write(z_owned_closure_query_t::default()); -} - -/// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_closure_query_check(this_: &z_owned_closure_query_t) -> bool { - !this_.is_empty() -} - -/// Calls the closure. Calling an uninitialized closure is a no-op. -#[no_mangle] -pub extern "C" fn z_closure_query_call( - closure: &z_loaned_closure_query_t, - query: &mut z_loaned_query_t, -) { - let closure = closure.as_owned_c_type_ref(); - match closure._call { - Some(call) => call(query, closure._context), - None => crate::report_error!("Attempted to call an uninitialized closure!"), - } -} -/// Drops the closure, resetting it to its gravestone state. -#[no_mangle] -pub extern "C" fn z_closure_query_drop(closure_: &mut z_moved_closure_query_t) { - let _ = closure_.take_rust_type(); -} - -impl From for z_owned_closure_query_t { - fn from(f: F) -> Self { - let this = Box::into_raw(Box::new(f)) as _; - extern "C" fn call( - query: &mut z_loaned_query_t, - this: *mut c_void, - ) { - let this = unsafe { &*(this as *const F) }; - this(query) - } - extern "C" fn drop(this: *mut c_void) { - std::mem::drop(unsafe { Box::from_raw(this as *mut F) }) - } - z_owned_closure_query_t { - _context: this, - _call: Some(call::), - _drop: Some(drop::), - } - } -} - -/// Borrows closure. -#[no_mangle] -pub extern "C" fn z_closure_query_loan( - closure: &z_owned_closure_query_t, -) -> &z_loaned_closure_query_t { - closure.as_loaned_c_type_ref() -} - -/// Mutably borrows closure. -#[no_mangle] -pub extern "C" fn z_closure_query_loan_mut( - closure: &mut z_owned_closure_query_t, -) -> &mut z_loaned_closure_query_t { - closure.as_loaned_c_type_mut() -} - -/// @brief Constructs closure. -/// -/// Closures are not guaranteed not to be called concurrently. -/// -/// It is guaranteed that: -/// - `call` will never be called once `drop` has started. -/// - `drop` will only be called **once**, and **after every** `call` has ended. -/// - The two previous guarantees imply that `call` and `drop` are never called concurrently. -/// -/// @param this_: uninitialized memory location where new closure will be constructed. -/// @param call: a closure body. -/// @param drop: an optional function to be called once on closure drop. -/// @param context: closure context. -#[no_mangle] -pub extern "C" fn z_closure_query( - this: &mut MaybeUninit, - call: Option, - drop: Option, - context: *mut c_void, -) { - this.write(z_owned_closure_query_t { - _context: context, - _call: call, - _drop: drop, - }); -} diff --git a/src/closures/reply_closure.rs b/src/closures/reply_closure.rs deleted file mode 100644 index 503d55dd2..000000000 --- a/src/closures/reply_closure.rs +++ /dev/null @@ -1,176 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::mem::MaybeUninit; - -use libc::c_void; - -use crate::{ - transmute::{LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, - z_loaned_reply_t, -}; - -/// @brief A reply-processing closure. -/// -/// A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks. -#[repr(C)] -pub struct z_owned_closure_reply_t { - pub _context: *mut c_void, - pub(crate) _call: Option, - pub _drop: Option, -} - -/// Loaned closure. -#[repr(C)] -pub struct z_loaned_closure_reply_t { - _0: usize, - _1: usize, - _2: usize, -} - -/// Moved closure. -#[repr(C)] -#[derive(Default)] -pub struct z_moved_closure_reply_t { - pub _this: z_owned_closure_reply_t, -} - -decl_c_type!( - owned(z_owned_closure_reply_t), - loaned(z_loaned_closure_reply_t), - moved(z_moved_closure_reply_t), -); - -impl Default for z_owned_closure_reply_t { - fn default() -> Self { - z_owned_closure_reply_t { - _context: std::ptr::null_mut(), - _call: None, - _drop: None, - } - } -} - -impl z_owned_closure_reply_t { - pub(crate) fn is_empty(&self) -> bool { - self._call.is_none() && self._drop.is_none() && self._context.is_null() - } -} -unsafe impl Send for z_owned_closure_reply_t {} -unsafe impl Sync for z_owned_closure_reply_t {} -impl Drop for z_owned_closure_reply_t { - fn drop(&mut self) { - if let Some(drop) = self._drop { - drop(self._context) - } - } -} -/// Constructs a closure int its gravestone state. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_internal_closure_reply_null( - this_: &mut MaybeUninit, -) { - this_.write(z_owned_closure_reply_t::default()); -} - -/// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_closure_reply_check(this_: &z_owned_closure_reply_t) -> bool { - !this_.is_empty() -} - -/// Calls the closure. Calling an uninitialized closure is a no-op. -#[no_mangle] -pub extern "C" fn z_closure_reply_call( - closure: &z_loaned_closure_reply_t, - reply: &mut z_loaned_reply_t, -) { - let closure = closure.as_owned_c_type_ref(); - match closure._call { - Some(call) => call(reply, closure._context), - None => { - crate::report_error!("Attempted to call an uninitialized closure!"); - } - } -} -/// Drops the closure, resetting it to its gravestone state. Droping an uninitialized closure is a no-op. -#[no_mangle] -pub extern "C" fn z_closure_reply_drop(closure_: &mut z_moved_closure_reply_t) { - let _ = closure_.take_rust_type(); -} - -impl From for z_owned_closure_reply_t { - fn from(f: F) -> Self { - let this = Box::into_raw(Box::new(f)) as _; - extern "C" fn call( - response: &mut z_loaned_reply_t, - this: *mut c_void, - ) { - let this = unsafe { &*(this as *const F) }; - this(response); - } - extern "C" fn drop(this: *mut c_void) { - std::mem::drop(unsafe { Box::from_raw(this as *mut F) }) - } - z_owned_closure_reply_t { - _context: this, - _call: Some(call::), - _drop: Some(drop::), - } - } -} - -/// Borrows closure. -#[no_mangle] -pub extern "C" fn z_closure_reply_loan( - closure: &z_owned_closure_reply_t, -) -> &z_loaned_closure_reply_t { - closure.as_loaned_c_type_ref() -} - -/// Mutably borrows closure. -#[no_mangle] -pub extern "C" fn z_closure_reply_loan_mut( - closure: &mut z_owned_closure_reply_t, -) -> &mut z_loaned_closure_reply_t { - closure.as_loaned_c_type_mut() -} - -/// @brief Constructs closure. -/// -/// Closures are not guaranteed not to be called concurrently. -/// -/// It is guaranteed that: -/// - `call` will never be called once `drop` has started. -/// - `drop` will only be called **once**, and **after every** `call` has ended. -/// - The two previous guarantees imply that `call` and `drop` are never called concurrently. -/// -/// @param this_: uninitialized memory location where new closure will be constructed. -/// @param call: a closure body. -/// @param drop: an optional function to be called once on closure drop. -/// @param context: closure context. -#[no_mangle] -pub extern "C" fn z_closure_reply( - this: &mut MaybeUninit, - call: Option, - drop: Option, - context: *mut c_void, -) { - this.write(z_owned_closure_reply_t { - _context: context, - _call: call, - _drop: drop, - }); -} diff --git a/src/closures/response_channel.rs b/src/closures/response_channel.rs deleted file mode 100644 index 1b6dc98e2..000000000 --- a/src/closures/response_channel.rs +++ /dev/null @@ -1,254 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::{mem::MaybeUninit, sync::Arc}; - -use libc::c_void; -use zenoh::{ - handlers::{self, FifoChannelHandler, IntoHandler, RingChannelHandler}, - query::Reply, -}; - -pub use crate::opaque_types::{ - z_loaned_fifo_handler_reply_t, z_moved_fifo_handler_reply_t, z_owned_fifo_handler_reply_t, -}; -use crate::{ - result::{self, z_result_t}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_loaned_reply_t, z_owned_closure_reply_t, z_owned_reply_t, -}; -decl_c_type!( - owned(z_owned_fifo_handler_reply_t, option FifoChannelHandler), - loaned(z_loaned_fifo_handler_reply_t), -); - -/// Drops the handler and resets it to a gravestone state. -#[no_mangle] -pub extern "C" fn z_fifo_handler_reply_drop(this_: &mut z_moved_fifo_handler_reply_t) { - let _ = this_.take_rust_type(); -} - -/// Constructs a handler in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_fifo_handler_reply_null( - this_: &mut MaybeUninit, -) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_fifo_handler_reply_check( - this_: &z_owned_fifo_handler_reply_t, -) -> bool { - this_.as_rust_type_ref().is_some() -} - -extern "C" fn __z_handler_reply_send(reply: &mut z_loaned_reply_t, context: *mut c_void) { - unsafe { - let f = (context as *mut std::sync::Arc) - .as_mut() - .unwrap_unchecked(); - let owned_ref: &mut Option = std::mem::transmute(reply); - (f)(std::mem::take(owned_ref).unwrap_unchecked()); - } -} - -extern "C" fn __z_handler_reply_drop(context: *mut c_void) { - unsafe { - let f = Box::from_raw(context as *mut Arc); - std::mem::drop(f); - } -} - -/// Constructs send and recieve ends of the fifo channel -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_fifo_channel_reply_new( - callback: &mut MaybeUninit, - handler: &mut MaybeUninit, - capacity: usize, -) { - let fifo = handlers::FifoChannel::new(capacity); - let (cb, h) = fifo.into_handler(); - let cb_ptr = Box::into_raw(Box::new(cb)) as *mut libc::c_void; - handler.as_rust_type_mut_uninit().write(Some(h)); - callback.write(z_owned_closure_reply_t { - _call: Some(__z_handler_reply_send), - _context: cb_ptr, - _drop: Some(__z_handler_reply_drop), - }); -} - -/// Borrows handler. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_fifo_handler_reply_loan( - this: &z_owned_fifo_handler_reply_t, -) -> &z_loaned_fifo_handler_reply_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// Returns reply from the fifo buffer. If there are no more pending replies will block until next reply is received, or until -/// the channel is dropped (normally when all replies are received). -/// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the reply will be in the gravestone state). -#[no_mangle] -pub extern "C" fn z_fifo_handler_reply_recv( - this: &z_loaned_fifo_handler_reply_t, - reply: &mut MaybeUninit, -) -> z_result_t { - match this.as_rust_type_ref().recv() { - Ok(q) => { - reply.as_rust_type_mut_uninit().write(Some(q)); - result::Z_OK - } - Err(_) => { - reply.as_rust_type_mut_uninit().write(None); - result::Z_CHANNEL_DISCONNECTED - } - } -} - -/// Returns reply from the fifo buffer. If there are no more pending replies will return immediately (with reply set to its gravestone state). -/// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the reply will be in the gravestone state), -/// `Z_CHANNEL_NODATA` if the channel is still alive, but its buffer is empty (the reply will be in the gravestone state). -#[no_mangle] -pub extern "C" fn z_fifo_handler_reply_try_recv( - this: &z_loaned_fifo_handler_reply_t, - reply: &mut MaybeUninit, -) -> z_result_t { - match this.as_rust_type_ref().try_recv() { - Ok(Some(q)) => { - reply.as_rust_type_mut_uninit().write(Some(q)); - result::Z_OK - } - Ok(None) => { - reply.as_rust_type_mut_uninit().write(None); - result::Z_CHANNEL_NODATA - } - Err(_) => { - reply.as_rust_type_mut_uninit().write(None); - result::Z_CHANNEL_DISCONNECTED - } - } -} - -pub use crate::opaque_types::{ - z_loaned_ring_handler_reply_t, z_moved_ring_handler_reply_t, z_owned_ring_handler_reply_t, -}; -decl_c_type!( - owned(z_owned_ring_handler_reply_t, option RingChannelHandler), - loaned(z_loaned_ring_handler_reply_t), -); - -/// Drops the handler and resets it to a gravestone state. -#[no_mangle] -pub extern "C" fn z_ring_handler_reply_drop(this_: &mut z_moved_ring_handler_reply_t) { - let _ = this_.take_rust_type(); -} - -/// Constructs a handler in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_ring_handler_reply_null( - this_: &mut MaybeUninit, -) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_ring_handler_reply_check( - this_: &z_owned_ring_handler_reply_t, -) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// Constructs send and recieve ends of the ring channel -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_ring_channel_reply_new( - callback: &mut MaybeUninit, - handler: &mut MaybeUninit, - capacity: usize, -) { - let ring = handlers::RingChannel::new(capacity); - let (cb, h) = ring.into_handler(); - let cb_ptr = Box::into_raw(Box::new(cb)) as *mut libc::c_void; - handler.as_rust_type_mut_uninit().write(Some(h)); - callback.write(z_owned_closure_reply_t { - _call: Some(__z_handler_reply_send), - _context: cb_ptr, - _drop: Some(__z_handler_reply_drop), - }); -} - -/// Borrows handler. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_ring_handler_reply_loan( - this: &z_owned_ring_handler_reply_t, -) -> &z_loaned_ring_handler_reply_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// Returns reply from the ring buffer. If there are no more pending replies will block until next reply is received, or until -/// the channel is dropped (normally when all replies are received). -/// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the reply will be in the gravestone state). -#[no_mangle] -pub extern "C" fn z_ring_handler_reply_recv( - this: &z_loaned_ring_handler_reply_t, - reply: &mut MaybeUninit, -) -> z_result_t { - match this.as_rust_type_ref().recv() { - Ok(q) => { - reply.as_rust_type_mut_uninit().write(Some(q)); - result::Z_OK - } - Err(_) => { - reply.as_rust_type_mut_uninit().write(None); - result::Z_CHANNEL_DISCONNECTED - } - } -} - -/// Returns reply from the ring buffer. If there are no more pending replies will return immediately (with reply set to its gravestone state). -/// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the reply will be in the gravestone state), -/// `Z_CHANNEL_NODATA` if the channel is still alive, but its buffer is empty (the reply will be in the gravestone state). -#[no_mangle] -pub extern "C" fn z_ring_handler_reply_try_recv( - this: &z_loaned_ring_handler_reply_t, - reply: &mut MaybeUninit, -) -> z_result_t { - match this.as_rust_type_ref().try_recv() { - Ok(q) => { - let r = if q.is_some() { - result::Z_OK - } else { - result::Z_CHANNEL_NODATA - }; - reply.as_rust_type_mut_uninit().write(q); - r - } - Err(_) => { - reply.as_rust_type_mut_uninit().write(None); - result::Z_CHANNEL_DISCONNECTED - } - } -} diff --git a/src/closures/sample_channel.rs b/src/closures/sample_channel.rs deleted file mode 100644 index 750ad2129..000000000 --- a/src/closures/sample_channel.rs +++ /dev/null @@ -1,258 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::{mem::MaybeUninit, sync::Arc}; - -use libc::c_void; -use zenoh::{ - handlers::{self, FifoChannelHandler, IntoHandler, RingChannelHandler}, - sample::Sample, -}; - -pub use crate::opaque_types::{ - z_loaned_fifo_handler_sample_t, z_moved_fifo_handler_sample_t, z_owned_fifo_handler_sample_t, -}; -use crate::{ - result::{self, z_result_t}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_loaned_sample_t, z_owned_closure_sample_t, z_owned_sample_t, -}; -decl_c_type!( - owned(z_owned_fifo_handler_sample_t, option FifoChannelHandler), - loaned(z_loaned_fifo_handler_sample_t), -); - -/// Drops the handler and resets it to a gravestone state. -#[no_mangle] -pub extern "C" fn z_fifo_handler_sample_drop(this_: &mut z_moved_fifo_handler_sample_t) { - let _ = this_.take_rust_type(); -} - -/// Constructs a handler in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_fifo_handler_sample_null( - this: &mut MaybeUninit, -) { - this.as_rust_type_mut_uninit().write(None); -} - -/// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_fifo_handler_sample_check( - this_: &z_owned_fifo_handler_sample_t, -) -> bool { - this_.as_rust_type_ref().is_some() -} - -extern "C" fn __z_handler_sample_send(sample: &mut z_loaned_sample_t, context: *mut c_void) { - unsafe { - let f = (context as *mut std::sync::Arc) - .as_mut() - .unwrap_unchecked(); - let owned_ref: &mut Option = std::mem::transmute(sample); - (f)(std::mem::take(owned_ref).unwrap_unchecked()); - } -} - -extern "C" fn __z_handler_sample_drop(context: *mut c_void) { - unsafe { - let f = Box::from_raw(context as *mut Arc); - std::mem::drop(f); - } -} - -/// Constructs send and recieve ends of the fifo channel -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_fifo_channel_sample_new( - callback: &mut MaybeUninit, - handler: &mut MaybeUninit, - capacity: usize, -) { - let fifo = handlers::FifoChannel::new(capacity); - let (cb, h) = fifo.into_handler(); - let cb_ptr = Box::into_raw(Box::new(cb)) as *mut libc::c_void; - handler.as_rust_type_mut_uninit().write(Some(h)); - callback.write(z_owned_closure_sample_t { - _call: Some(__z_handler_sample_send), - _context: cb_ptr, - _drop: Some(__z_handler_sample_drop), - }); -} - -/// Borrows handler. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_fifo_handler_sample_loan( - this: &z_owned_fifo_handler_sample_t, -) -> &z_loaned_fifo_handler_sample_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// Returns sample from the fifo buffer. If there are no more pending replies will block until next sample is received, or until -/// the channel is dropped (normally when there are no more samples to receive). -/// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the sample will be in the gravestone state). -#[no_mangle] -pub extern "C" fn z_fifo_handler_sample_recv( - this: &z_loaned_fifo_handler_sample_t, - sample: &mut MaybeUninit, -) -> z_result_t { - match this.as_rust_type_ref().recv() { - Ok(q) => { - sample.as_rust_type_mut_uninit().write(Some(q)); - result::Z_OK - } - Err(_) => { - sample.as_rust_type_mut_uninit().write(None); - result::Z_CHANNEL_DISCONNECTED - } - } -} - -/// Returns sample from the fifo buffer. -/// If there are no more pending replies will return immediately (with sample set to its gravestone state). -/// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the sample will be in the gravestone state), -/// `Z_CHANNEL_NODATA` if the channel is still alive, but its buffer is empty (the sample will be in the gravestone state). -#[no_mangle] -pub extern "C" fn z_fifo_handler_sample_try_recv( - this: &z_loaned_fifo_handler_sample_t, - sample: &mut MaybeUninit, -) -> z_result_t { - match this.as_rust_type_ref().try_recv() { - Ok(Some(q)) => { - sample.as_rust_type_mut_uninit().write(Some(q)); - result::Z_OK - } - Ok(None) => { - sample.as_rust_type_mut_uninit().write(None); - result::Z_CHANNEL_NODATA - } - Err(_) => { - sample.as_rust_type_mut_uninit().write(None); - result::Z_CHANNEL_DISCONNECTED - } - } -} - -pub use crate::opaque_types::{ - z_loaned_ring_handler_sample_t, z_moved_ring_handler_sample_t, z_owned_ring_handler_sample_t, -}; -decl_c_type!( - owned( - z_owned_ring_handler_sample_t, - option RingChannelHandler, - ), - loaned(z_loaned_ring_handler_sample_t), -); - -/// Drops the handler and resets it to a gravestone state. -#[no_mangle] -pub extern "C" fn z_ring_handler_sample_drop(this_: &mut z_moved_ring_handler_sample_t) { - let _ = this_.take_rust_type(); -} - -/// Constructs a handler in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_ring_handler_sample_null( - this: &mut MaybeUninit, -) { - this.as_rust_type_mut_uninit().write(None); -} - -/// Returns ``true`` if handler is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_ring_handler_sample_check( - this_: &z_owned_ring_handler_sample_t, -) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// Constructs send and recieve ends of the ring channel -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_ring_channel_sample_new( - callback: &mut MaybeUninit, - handler: &mut MaybeUninit, - capacity: usize, -) { - let ring = handlers::RingChannel::new(capacity); - let (cb, h) = ring.into_handler(); - let cb_ptr = Box::into_raw(Box::new(cb)) as *mut libc::c_void; - handler.as_rust_type_mut_uninit().write(Some(h)); - callback.write(z_owned_closure_sample_t { - _call: Some(__z_handler_sample_send), - _context: cb_ptr, - _drop: Some(__z_handler_sample_drop), - }); -} - -/// Borrows handler. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_ring_handler_sample_loan( - this: &z_owned_ring_handler_sample_t, -) -> &z_loaned_ring_handler_sample_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// Returns sample from the ring buffer. If there are no more pending replies will block until next sample is received, or until -/// the channel is dropped (normally when there are no more replies to receive). -/// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the sample will be in the gravestone state). -#[no_mangle] -pub extern "C" fn z_ring_handler_sample_recv( - this: &z_loaned_ring_handler_sample_t, - sample: &mut MaybeUninit, -) -> z_result_t { - match this.as_rust_type_ref().recv() { - Ok(q) => { - sample.as_rust_type_mut_uninit().write(Some(q)); - result::Z_OK - } - Err(_) => { - sample.as_rust_type_mut_uninit().write(None); - result::Z_CHANNEL_DISCONNECTED - } - } -} - -/// Returns sample from the ring buffer. If there are no more pending replies will return immediately (with sample set to its gravestone state). -/// @return 0 in case of success, `Z_CHANNEL_DISCONNECTED` if channel was dropped (the sample will be in the gravestone state), -/// `Z_CHANNEL_NODATA` if the channel is still alive, but its buffer is empty (the sample will be in the gravestone state). -#[no_mangle] -pub extern "C" fn z_ring_handler_sample_try_recv( - this: &z_loaned_ring_handler_sample_t, - sample: &mut MaybeUninit, -) -> z_result_t { - match this.as_rust_type_ref().try_recv() { - Ok(q) => { - let r = if q.is_some() { - result::Z_OK - } else { - result::Z_CHANNEL_NODATA - }; - sample.as_rust_type_mut_uninit().write(q); - r - } - Err(_) => { - sample.as_rust_type_mut_uninit().write(None); - result::Z_CHANNEL_DISCONNECTED - } - } -} diff --git a/src/closures/sample_closure.rs b/src/closures/sample_closure.rs deleted file mode 100644 index b3d5dbd88..000000000 --- a/src/closures/sample_closure.rs +++ /dev/null @@ -1,174 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::mem::MaybeUninit; - -use libc::c_void; - -use crate::{ - transmute::{LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, - z_loaned_sample_t, -}; -/// @brief A sample-processing closure. -/// -/// A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks. -#[repr(C)] -pub struct z_owned_closure_sample_t { - pub _context: *mut c_void, - pub(crate) _call: Option, - pub _drop: Option, -} - -/// Loaned closure. -#[repr(C)] -pub struct z_loaned_closure_sample_t { - _0: usize, - _1: usize, - _2: usize, -} - -/// Moved closure. -#[repr(C)] -pub struct z_moved_closure_sample_t { - _this: z_owned_closure_sample_t, -} - -decl_c_type!( - owned(z_owned_closure_sample_t), - loaned(z_loaned_closure_sample_t), - moved(z_moved_closure_sample_t), -); - -impl Default for z_owned_closure_sample_t { - fn default() -> Self { - z_owned_closure_sample_t { - _context: std::ptr::null_mut(), - _call: None, - _drop: None, - } - } -} - -impl z_owned_closure_sample_t { - pub fn is_empty(&self) -> bool { - self._call.is_none() && self._drop.is_none() && self._context.is_null() - } -} -unsafe impl Send for z_owned_closure_sample_t {} -unsafe impl Sync for z_owned_closure_sample_t {} -impl Drop for z_owned_closure_sample_t { - fn drop(&mut self) { - if let Some(drop) = self._drop { - drop(self._context) - } - } -} - -/// Constructs a closure in its gravestone state. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_internal_closure_sample_null( - this_: &mut MaybeUninit, -) { - this_.write(z_owned_closure_sample_t::default()); -} - -/// Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_closure_sample_check(this_: &z_owned_closure_sample_t) -> bool { - !this_.is_empty() -} - -/// Calls the closure. Calling an uninitialized closure is a no-op. -#[no_mangle] -pub extern "C" fn z_closure_sample_call( - closure: &z_loaned_closure_sample_t, - sample: &mut z_loaned_sample_t, -) { - let closure = closure.as_owned_c_type_ref(); - match closure._call { - Some(call) => call(sample, closure._context), - None => crate::report_error!("Attempted to call an uninitialized closure!"), - } -} - -/// Drops the closure. Droping an uninitialized closure is a no-op. -#[no_mangle] -pub extern "C" fn z_closure_sample_drop(closure_: &mut z_moved_closure_sample_t) { - let _ = closure_.take_rust_type(); -} - -impl From for z_owned_closure_sample_t { - fn from(f: F) -> Self { - let this = Box::into_raw(Box::new(f)) as _; - extern "C" fn call( - sample: &mut z_loaned_sample_t, - this: *mut c_void, - ) { - let this = unsafe { &*(this as *const F) }; - this(sample) - } - extern "C" fn drop(this: *mut c_void) { - std::mem::drop(unsafe { Box::from_raw(this as *mut F) }) - } - z_owned_closure_sample_t { - _context: this, - _call: Some(call::), - _drop: Some(drop::), - } - } -} - -/// Borrows closure. -#[no_mangle] -pub extern "C" fn z_closure_sample_loan( - closure: &z_owned_closure_sample_t, -) -> &z_loaned_closure_sample_t { - closure.as_loaned_c_type_ref() -} - -/// Mutably borrows closure. -#[no_mangle] -pub extern "C" fn z_closure_sample_loan_mut( - closure: &mut z_owned_closure_sample_t, -) -> &mut z_loaned_closure_sample_t { - closure.as_loaned_c_type_mut() -} - -/// @brief Constructs closure. -/// -/// Closures are not guaranteed not to be called concurrently. -/// -/// It is guaranteed that: -/// - `call` will never be called once `drop` has started. -/// - `drop` will only be called **once**, and **after every** `call` has ended. -/// - The two previous guarantees imply that `call` and `drop` are never called concurrently. -/// -/// @param this_: uninitialized memory location where new closure will be constructed. -/// @param call: a closure body. -/// @param drop: an optional function to be called once on closure drop. -/// @param context: closure context. -#[no_mangle] -pub extern "C" fn z_closure_sample( - this: &mut MaybeUninit, - call: Option, - drop: Option, - context: *mut c_void, -) { - this.write(z_owned_closure_sample_t { - _context: context, - _call: call, - _drop: drop, - }); -} diff --git a/src/closures/zenohid_closure.rs b/src/closures/zenohid_closure.rs deleted file mode 100644 index ef542d340..000000000 --- a/src/closures/zenohid_closure.rs +++ /dev/null @@ -1,169 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::mem::MaybeUninit; - -use libc::c_void; - -use crate::{ - transmute::{LoanedCTypeRef, OwnedCTypeRef, TakeRustType}, - z_id_t, -}; -/// @brief A zenoh id-processing closure. -/// -/// A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks: -#[repr(C)] -pub struct z_owned_closure_zid_t { - _context: *mut c_void, - _call: Option, - _drop: Option, -} - -/// @brief Loaned closure. -#[repr(C)] -pub struct z_loaned_closure_zid_t { - _0: usize, - _1: usize, - _2: usize, -} - -/// @brief Moved closure. -#[repr(C)] -pub struct z_moved_closure_zid_t { - pub _this: z_owned_closure_zid_t, -} - -decl_c_type!( - owned(z_owned_closure_zid_t), - loaned(z_loaned_closure_zid_t), - moved(z_moved_closure_zid_t), -); - -impl Default for z_owned_closure_zid_t { - fn default() -> Self { - z_owned_closure_zid_t { - _context: std::ptr::null_mut(), - _call: None, - _drop: None, - } - } -} - -impl z_owned_closure_zid_t { - pub fn is_empty(&self) -> bool { - self._call.is_none() && self._drop.is_none() && self._context.is_null() - } -} -unsafe impl Send for z_owned_closure_zid_t {} -unsafe impl Sync for z_owned_closure_zid_t {} -impl Drop for z_owned_closure_zid_t { - fn drop(&mut self) { - if let Some(drop) = self._drop { - drop(self._context) - } - } -} - -/// @brief Returns ``true`` if closure is valid, ``false`` if it is in gravestone state. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_internal_closure_zid_check(this_: &z_owned_closure_zid_t) -> bool { - !this_.is_empty() -} - -/// @brief Constructs a null closure. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_internal_closure_zid_null( - this_: &mut MaybeUninit, -) { - this_.write(z_owned_closure_zid_t::default()); -} - -/// @brief Calls the closure. Calling an uninitialized closure is a no-op. -#[no_mangle] -pub extern "C" fn z_closure_zid_call(closure: &z_loaned_closure_zid_t, z_id: &z_id_t) { - let closure = closure.as_owned_c_type_ref(); - match closure._call { - Some(call) => call(z_id, closure._context), - None => { - crate::report_error!("Attempted to call an uninitialized closure!"); - } - } -} - -/// @brief Drops the closure, resetting it to its gravestone state. Droping an uninitialized (null) closure is a no-op. -#[no_mangle] -pub extern "C" fn z_closure_zid_drop(closure_: &mut z_moved_closure_zid_t) { - let _ = closure_.take_rust_type(); -} - -impl From for z_owned_closure_zid_t { - fn from(f: F) -> Self { - let this = Box::into_raw(Box::new(f)) as _; - extern "C" fn call(response: &z_id_t, this: *mut c_void) { - let this = unsafe { &*(this as *const F) }; - this(response) - } - extern "C" fn drop(this: *mut c_void) { - std::mem::drop(unsafe { Box::from_raw(this as *mut F) }) - } - z_owned_closure_zid_t { - _context: this, - _call: Some(call::), - _drop: Some(drop::), - } - } -} - -/// @brief Borrows closure. -#[no_mangle] -pub extern "C" fn z_closure_zid_loan(closure: &z_owned_closure_zid_t) -> &z_loaned_closure_zid_t { - closure.as_loaned_c_type_ref() -} - -/// @brief Mutably borrows closure. -#[no_mangle] -pub extern "C" fn z_closure_zid_loan_mut( - closure: &z_owned_closure_zid_t, -) -> &z_loaned_closure_zid_t { - closure.as_loaned_c_type_ref() -} - -/// @brief Constructs closure. -/// -/// Closures are not guaranteed not to be called concurrently. -/// -/// It is guaranteed that: -/// - `call` will never be called once `drop` has started. -/// - `drop` will only be called **once**, and **after every** `call` has ended. -/// - The two previous guarantees imply that `call` and `drop` are never called concurrently. -/// -/// @param this_: uninitialized memory location where new closure will be constructed. -/// @param call: a closure body. -/// @param drop: an optional function to be called once on closure drop. -/// @param context: closure context. -#[no_mangle] -pub extern "C" fn z_closure_zid( - this: &mut MaybeUninit, - call: Option, - drop: Option, - context: *mut c_void, -) { - this.write(z_owned_closure_zid_t { - _context: context, - _call: call, - _drop: drop, - }); -} diff --git a/src/collections.rs b/src/collections.rs deleted file mode 100644 index 019dc475b..000000000 --- a/src/collections.rs +++ /dev/null @@ -1,940 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use core::ffi::c_void; -use std::{ - hash::Hash, - mem::MaybeUninit, - ops::{Deref, DerefMut}, - ptr::{null, null_mut, slice_from_raw_parts}, - slice::from_raw_parts, - str::{from_utf8, Utf8Error}, -}; - -use crate::{ - result::{self, z_result_t}, - strlen_or_zero, - transmute::{Gravestone, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, -}; - -pub struct CSlice { - data: *const u8, - len: usize, - drop: Option, - context: *mut c_void, -} - -pub extern "C" fn _z_drop_c_slice_default(data: *mut c_void, context: *mut c_void) { - let ptr = data as *const u8; - let len = context as usize; - let b = unsafe { Box::from_raw(slice_from_raw_parts(ptr, len).cast_mut()) }; - std::mem::drop(b); -} - -#[derive(Clone)] -pub struct CSliceOwned(CSlice); -pub struct CSliceView(CSlice); - -impl Gravestone for CSliceOwned { - fn gravestone() -> Self { - Self(CSlice::gravestone()) - } - fn is_gravestone(&self) -> bool { - self.0.is_gravestone() - } -} - -impl Gravestone for CSliceView { - fn gravestone() -> Self { - Self(CSlice::gravestone()) - } - fn is_gravestone(&self) -> bool { - self.0.is_gravestone() - } -} - -impl Deref for CSliceOwned { - type Target = CSlice; - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl Deref for CSliceView { - type Target = CSlice; - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl DerefMut for CSliceOwned { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} - -impl DerefMut for CSliceView { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} - -impl From for CSlice { - fn from(value: CSliceOwned) -> Self { - value.0 - } -} - -impl From for CSlice { - fn from(value: CSliceView) -> Self { - value.0 - } -} - -impl CSliceView { - pub fn new(data: *const u8, len: usize) -> Result { - Ok(Self(CSlice::new_borrowed(data, len)?)) - } - - pub fn from_slice(s: &[u8]) -> CSliceView { - CSliceView(CSlice::new_borrowed_from_slice(s)) - } -} - -impl CSliceOwned { - #[allow(clippy::missing_safety_doc)] - pub unsafe fn new(data: *const u8, len: usize) -> Result { - Ok(Self(CSlice::new_owned(data, len)?)) - } - #[allow(clippy::missing_safety_doc)] - pub unsafe fn wrap( - data: *mut u8, - len: usize, - drop: Option, - context: *mut c_void, - ) -> Result { - Ok(CSliceOwned(CSlice::new(data, len, drop, context)?)) - } -} - -impl CSlice { - pub fn new_unchecked( - data: *const u8, - len: usize, - drop: Option, - context: *mut c_void, - ) -> Self { - Self { - data, - len, - drop, - context, - } - } - - pub fn new_borrowed_unchecked(data: *const u8, len: usize) -> Self { - Self::new_unchecked(data, len, None, null_mut()) - } - - pub fn new( - data: *mut u8, - len: usize, - drop: Option, - context: *mut c_void, - ) -> Result { - if data.is_null() && len > 0 { - crate::report_error!("Non zero-length array should not be NULL"); - Err(result::Z_EINVAL) - } else { - Ok(Self::new_unchecked(data, len, drop, context)) - } - } - - pub fn new_borrowed(data: *const u8, len: usize) -> Result { - if data.is_null() && len > 0 { - crate::report_error!("Non zero-length arra should not be NULL"); - Err(result::Z_EINVAL) - } else { - Ok(Self::new_borrowed_unchecked(data, len)) - } - } - - pub fn new_borrowed_from_slice(slice: &[u8]) -> Self { - Self::new_borrowed_unchecked(slice.as_ptr(), slice.len()) - } - - #[allow(clippy::missing_safety_doc)] - pub unsafe fn new_owned_unchecked(data: *const u8, len: usize) -> Self { - if len == 0 { - return Self::gravestone(); - } - let b = unsafe { from_raw_parts(data, len).to_vec().into_boxed_slice() }; - let slice = Box::leak(b); - CSlice::wrap(slice.as_ptr(), len) - } - - pub fn wrap(data: *const u8, len: usize) -> Self { - Self::new_unchecked(data, len, Some(_z_drop_c_slice_default), len as *mut c_void) - } - - #[allow(clippy::missing_safety_doc)] - pub unsafe fn new_owned(data: *const u8, len: usize) -> Result { - if data.is_null() && len > 0 { - crate::report_error!("Non zero-length array should not be NULL"); - Err(result::Z_EINVAL) - } else { - Ok(Self::new_owned_unchecked(data, len)) - } - } - - pub fn slice(&self) -> &'static [u8] { - if self.len == 0 { - return &[0u8; 0]; - } - unsafe { from_raw_parts(self.data, self.len) } - } - - pub fn data(&self) -> *const u8 { - self.data - } - - pub fn len(&self) -> usize { - self.len - } - - pub fn is_empty(&self) -> bool { - self.len == 0 - } - - pub fn is_owned(&self) -> bool { - self.drop.is_some() - } - - pub fn clone_to_borrowed(&self) -> Self { - Self::new_borrowed_unchecked(self.data, self.len) - } - - pub fn clone_to_owned(&self) -> CSliceOwned { - CSliceOwned(unsafe { Self::new_owned_unchecked(self.data(), self.len()) }) - } -} - -impl Clone for CSlice { - fn clone(&self) -> Self { - unsafe { Self::new_owned_unchecked(self.data(), self.len()) } - } -} - -impl Gravestone for CSlice { - fn gravestone() -> Self { - Self { - data: null(), - len: 0, - drop: None, - context: null_mut(), - } - } - fn is_gravestone(&self) -> bool { - self.data.is_null() - } -} - -impl Drop for CSlice { - fn drop(&mut self) { - if let Some(drop) = self.drop { - drop(self.data as *mut c_void, self.context); - } - } -} - -impl Hash for CSlice { - fn hash(&self, state: &mut H) { - self.slice().hash(state); - } -} - -impl PartialEq for CSlice { - fn eq(&self, other: &Self) -> bool { - self.slice() == other.slice() - } -} - -impl From> for CSliceOwned { - fn from(value: Vec) -> Self { - let slice = Box::leak(value.into_boxed_slice()); - CSliceOwned(CSlice::wrap(slice.as_ptr(), slice.len())) - } -} - -impl From> for CSlice { - fn from(value: Vec) -> Self { - let slice: CSliceOwned = value.into(); - slice.0 - } -} - -impl std::cmp::Eq for CSlice {} - -pub use crate::opaque_types::{z_loaned_slice_t, z_moved_slice_t, z_owned_slice_t, z_view_slice_t}; - -decl_c_type!( - owned(z_owned_slice_t, CSliceOwned), - loaned(z_loaned_slice_t, CSlice), - view(z_view_slice_t, CSliceView), -); - -/// Constructs an empty view slice. -#[no_mangle] -pub extern "C" fn z_view_slice_empty(this_: &mut MaybeUninit) { - this_ - .as_rust_type_mut_uninit() - .write(CSliceView::gravestone()); -} - -/// Constructs a `len` bytes long view starting at `start`. -/// -/// @return -1 if `start == NULL` and `len > 0` (and creates an empty view slice), 0 otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_view_slice_from_buf( - this: &mut MaybeUninit, - start: *const u8, - len: usize, -) -> z_result_t { - let this = this.as_rust_type_mut_uninit(); - match CSliceView::new(start, len) { - Ok(slice) => { - this.write(slice); - result::Z_OK - } - Err(e) => { - this.write(CSliceView::gravestone()); - e - } - } -} - -/// Borrows view slice. -#[no_mangle] -pub extern "C" fn z_view_slice_loan(this_: &z_view_slice_t) -> &z_loaned_slice_t { - this_.as_rust_type_ref().as_loaned_c_type_ref() -} - -/// @return ``true`` if the slice is not empty, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_view_slice_is_empty(this_: &z_view_slice_t) -> bool { - this_.as_rust_type_ref().is_empty() -} - -/// Constructs an empty `z_owned_slice_t`. -#[no_mangle] -pub extern "C" fn z_slice_empty(this_: &mut MaybeUninit) { - this_ - .as_rust_type_mut_uninit() - .write(CSliceOwned::gravestone()); -} - -/// Constructs an empty `z_owned_slice_t`. -#[no_mangle] -pub extern "C" fn z_internal_slice_null(this_: &mut MaybeUninit) { - z_slice_empty(this_); -} - -/// Frees the memory and invalidates the slice. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_slice_drop(this_: &mut z_moved_slice_t) { - let _ = this_.take_rust_type(); -} - -/// Borrows slice. -#[no_mangle] -pub extern "C" fn z_slice_loan(this_: &z_owned_slice_t) -> &z_loaned_slice_t { - this_.as_rust_type_ref().as_loaned_c_type_ref() -} - -/// Constructs an owned copy of a slice. -#[no_mangle] -pub extern "C" fn z_slice_clone(dst: &mut MaybeUninit, this_: &z_loaned_slice_t) { - dst.as_rust_type_mut_uninit() - .write(this_.as_rust_type_ref().clone_to_owned()); -} - -/// @return ``true`` if slice is not empty, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_internal_slice_check(this_: &z_owned_slice_t) -> bool { - !this_.as_rust_type_ref().is_empty() -} - -/// @return the length of the slice. -#[no_mangle] -pub extern "C" fn z_slice_len(this_: &z_loaned_slice_t) -> usize { - this_.as_rust_type_ref().len() -} - -/// @return the pointer to the slice data. -#[no_mangle] -pub extern "C" fn z_slice_data(this_: &z_loaned_slice_t) -> *const u8 { - this_.as_rust_type_ref().data() -} - -/// @return ``true`` if slice is empty, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_slice_is_empty(this_: &z_loaned_slice_t) -> bool { - this_.as_rust_type_ref().is_empty() -} - -/// Constructs a slice by copying a `len` bytes long sequence starting at `start`. -/// -/// @return -1 if `start == NULL` and `len > 0` (creating an empty slice), 0 otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_slice_copy_from_buf( - this: &mut MaybeUninit, - start: *const u8, - len: usize, -) -> z_result_t { - let this = this.as_rust_type_mut_uninit(); - match CSliceOwned::new(start, len) { - Ok(slice) => { - this.write(slice); - result::Z_OK - } - Err(e) => { - this.write(CSliceOwned::gravestone()); - e - } - } -} - -/// Constructs a slice by transferring ownership of `data` to it. -/// @param this_: Pointer to an uninitialized memoery location where slice will be constructed. -/// @param data: Pointer to the data to be owned by `this_`. -/// @param len: Number of bytes in `data`. -/// @param drop: A thread-safe delete function to free the `data`. Will be called once when `this_` is dropped. Can be NULL, in case if `data` is allocated in static memory. -/// @param context: An optional context to be passed to the `deleter`. -/// -/// @return -1 if `start == NULL` and `len > 0` (creating an empty slice), 0 otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_slice_from_buf( - this: &mut MaybeUninit, - data: *mut u8, - len: usize, - drop: Option, - context: *mut c_void, -) -> z_result_t { - let this = this.as_rust_type_mut_uninit(); - match CSliceOwned::wrap(data, len, drop, context) { - Ok(slice) => { - this.write(slice); - result::Z_OK - } - Err(e) => { - this.write(CSliceOwned::gravestone()); - e - } - } -} - -pub use crate::opaque_types::{ - z_loaned_string_t, z_moved_string_t, z_owned_string_t, z_view_string_t, -}; - -// The wrappers which provides string-related interfaces to memory slice `CSlice` -// Unlike the standard `std:ffi::CString` these structures doesn't provide -// any guarantees about null-termination - -#[derive(Clone)] -pub struct CStringInner(CSlice); -pub struct CStringOwned(CStringInner); -pub struct CStringView(CStringInner); - -impl Gravestone for CStringInner { - fn gravestone() -> Self { - Self(CSlice::gravestone()) - } - fn is_gravestone(&self) -> bool { - self.0.is_gravestone() - } -} - -impl Gravestone for CStringOwned { - fn gravestone() -> Self { - Self(CStringInner::gravestone()) - } - fn is_gravestone(&self) -> bool { - self.0.is_gravestone() - } -} - -impl Gravestone for CStringView { - fn gravestone() -> Self { - Self(CStringInner::gravestone()) - } - fn is_gravestone(&self) -> bool { - self.0.is_gravestone() - } -} - -impl CStringInner { - pub fn new_borrowed_from_slice(slice: &[u8]) -> Self { - CStringInner(CSlice::new_borrowed_from_slice(slice)) - } -} - -impl CStringOwned { - #[allow(clippy::missing_safety_doc)] - pub unsafe fn new(data: *const libc::c_char, len: usize) -> Result { - Ok(CStringOwned(CStringInner(CSlice::new_owned( - data as _, len, - )?))) - } - - #[allow(clippy::missing_safety_doc)] - pub unsafe fn wrap( - data: *mut libc::c_char, - len: usize, - drop: Option, - context: *mut c_void, - ) -> Result { - Ok(CStringOwned(CStringInner(CSlice::new( - data as _, len, drop, context, - )?))) - } -} - -impl CStringView { - #[allow(clippy::missing_safety_doc)] - pub unsafe fn new_borrowed(data: *const libc::c_char, len: usize) -> Result { - Ok(CStringView(CStringInner(CSlice::new_borrowed( - data as _, len, - )?))) - } - pub fn new_borrowed_from_slice(slice: &[u8]) -> Self { - CStringView(CStringInner::new_borrowed_from_slice(slice)) - } -} - -impl Deref for CStringInner { - type Target = CSlice; - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl Deref for CStringOwned { - type Target = CStringInner; - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl Deref for CStringView { - type Target = CStringInner; - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl AsRef for CStringInner { - fn as_ref(&self) -> &CSlice { - &self.0 - } -} - -impl AsRef for CStringOwned { - fn as_ref(&self) -> &CSlice { - &self.0 - } -} - -impl AsRef for CStringView { - fn as_ref(&self) -> &CSlice { - &self.0 - } -} - -impl From for CStringOwned { - fn from(value: String) -> Self { - let slice = Box::leak(value.into_boxed_str()); - CStringOwned(CStringInner(CSlice::wrap(slice.as_ptr(), slice.len()))) - } -} - -impl From for CSlice { - fn from(value: CStringInner) -> Self { - value.0 - } -} - -impl TryFrom<&CStringInner> for &str { - type Error = Utf8Error; - - fn try_from(value: &CStringInner) -> Result { - if value.0.data.is_null() { - Ok("") - } else { - let s = unsafe { from_raw_parts(value.0.data, value.len) }; - from_utf8(s) - } - } -} - -impl TryFrom<&CStringView> for &str { - type Error = Utf8Error; - - fn try_from(value: &CStringView) -> Result { - (&value.0).try_into() - } -} - -impl From for CSlice { - fn from(value: CStringOwned) -> Self { - value.0 .0 - } -} - -decl_c_type!( - owned(z_owned_string_t, CStringOwned), - loaned(z_loaned_string_t, CStringInner), - view(z_view_string_t, CStringView), -); - -/// Frees memory and invalidates `z_owned_string_t`, putting it in gravestone state. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_string_drop(this_: &mut z_moved_string_t) { - let _ = this_.take_rust_type(); -} - -/// @return ``true`` if `this_` is a valid string, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_string_check(this_: &z_owned_string_t) -> bool { - !this_.as_rust_type_ref().is_empty() -} - -/// Constructs owned string in a gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_string_null(this_: &mut MaybeUninit) { - this_ - .as_rust_type_mut_uninit() - .write(CStringOwned::gravestone()); -} - -/// @return ``true`` if view string is valid, ``false`` if it is in a gravestone state. -#[no_mangle] -pub extern "C" fn z_view_string_is_empty(this_: &z_view_string_t) -> bool { - this_.as_rust_type_ref().is_empty() -} - -/// Constructs an empty owned string. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_string_empty(this_: &mut MaybeUninit) { - this_ - .as_rust_type_mut_uninit() - .write(CStringOwned::gravestone()); -} - -/// Constructs an empty view string. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_view_string_empty(this_: &mut MaybeUninit) { - this_ - .as_rust_type_mut_uninit() - .write(CStringView::gravestone()); -} - -/// Borrows string. -#[no_mangle] -pub extern "C" fn z_string_loan(this_: &z_owned_string_t) -> &z_loaned_string_t { - this_.as_rust_type_ref().as_loaned_c_type_ref() -} - -/// Borrows view string. -#[no_mangle] -pub extern "C" fn z_view_string_loan(this_: &z_view_string_t) -> &z_loaned_string_t { - this_.as_rust_type_ref().as_loaned_c_type_ref() -} - -/// Constructs an owned string by copying `str` into it (including terminating 0), using `strlen` (this should therefore not be used with untrusted inputs). -/// -/// @return -1 if `str == NULL` (and creates a string in a gravestone state), 0 otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_string_copy_from_str( - this_: &mut MaybeUninit, - str: *const libc::c_char, -) -> z_result_t { - z_string_copy_from_substr(this_, str, strlen_or_zero(str)) -} - -/// Constructs an owned string by copying a `str` substring of length `len`. -/// -/// @return -1 if `str == NULL` and `len > 0` (and creates a string in a gravestone state), 0 otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_string_copy_from_substr( - this: &mut MaybeUninit, - str: *const libc::c_char, - len: usize, -) -> z_result_t { - let this = this.as_rust_type_mut_uninit(); - match CStringOwned::new(str, len) { - Ok(slice) => { - this.write(slice); - result::Z_OK - } - Err(e) => { - this.write(CStringOwned::gravestone()); - e - } - } -} - -/// Constructs an owned string by transferring ownership of a null-terminated string `str` to it. -/// @param this_: Pointer to an uninitialized memory location where an owned string will be constructed. -/// @param str: Pointer to a null terminated string to be owned by `this_`. -/// @param drop: A thread-safe delete function to free the `str`. Will be called once when `str` is dropped. Can be NULL, in case if `str` is allocated in static memory. -/// @param context: An optional context to be passed to the `deleter`. -/// @return -1 if `str == NULL` and `len > 0` (and creates a string in a gravestone state), 0 otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_string_from_str( - this: &mut MaybeUninit, - str: *mut libc::c_char, - drop: Option, - context: *mut c_void, -) -> z_result_t { - let this = this.as_rust_type_mut_uninit(); - match CStringOwned::wrap(str, strlen_or_zero(str), drop, context) { - Ok(slice) => { - this.write(slice); - result::Z_OK - } - Err(e) => { - this.write(CStringOwned::gravestone()); - e - } - } -} - -/// Constructs a view string of `str`, using `strlen` (this should therefore not be used with untrusted inputs). -/// -/// @return -1 if `str == NULL` (and creates a string in a gravestone state), 0 otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_view_string_from_str( - this: &mut MaybeUninit, - str: *const libc::c_char, -) -> z_result_t { - let this = this.as_rust_type_mut_uninit(); - match CStringView::new_borrowed(str, strlen_or_zero(str)) { - Ok(slice) => { - this.write(slice); - result::Z_OK - } - Err(e) => { - this.write(CStringView::gravestone()); - e - } - } -} - -/// Constructs a view string to a specified substring of length `len`. -/// -/// @return -1 if `str == NULL` and `len > 0` (and creates a string in a gravestone state), 0 otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_view_string_from_substr( - this: &mut MaybeUninit, - str: *const libc::c_char, - len: usize, -) -> z_result_t { - let this = this.as_rust_type_mut_uninit(); - match CStringView::new_borrowed(str, len) { - Ok(slice) => { - this.write(slice); - result::Z_OK - } - Err(e) => { - this.write(CStringView::gravestone()); - e - } - } -} - -/// @return the length of the string (without terminating 0 character). -#[no_mangle] -pub extern "C" fn z_string_len(this_: &z_loaned_string_t) -> usize { - this_.as_rust_type_ref().len() -} - -/// @return the pointer of the string data. -#[no_mangle] -pub extern "C" fn z_string_data(this_: &z_loaned_string_t) -> *const libc::c_char { - this_.as_rust_type_ref().data() as _ -} - -/// Constructs an owned copy of a string. -#[no_mangle] -pub extern "C" fn z_string_clone( - dst: &mut MaybeUninit, - this: &z_loaned_string_t, -) { - let slice = this.as_rust_type_ref().clone_to_owned(); - dst.as_rust_type_mut_uninit() - .write(CStringOwned(CStringInner(slice.0))); -} - -// Converts loaned string into loaned slice (with terminating 0 character). -#[no_mangle] -pub extern "C" fn z_string_as_slice(this_: &z_loaned_string_t) -> &z_loaned_slice_t { - this_.as_rust_type_ref().as_ref().as_loaned_c_type_ref() -} - -/// @return ``true`` if string is empty, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_string_is_empty(this_: &z_loaned_string_t) -> bool { - this_.as_rust_type_ref().is_empty() -} - -pub use crate::opaque_types::{ - z_loaned_string_array_t, z_moved_string_array_t, z_owned_string_array_t, -}; -pub type ZVector = Vec; -decl_c_type!( - owned(z_owned_string_array_t, ZVector), - loaned(z_loaned_string_array_t), -); - -impl Gravestone for ZVector { - fn gravestone() -> Self { - Vec::new() - } - fn is_gravestone(&self) -> bool { - self.is_empty() - } -} - -/// Constructs a new empty string array. -#[no_mangle] -pub extern "C" fn z_string_array_new(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(ZVector::gravestone()); -} - -/// Constructs string array in its gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_string_array_null(this_: &mut MaybeUninit) { - z_string_array_new(this_) -} - -/// @return ``true`` if the string array is valid, ``false`` if it is in a gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_string_array_check(this_: &z_owned_string_array_t) -> bool { - !this_.as_rust_type_ref().is_empty() -} - -/// Destroys the string array, resetting it to its gravestone value. -#[no_mangle] -pub extern "C" fn z_string_array_drop(this_: &mut z_moved_string_array_t) { - let _ = this_.take_rust_type(); -} - -/// Borrows string array. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_string_array_loan( - this: &z_owned_string_array_t, -) -> &z_loaned_string_array_t { - this.as_rust_type_ref().as_loaned_c_type_ref() -} - -/// Mutably borrows string array. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_string_array_loan_mut( - this: &mut z_owned_string_array_t, -) -> &mut z_loaned_string_array_t { - this.as_rust_type_mut().as_loaned_c_type_mut() -} - -/// @return number of elements in the array. -#[no_mangle] -pub extern "C" fn z_string_array_len(this_: &z_loaned_string_array_t) -> usize { - this_.as_rust_type_ref().len() -} - -/// @return ``true`` if the array is empty, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_string_array_is_empty(this_: &z_loaned_string_array_t) -> bool { - this_.as_rust_type_ref().is_empty() -} - -/// @return the value at the position of index in the string array. -/// -/// Will return `NULL` if the index is out of bounds. -#[no_mangle] -pub extern "C" fn z_string_array_get( - this: &z_loaned_string_array_t, - index: usize, -) -> Option<&z_loaned_string_t> { - let a = this.as_rust_type_ref(); - if index >= a.len() { - return None; - } - - Some(a[index].as_loaned_c_type_ref()) -} - -/// Appends specified value to the end of the string array by copying. -/// -/// @return the new length of the array. -#[no_mangle] -pub extern "C" fn z_string_array_push_by_copy( - this: &mut z_loaned_string_array_t, - value: &z_loaned_string_t, -) -> usize { - let this = this.as_rust_type_mut(); - let v = value.as_rust_type_ref(); - this.push(CStringInner(v.clone_to_owned().into())); - - this.len() -} - -/// Appends specified value to the end of the string array by alias. -/// -/// @return the new length of the array. -#[no_mangle] -pub extern "C" fn z_string_array_push_by_alias( - this: &mut z_loaned_string_array_t, - value: &z_loaned_string_t, -) -> usize { - let this = this.as_rust_type_mut(); - let v = value.as_rust_type_ref(); - this.push(CStringInner(v.clone_to_borrowed())); - - this.len() -} - -/// Constructs an owned copy of a string array. -#[no_mangle] -pub extern "C" fn z_string_array_clone( - dst: &mut MaybeUninit, - this_: &z_loaned_string_array_t, -) { - dst.as_rust_type_mut_uninit() - .write(this_.as_rust_type_ref().clone()); -} diff --git a/src/commons.rs b/src/commons.rs deleted file mode 100644 index aaf7a1442..000000000 --- a/src/commons.rs +++ /dev/null @@ -1,673 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::{mem::MaybeUninit, ptr::null}; - -use libc::c_ulong; -#[cfg(feature = "unstable")] -use zenoh::{qos::Reliability, query::ReplyKeyExpr, sample::SourceInfo, session::EntityGlobalId}; -use zenoh::{ - qos::{CongestionControl, Priority}, - query::{ConsolidationMode, QueryTarget}, - sample::{Locality, Sample, SampleKind}, - time::Timestamp, -}; - -#[cfg(feature = "unstable")] -use crate::transmute::Gravestone; -#[cfg(feature = "unstable")] -use crate::transmute::IntoCType; -#[cfg(feature = "unstable")] -use crate::z_moved_source_info_t; -use crate::{ - result, - transmute::{CTypeRef, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_id_t, z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_session_t, -}; - -/// A zenoh unsigned integer -#[allow(non_camel_case_types)] -pub type z_zint_t = c_ulong; - -#[allow(non_camel_case_types)] -#[repr(C)] -#[derive(Clone, Copy, Debug)] -pub enum z_sample_kind_t { - /// The Sample was issued by a ``put`` operation. - PUT = 0, - /// The Sample was issued by a ``delete`` operation. - DELETE = 1, -} - -impl From for z_sample_kind_t { - fn from(k: SampleKind) -> Self { - match k { - SampleKind::Put => z_sample_kind_t::PUT, - SampleKind::Delete => z_sample_kind_t::DELETE, - } - } -} - -impl From for SampleKind { - fn from(k: z_sample_kind_t) -> Self { - match k { - z_sample_kind_t::PUT => SampleKind::Put, - z_sample_kind_t::DELETE => SampleKind::Delete, - } - } -} -use crate::opaque_types::z_timestamp_t; -decl_c_type!(copy(z_timestamp_t, Timestamp)); - -/// Create uhlc timestamp from session id. -#[no_mangle] -pub extern "C" fn z_timestamp_new( - this: &mut MaybeUninit, - session: &z_loaned_session_t, -) -> result::z_result_t { - let timestamp = session.as_rust_type_ref().new_timestamp(); - this.as_rust_type_mut_uninit().write(timestamp); - result::Z_OK -} - -/// Returns NPT64 time associated with this timestamp. -#[no_mangle] -pub extern "C" fn z_timestamp_ntp64_time(this_: &z_timestamp_t) -> u64 { - this_.as_rust_type_ref().get_time().0 -} - -/// @brief Returns id associated with this timestamp. -#[no_mangle] -pub extern "C" fn z_timestamp_id(this_: &z_timestamp_t) -> z_id_t { - this_.as_rust_type_ref().get_id().to_le_bytes().into() -} - -use crate::opaque_types::z_loaned_sample_t; -pub use crate::opaque_types::{z_moved_sample_t, z_owned_sample_t}; -decl_c_type!( - owned(z_owned_sample_t, option Sample), - loaned(z_loaned_sample_t), -); - -/// Returns the key expression of the sample. -#[no_mangle] -pub extern "C" fn z_sample_keyexpr(this_: &z_loaned_sample_t) -> &z_loaned_keyexpr_t { - this_.as_rust_type_ref().key_expr().as_loaned_c_type_ref() -} -/// Returns the encoding associated with the sample data. -#[no_mangle] -pub extern "C" fn z_sample_encoding(this_: &z_loaned_sample_t) -> &z_loaned_encoding_t { - this_.as_rust_type_ref().encoding().as_loaned_c_type_ref() -} -/// Returns the sample payload data. -#[no_mangle] -pub extern "C" fn z_sample_payload(this_: &z_loaned_sample_t) -> &z_loaned_bytes_t { - this_.as_rust_type_ref().payload().as_loaned_c_type_ref() -} -/// Returns the mutable sample payload data. -#[no_mangle] -pub extern "C" fn z_sample_payload_mut(this_: &mut z_loaned_sample_t) -> &mut z_loaned_bytes_t { - this_ - .as_rust_type_mut() - .payload_mut() - .as_loaned_c_type_mut() -} - -/// Returns the sample kind. -#[no_mangle] -pub extern "C" fn z_sample_kind(this_: &z_loaned_sample_t) -> z_sample_kind_t { - this_.as_rust_type_ref().kind().into() -} -/// Returns the sample timestamp. -/// -/// Will return `NULL`, if sample is not associated with a timestamp. -#[no_mangle] -pub extern "C" fn z_sample_timestamp(this_: &z_loaned_sample_t) -> Option<&z_timestamp_t> { - if let Some(t) = this_.as_rust_type_ref().timestamp() { - Some(t.as_ctype_ref()) - } else { - None - } -} - -/// Returns sample attachment. -/// -/// Returns `NULL`, if sample does not contain any attachment. -#[no_mangle] -pub extern "C" fn z_sample_attachment(this_: &z_loaned_sample_t) -> *const z_loaned_bytes_t { - match this_.as_rust_type_ref().attachment() { - Some(attachment) => attachment.as_loaned_c_type_ref() as *const _, - None => null(), - } -} -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns the sample source_info. -#[no_mangle] -pub extern "C" fn z_sample_source_info(this_: &z_loaned_sample_t) -> &z_loaned_source_info_t { - this_ - .as_rust_type_ref() - .source_info() - .as_loaned_c_type_ref() -} - -/// Constructs an owned shallow copy of the sample (i.e. all modficiations applied to the copy, might be visible in the original) in provided uninitilized memory location. -#[no_mangle] -pub extern "C" fn z_sample_clone( - dst: &mut MaybeUninit, - this: &z_loaned_sample_t, -) { - dst.as_rust_type_mut_uninit() - .write(Some(this.as_rust_type_ref().clone())); -} - -/// Returns sample qos priority value. -#[no_mangle] -pub extern "C" fn z_sample_priority(this_: &z_loaned_sample_t) -> z_priority_t { - this_.as_rust_type_ref().priority().into() -} - -/// Returns whether sample qos express flag was set or not. -#[no_mangle] -pub extern "C" fn z_sample_express(this_: &z_loaned_sample_t) -> bool { - this_.as_rust_type_ref().express() -} - -/// Returns sample qos congestion control value. -#[no_mangle] -pub extern "C" fn z_sample_congestion_control(this_: &z_loaned_sample_t) -> z_congestion_control_t { - this_.as_rust_type_ref().congestion_control().into() -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns the reliability setting the sample was delivered with. -#[no_mangle] -pub extern "C" fn z_sample_reliability(this_: &z_loaned_sample_t) -> z_reliability_t { - this_.as_rust_type_ref().reliability().into() -} - -/// Returns ``true`` if sample is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_sample_check(this_: &z_owned_sample_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// Borrows sample. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_sample_loan(this_: &z_owned_sample_t) -> &z_loaned_sample_t { - this_ - .as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// Mutably borrows sample. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_sample_loan_mut(this_: &mut z_owned_sample_t) -> &mut z_loaned_sample_t { - this_ - .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - -/// Takes ownership of the mutably borrowed sample. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_sample_take_from_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_sample_t, -) { - let dst = dst.as_rust_type_mut_uninit(); - let src = src.as_rust_type_mut(); - let src = std::mem::replace(src, Sample::empty()); - dst.write(Some(src)); -} - -/// Frees the memory and invalidates the sample, resetting it to a gravestone state. -#[no_mangle] -pub extern "C" fn z_sample_drop(this_: &mut z_moved_sample_t) { - let _ = this_.take_rust_type(); -} - -/// Constructs sample in its gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_sample_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// The locality of samples to be received by subscribers or targeted by publishers. -#[repr(C)] -#[derive(Clone, Copy, Debug)] -pub enum zc_locality_t { - /// Any - ANY = 0, - /// Only from local sessions. - SESSION_LOCAL = 1, - /// Only from remote sessions. - REMOTE = 2, -} - -impl From for zc_locality_t { - fn from(k: Locality) -> Self { - match k { - Locality::Any => zc_locality_t::ANY, - Locality::SessionLocal => zc_locality_t::SESSION_LOCAL, - Locality::Remote => zc_locality_t::REMOTE, - } - } -} - -impl From for Locality { - fn from(k: zc_locality_t) -> Self { - match k { - zc_locality_t::ANY => Locality::Any, - zc_locality_t::SESSION_LOCAL => Locality::SessionLocal, - zc_locality_t::REMOTE => Locality::Remote, - } - } -} - -/// @brief Returns default value of `zc_locality_t` -#[no_mangle] -pub extern "C" fn zc_locality_default() -> zc_locality_t { - Locality::default().into() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief The publisher reliability. -/// @note Currently `reliability` does not trigger any data retransmission on the wire. -/// It is rather used as a marker on the wire and it may be used to select the best link available (e.g. TCP for reliable data and UDP for best effort data). -#[cfg(feature = "unstable")] -#[allow(non_camel_case_types, clippy::upper_case_acronyms)] -#[repr(C)] -#[derive(Clone, Copy)] -pub enum z_reliability_t { - /// Defines reliability as ``BEST_EFFORT`` - BEST_EFFORT = 0, - /// Defines reliability as ``RELIABLE`` - RELIABLE = 1, -} - -#[cfg(feature = "unstable")] -impl From for z_reliability_t { - #[inline] - fn from(r: Reliability) -> Self { - match r { - Reliability::BestEffort => z_reliability_t::BEST_EFFORT, - Reliability::Reliable => z_reliability_t::RELIABLE, - } - } -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns the default value for `reliability`. -#[no_mangle] -pub extern "C" fn z_reliability_default() -> z_reliability_t { - Reliability::default().into() -} - -#[cfg(feature = "unstable")] -impl From for Reliability { - #[inline] - fn from(val: z_reliability_t) -> Self { - match val { - z_reliability_t::BEST_EFFORT => Reliability::BestEffort, - z_reliability_t::RELIABLE => Reliability::Reliable, - } - } -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Key expressions types to which Queryable should reply to. -#[repr(C)] -#[derive(Clone, Copy, Debug)] -pub enum zc_reply_keyexpr_t { - /// Replies to any key expression queries. - ANY = 0, - /// Replies only to queries with intersecting key expressions. - MATCHING_QUERY = 1, -} - -#[cfg(feature = "unstable")] -impl From for zc_reply_keyexpr_t { - fn from(k: ReplyKeyExpr) -> Self { - match k { - ReplyKeyExpr::Any => zc_reply_keyexpr_t::ANY, - ReplyKeyExpr::MatchingQuery => zc_reply_keyexpr_t::MATCHING_QUERY, - } - } -} - -#[cfg(feature = "unstable")] -impl From for ReplyKeyExpr { - fn from(k: zc_reply_keyexpr_t) -> Self { - match k { - zc_reply_keyexpr_t::ANY => ReplyKeyExpr::Any, - zc_reply_keyexpr_t::MATCHING_QUERY => ReplyKeyExpr::MatchingQuery, - } - } -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns the default value of #zc_reply_keyexpr_t. -#[no_mangle] -pub extern "C" fn zc_reply_keyexpr_default() -> zc_reply_keyexpr_t { - ReplyKeyExpr::default().into() -} - -/// The Queryables that should be target of a `z_get()`. -#[allow(non_camel_case_types)] -#[repr(C)] -#[derive(Clone, Copy)] -pub enum z_query_target_t { - /// The nearest complete queryable if any else all matching queryables. - BEST_MATCHING = 0, - /// All matching queryables. - ALL = 1, - /// All complete queryables. - ALL_COMPLETE = 2, -} - -impl From for z_query_target_t { - #[inline] - fn from(t: QueryTarget) -> Self { - match t { - QueryTarget::BestMatching => z_query_target_t::BEST_MATCHING, - QueryTarget::All => z_query_target_t::ALL, - QueryTarget::AllComplete => z_query_target_t::ALL_COMPLETE, - } - } -} - -impl From for QueryTarget { - #[inline] - fn from(val: z_query_target_t) -> Self { - match val { - z_query_target_t::BEST_MATCHING => QueryTarget::BestMatching, - z_query_target_t::ALL => QueryTarget::All, - z_query_target_t::ALL_COMPLETE => QueryTarget::AllComplete, - } - } -} - -/// Create a default `z_query_target_t`. -#[no_mangle] -pub extern "C" fn z_query_target_default() -> z_query_target_t { - QueryTarget::default().into() -} - -/// Consolidation mode values. -#[repr(C)] -#[derive(Clone, Copy, Default)] -pub enum z_consolidation_mode_t { - /// Let Zenoh decide the best consolidation mode depending on the query selector. - /// If the selector contains time range properties, consolidation mode `NONE` is used. - /// Otherwise the `LATEST` consolidation mode is used. - AUTO = -1, - #[default] - /// No consolidation is applied. Replies may come in any order and any number. - NONE = 0, - /// It guarantees that any reply for a given key expression will be monotonic in time - /// w.r.t. the previous received replies for the same key expression. I.e., for the same key expression multiple - /// replies may be received. It is guaranteed that two replies received at t1 and t2 will have timestamp - /// ts2 > ts1. It optimizes latency. - MONOTONIC = 1, - /// It guarantees unicity of replies for the same key expression. - /// It optimizes bandwidth. - LATEST = 2, -} - -impl From for z_consolidation_mode_t { - #[inline] - fn from(cm: ConsolidationMode) -> Self { - match cm { - ConsolidationMode::Auto => z_consolidation_mode_t::AUTO, - ConsolidationMode::None => z_consolidation_mode_t::NONE, - ConsolidationMode::Monotonic => z_consolidation_mode_t::MONOTONIC, - ConsolidationMode::Latest => z_consolidation_mode_t::LATEST, - } - } -} - -impl From for ConsolidationMode { - #[inline] - fn from(val: z_consolidation_mode_t) -> Self { - match val { - z_consolidation_mode_t::AUTO => ConsolidationMode::Auto, - z_consolidation_mode_t::NONE => ConsolidationMode::None, - z_consolidation_mode_t::MONOTONIC => ConsolidationMode::Monotonic, - z_consolidation_mode_t::LATEST => ConsolidationMode::Latest, - } - } -} - -/// The priority of zenoh messages. -#[allow(non_camel_case_types)] -#[repr(C)] -#[derive(Clone, Copy)] -pub enum z_priority_t { - /// Priority for ``RealTime`` messages. - REAL_TIME = 1, - /// Highest priority for ``Interactive`` messages. - INTERACTIVE_HIGH = 2, - /// Lowest priority for ``Interactive`` messages. - INTERACTIVE_LOW = 3, - /// Highest priority for ``Data`` messages. - DATA_HIGH = 4, - /// Default priority for ``Data`` messages. - DATA = 5, - /// Lowest priority for ``Data`` messages. - DATA_LOW = 6, - /// Priority for ``Background traffic`` messages. - BACKGROUND = 7, -} - -impl From for z_priority_t { - fn from(p: Priority) -> Self { - match p { - Priority::RealTime => z_priority_t::REAL_TIME, - Priority::InteractiveHigh => z_priority_t::INTERACTIVE_HIGH, - Priority::InteractiveLow => z_priority_t::INTERACTIVE_LOW, - Priority::DataHigh => z_priority_t::DATA_HIGH, - Priority::Data => z_priority_t::DATA, - Priority::DataLow => z_priority_t::DATA_LOW, - Priority::Background => z_priority_t::BACKGROUND, - } - } -} - -impl From for Priority { - fn from(p: z_priority_t) -> Self { - match p { - z_priority_t::REAL_TIME => Priority::RealTime, - z_priority_t::INTERACTIVE_HIGH => Priority::InteractiveHigh, - z_priority_t::INTERACTIVE_LOW => Priority::InteractiveLow, - z_priority_t::DATA_HIGH => Priority::DataHigh, - z_priority_t::DATA => Priority::Data, - z_priority_t::DATA_LOW => Priority::DataLow, - z_priority_t::BACKGROUND => Priority::Background, - } - } -} - -/// Returns the default value of #z_priority_t. -#[no_mangle] -pub extern "C" fn z_priority_default() -> z_priority_t { - Priority::default().into() -} - -#[allow(non_camel_case_types)] -#[repr(C)] -#[derive(Clone, Copy)] -pub enum z_congestion_control_t { - /// Messages are not dropped in case of congestion. - BLOCK = 0, - /// Messages are dropped in case of congestion. - DROP = 1, - #[cfg(feature = "unstable")] - /// Messages except the first one are dropped in case of congestion. - BLOCK_FIRST = 2, -} - -/// Returns the default congestion control value of zenoh push network messages, typically used for put operations. -#[no_mangle] -pub extern "C" fn z_internal_congestion_control_default_push() -> z_congestion_control_t { - CongestionControl::DEFAULT_PUSH.into() -} - -/// Returns the default congestion control value of zenoh request network messages, typically used for get operations. -#[no_mangle] -pub extern "C" fn z_internal_congestion_control_default_request() -> z_congestion_control_t { - CongestionControl::DEFAULT_REQUEST.into() -} - -/// Returns the default congestion control value of zenoh response network messages, typically used for reply operations. -#[no_mangle] -pub extern "C" fn z_internal_congestion_control_default_response() -> z_congestion_control_t { - CongestionControl::DEFAULT_RESPONSE.into() -} - -impl From for z_congestion_control_t { - fn from(cc: CongestionControl) -> Self { - match cc { - CongestionControl::Block => z_congestion_control_t::BLOCK, - CongestionControl::Drop => z_congestion_control_t::DROP, - #[cfg(feature = "unstable")] - CongestionControl::BlockFirst => z_congestion_control_t::BLOCK_FIRST, - } - } -} - -impl From for CongestionControl { - fn from(cc: z_congestion_control_t) -> Self { - match cc { - z_congestion_control_t::BLOCK => CongestionControl::Block, - z_congestion_control_t::DROP => CongestionControl::Drop, - #[cfg(feature = "unstable")] - z_congestion_control_t::BLOCK_FIRST => CongestionControl::BlockFirst, - } - } -} - -#[cfg(feature = "unstable")] -use crate::z_entity_global_id_t; -#[cfg(feature = "unstable")] -decl_c_type!(copy(z_entity_global_id_t, EntityGlobalId)); - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns the zenoh id of entity global id. -#[no_mangle] -pub extern "C" fn z_entity_global_id_zid(this_: &z_entity_global_id_t) -> z_id_t { - this_.as_rust_type_ref().zid().into_c_type() -} -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns the entity id of the entity global id. -#[no_mangle] -pub extern "C" fn z_entity_global_id_eid(this_: &z_entity_global_id_t) -> u32 { - this_.as_rust_type_ref().eid() -} -#[cfg(feature = "unstable")] -pub use crate::opaque_types::{z_loaned_source_info_t, z_owned_source_info_t}; -#[cfg(feature = "unstable")] -decl_c_type!( - owned(z_owned_source_info_t, SourceInfo), - loaned(z_loaned_source_info_t, SourceInfo), -); - -#[cfg(feature = "unstable")] -impl Gravestone for SourceInfo { - fn gravestone() -> Self { - SourceInfo::default() - } - fn is_gravestone(&self) -> bool { - self.source_id().is_none() && self.source_sn().is_none() - } -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Creates source info. -#[no_mangle] -pub extern "C" fn z_source_info_new( - this: &mut MaybeUninit, - source_id: &z_entity_global_id_t, - source_sn: u32, -) -> result::z_result_t { - let this = this.as_rust_type_mut_uninit(); - let source_info = SourceInfo::new(Some(*source_id.as_rust_type_ref()), Some(source_sn)); - this.write(source_info); - result::Z_OK -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns the source_id of the source info. -#[no_mangle] -pub extern "C" fn z_source_info_id(this_: &z_loaned_source_info_t) -> z_entity_global_id_t { - match this_.as_rust_type_ref().source_id() { - Some(source_id) => *source_id, - None => EntityGlobalId::default(), - } - .into_c_type() -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns the source_sn of the source info. -#[no_mangle] -pub extern "C" fn z_source_info_sn(this_: &z_loaned_source_info_t) -> u32 { - this_.as_rust_type_ref().source_sn().unwrap_or_default() -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns ``true`` if source info is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_source_info_check(this_: &z_owned_source_info_t) -> bool { - this_.as_rust_type_ref().source_id().is_some() || this_.as_rust_type_ref().source_sn().is_some() -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Borrows source info. -#[no_mangle] -pub extern "C" fn z_source_info_loan(this_: &z_owned_source_info_t) -> &z_loaned_source_info_t { - this_.as_rust_type_ref().as_loaned_c_type_ref() -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Frees the memory and invalidates the source info, resetting it to a gravestone state. -#[no_mangle] -pub extern "C" fn z_source_info_drop(this_: &mut z_moved_source_info_t) { - let _ = this_.take_rust_type(); -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs source info in its gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_source_info_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(SourceInfo::default()); -} diff --git a/src/config.rs b/src/config.rs deleted file mode 100644 index 71c22da27..000000000 --- a/src/config.rs +++ /dev/null @@ -1,353 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// -use std::{mem::MaybeUninit, slice::from_raw_parts, str::from_utf8}; - -use libc::{c_char, c_uint}; -use zenoh::config::{Config, WhatAmI}; - -use crate::{ - result::{self, Z_OK}, - strlen_or_zero, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_internal_string_null, z_owned_string_t, z_string_copy_from_substr, CStringView, -}; - -#[no_mangle] -pub static Z_ROUTER: c_uint = WhatAmI::Router as c_uint; -#[no_mangle] -pub static Z_PEER: c_uint = WhatAmI::Peer as c_uint; -#[no_mangle] -pub static Z_CLIENT: c_uint = WhatAmI::Client as c_uint; - -pub use crate::opaque_types::{z_loaned_config_t, z_moved_config_t, z_owned_config_t}; -decl_c_type!( - owned(z_owned_config_t, option Config), - loaned(z_loaned_config_t), -); - -/// Borrows config. -#[no_mangle] -pub extern "C" fn z_config_loan(this_: &'static z_owned_config_t) -> &'static z_loaned_config_t { - let this = this_.as_rust_type_ref(); - let this = unsafe { this.as_ref().unwrap_unchecked() }; - this.as_loaned_c_type_ref() -} - -/// Mutably borrows config. -#[no_mangle] -pub extern "C" fn z_config_loan_mut(this_: &mut z_owned_config_t) -> &mut z_loaned_config_t { - let this = this_.as_rust_type_mut(); - let this = unsafe { this.as_mut().unwrap_unchecked() }; - this.as_loaned_c_type_mut() -} - -/// Constructs a new empty configuration. -#[no_mangle] -pub extern "C" fn z_config_default( - this_: &mut MaybeUninit, -) -> result::z_result_t { - this_ - .as_rust_type_mut_uninit() - .write(Some(Config::default())); - Z_OK -} - -/// Constructs config in its gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_config_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// Clones the config into provided uninitialized memory location. -#[no_mangle] -pub extern "C" fn z_config_clone( - dst: &mut MaybeUninit, - this: &z_loaned_config_t, -) { - let src = Some(this.as_rust_type_ref().clone()); - let dst = dst.as_rust_type_mut_uninit(); - dst.write(src); -} - -/// Gets the property with the given path key from the configuration, and constructs and owned string from it. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn zc_config_get_from_str( - this: &z_loaned_config_t, - key: *const c_char, - out_value_string: &mut MaybeUninit, -) -> result::z_result_t { - zc_config_get_from_substr(this, key, strlen_or_zero(key), out_value_string) -} - -/// Gets the property with the given path key from the configuration, and constructs and owned string from it. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn zc_config_get_from_substr( - this: &z_loaned_config_t, - key: *const c_char, - key_len: usize, - out_value_string: &mut MaybeUninit, -) -> result::z_result_t { - let config = this.as_rust_type_ref(); - if key.is_null() { - z_internal_string_null(out_value_string); - crate::report_error!("Key should not be null"); - return result::Z_EINVAL; - } - - let key = match from_utf8(from_raw_parts(key as _, key_len)) { - Ok(s) => s, - Err(e) => { - crate::report_error!("Config key is not a valid utf-8 string: {}", e); - z_internal_string_null(out_value_string); - return result::Z_EINVAL; - } - }; - let val = config.get_json(key).ok(); - match val { - Some(val) => { - z_string_copy_from_substr( - out_value_string, - val.as_ptr() as *const libc::c_char, - val.len(), - ); - result::Z_OK - } - None => { - crate::report_error!("No value was found in the config for key: '{}'", key); - z_internal_string_null(out_value_string); - result::Z_EUNAVAILABLE - } - } -} - -/// Inserts a JSON-serialized `value` at the `key` position of the configuration. -/// -/// Returns 0 if successful, a negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc, unused_must_use)] -pub unsafe extern "C" fn zc_config_insert_json5( - this: &mut z_loaned_config_t, - key: *const c_char, - value: *const c_char, -) -> result::z_result_t { - zc_config_insert_json5_from_substr(this, key, strlen_or_zero(key), value, strlen_or_zero(value)) -} - -/// Inserts a JSON-serialized `value` at the `key` position of the configuration. -/// -/// Returns 0 if successful, a negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc, unused_must_use)] -pub unsafe extern "C" fn zc_config_insert_json5_from_substr( - this: &mut z_loaned_config_t, - key: *const c_char, - key_len: usize, - value: *const c_char, - value_len: usize, -) -> result::z_result_t { - let config = this.as_rust_type_mut(); - let csk = match CStringView::new_borrowed(key, key_len) { - Ok(cs) => cs, - Err(r) => return r, - }; - let key = match (&csk).try_into() { - Ok(s) => s, - Err(e) => { - crate::report_error!("Config key is not a valid utf-8 string: {}", e); - return result::Z_EINVAL; - } - }; - let csv = match CStringView::new_borrowed(value, value_len) { - Ok(cs) => cs, - Err(r) => return r, - }; - let value = match (&csv).try_into() { - Ok(s) => s, - Err(e) => { - crate::report_error!("Config value is not a valid utf-8 string: {}", e); - return result::Z_EINVAL; - } - }; - match config.insert_json5(key, value) { - Ok(_) => 0, - Err(e) => { - crate::report_error!( - "Failed to insert value '{}' for key '{}' into config: {}", - value, - key, - e - ); - result::Z_EGENERIC - } - } -} - -/// Frees `config`, and resets it to its gravestone state. -#[no_mangle] -pub extern "C" fn z_config_drop(this_: &mut z_moved_config_t) { - let _ = this_.take_rust_type(); -} - -/// Returns ``true`` if config is valid, ``false`` if it is in a gravestone state. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_internal_config_check(this_: &z_owned_config_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// Reads a configuration from a JSON-serialized string, such as '{mode:"client",connect:{endpoints:["tcp/127.0.0.1:7447"]}}'. -/// -/// Returns 0 in case of success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn zc_config_from_str( - this: &mut MaybeUninit, - s: *const c_char, -) -> result::z_result_t { - zc_config_from_substr(this, s, strlen_or_zero(s)) -} - -/// Reads a configuration from a JSON-serialized substring of specified lenght, such as '{mode:"client",connect:{endpoints:["tcp/127.0.0.1:7447"]}}'. -/// -/// Returns 0 in case of success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn zc_config_from_substr( - this: &mut MaybeUninit, - s: *const c_char, - len: usize, -) -> result::z_result_t { - z_internal_config_null(this); - if s.is_null() { - crate::report_error!("String should not be NULL"); - result::Z_EINVAL - } else { - let slice = std::slice::from_raw_parts(s as _, len); - let conf_str = match std::str::from_utf8(slice) { - Ok(cs) => cs, - Err(e) => { - crate::report_error!("Config should be a valid utf-8 string {}", e); - return result::Z_EINVAL; - } - }; - match json5::from_str(conf_str) { - Ok(props) => { - this.as_rust_type_mut_uninit().write(Some(props)); - result::Z_OK - } - Err(e) => { - crate::report_error!("Invalid config string: {}", e); - result::Z_EPARSE - } - } - } -} - -/// Constructs a json string representation of the `config`, such as '{"mode":"client","connect":{"endpoints":["tcp/127.0.0.1:7447"]}}'. -/// -/// Returns 0 in case of success, negative error code otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn zc_config_to_string( - config: &z_loaned_config_t, - out_config_string: &mut MaybeUninit, -) -> result::z_result_t { - let config = config.as_rust_type_ref(); - match json5::to_string(config) { - Ok(s) => { - unsafe { - z_string_copy_from_substr( - out_config_string, - s.as_ptr() as *const libc::c_char, - s.len(), - ) - }; - result::Z_OK - } - Err(e) => { - crate::report_error!("Config is not a valid json5: {}", e); - z_internal_string_null(out_config_string); - result::Z_EPARSE - } - } -} - -/// Constructs a configuration by parsing a file at `path` null-terminated string. Currently supported format is JSON5, a superset of JSON. -/// -/// Returns 0 in case of success, negative error code otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn zc_config_from_file( - this: &mut MaybeUninit, - path: *const c_char, -) -> result::z_result_t { - zc_config_from_file_substr(this, path, strlen_or_zero(path)) -} - -/// Constructs a configuration by parsing a file at `path` susbstring of specified length. Currently supported format is JSON5, a superset of JSON. -/// -/// Returns 0 in case of success, negative error code otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn zc_config_from_file_substr( - this: &mut MaybeUninit, - path: *const c_char, - len: usize, -) -> result::z_result_t { - z_internal_config_null(this); - if path.is_null() { - crate::report_error!("Path should be NULL"); - return result::Z_EINVAL; - } - let slice = std::slice::from_raw_parts(path as _, len); - let path_str = match std::str::from_utf8(slice) { - Ok(cs) => cs, - Err(e) => { - crate::report_error!("Path should be a valid utf-8 string {}", e); - return result::Z_EINVAL; - } - }; - match zenoh::config::Config::from_file(path_str) { - Ok(c) => { - this.as_rust_type_mut_uninit().write(Some(c)); - result::Z_OK - } - Err(e) => { - crate::report_error!("Failed to read config from {}: {}", path_str, e); - result::Z_EPARSE - } - } -} - -/// Constructs a configuration by parsing a file path stored in ZENOH_CONFIG environmental variable. -/// -/// Returns 0 in case of success, negative error code otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn zc_config_from_env( - this: &mut MaybeUninit, -) -> result::z_result_t { - match Config::from_env() { - Ok(c) => { - this.as_rust_type_mut_uninit().write(Some(c)); - result::Z_OK - } - Err(e) => { - crate::report_error!("Close error: {}", e); - result::Z_EIO - } - } -} diff --git a/src/context.rs b/src/context.rs deleted file mode 100644 index 6b74006f1..000000000 --- a/src/context.rs +++ /dev/null @@ -1,119 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::fmt::Debug; - -use libc::c_void; - -/// A trait for implementing droppable contexts -pub trait DroppableContext: Debug { - fn get(&self) -> *mut c_void; -} - -/// A non-tread-safe droppable context. -/// Contexts are idiomatically used in C together with callback interfaces to deliver associated state -/// information to each callback. -/// -/// This is a non-thread-safe context - zenoh-c guarantees that associated callbacks that share the same -/// zc_context_t instance will never be executed concurrently. In other words, all the callbacks associated -/// with this context data are not required to be thread-safe. -/// -/// NOTE: Remember that the same callback interfaces associated with different zc_context_t instances can -/// still be executed concurrently. The exact behavior depends on user's application, but we strongly -/// discourage our users from pinning to some specific behavior unless they _really_ understand what they -/// are doing. -/// -/// Once moved to zenoh-c ownership, this context is guaranteed to execute delete_fn when deleted. The -/// delete_fn is guaranteed to be executed only once at some point of time after the last associated -/// callback call returns. -/// NOTE: if user doesn't pass the instance of this context to zenoh-c, the delete_fn callback won't -/// be executed. -#[derive(Debug)] -#[repr(C)] -pub struct zc_context_t { - context: *mut c_void, - delete_fn: unsafe extern "C" fn(*mut c_void), -} - -impl From for Context { - fn from(value: zc_context_t) -> Self { - Self(value) - } -} - -#[derive(Debug)] -#[repr(transparent)] -pub struct Context(zc_context_t); -impl DroppableContext for Context { - fn get(&self) -> *mut c_void { - self.0.context - } -} -impl Drop for Context { - fn drop(&mut self) { - unsafe { - (self.0.delete_fn)(self.0.context); - } - } -} - -/// A tread-safe droppable context. -/// Contexts are idiomatically used in C together with callback interfaces to deliver associated state -/// information to each callback. -/// -/// This is a thread-safe context - the associated callbacks may be executed concurrently with the same -/// zc_context_t instance. In other words, all the callbacks associated with this context data MUST be -/// thread-safe. -/// -/// Once moved to zenoh-c ownership, this context is guaranteed to execute delete_fn when deleted.The -/// delete_fn is guaranteed to be executed only once at some point of time after the last associated -/// callback call returns. -/// NOTE: if user doesn't pass the instance of this context to zenoh-c, the delete_fn callback won't -/// be executed. -#[derive(Debug)] -#[repr(C)] -pub struct zc_threadsafe_context_t { - context: zc_threadsafe_context_data_t, - delete_fn: unsafe extern "C" fn(*mut c_void), -} - -impl From for ThreadsafeContext { - fn from(value: zc_threadsafe_context_t) -> Self { - Self(value) - } -} - -#[derive(Debug)] -#[repr(C)] -pub struct zc_threadsafe_context_data_t { - ptr: *mut c_void, -} -unsafe impl Send for zc_threadsafe_context_data_t {} -unsafe impl Sync for zc_threadsafe_context_data_t {} - -#[derive(Debug)] -#[repr(transparent)] -pub struct ThreadsafeContext(zc_threadsafe_context_t); -impl DroppableContext for ThreadsafeContext { - fn get(&self) -> *mut c_void { - self.0.context.ptr - } -} -impl Drop for ThreadsafeContext { - fn drop(&mut self) { - unsafe { - (self.0.delete_fn)(self.0.context.ptr); - } - } -} diff --git a/src/encoding.rs b/src/encoding.rs deleted file mode 100644 index c9d1c8759..000000000 --- a/src/encoding.rs +++ /dev/null @@ -1,625 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::{ - borrow::Cow, - mem::MaybeUninit, - ptr::null, - slice::from_raw_parts, - str::{from_utf8, FromStr}, -}; - -use libc::c_char; -use unwrap_infallible::UnwrapInfallible; -use zenoh::bytes::Encoding; - -pub use crate::opaque_types::{z_loaned_encoding_t, z_owned_encoding_t}; -use crate::{ - result::{self, z_result_t}, - strlen_or_zero, - transmute::{Gravestone, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_moved_encoding_t, z_owned_string_t, z_string_copy_from_substr, -}; - -decl_c_type!( - owned(z_owned_encoding_t, Encoding), - loaned(z_loaned_encoding_t, Encoding), -); - -impl Gravestone for Encoding { - fn gravestone() -> Self { - Encoding::default() - } - fn is_gravestone(&self) -> bool { - self == &Self::default() - } -} - -/// Constructs a `z_owned_encoding_t` from a specified substring. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_encoding_from_substr( - this: &mut MaybeUninit, - s: *const c_char, - len: usize, -) -> result::z_result_t { - let encoding = this.as_rust_type_mut_uninit(); - if s.is_null() { - encoding.write(Encoding::default()); - result::Z_OK - } else { - #[allow(clippy::unnecessary_cast)] - let s = from_raw_parts(s as *const u8, len); - match from_utf8(s) { - Ok(s) => { - encoding.write(Encoding::from_str(s).unwrap_infallible()); - result::Z_OK - } - Err(e) => { - crate::report_error!("Can not create encoding from non UTF-8 string: {}", e); - encoding.write(Encoding::default()); - result::Z_EINVAL - } - } - } -} - -/// Set a schema to this encoding from a c substring. Zenoh does not define what a schema is and its semantichs is left to the implementer. -/// E.g. a common schema for `text/plain` encoding is `utf-8`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_encoding_set_schema_from_substr( - this: &mut z_loaned_encoding_t, - s: *const c_char, - len: usize, -) -> result::z_result_t { - let encoding = this.as_rust_type_mut(); - if len == 0 { - *encoding = std::mem::take(encoding).with_schema(String::new()); - return result::Z_OK; - } else if s.is_null() { - crate::report_error!("Non-zero length string should not be null"); - return result::Z_EINVAL; - } - #[allow(clippy::unnecessary_cast)] - let schema_bytes = from_raw_parts(s as *const u8, len); - match from_utf8(schema_bytes) { - Ok(schema_str) => { - *encoding = std::mem::take(encoding).with_schema(schema_str); - result::Z_OK - } - Err(e) => { - crate::report_error!("{}", e); - result::Z_EINVAL - } - } -} - -/// Set a schema to this encoding from a c string. Zenoh does not define what a schema is and its semantichs is left to the implementer. -/// E.g. a common schema for `text/plain` encoding is `utf-8`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_encoding_set_schema_from_str( - this: &mut z_loaned_encoding_t, - s: *const c_char, -) -> z_result_t { - z_encoding_set_schema_from_substr(this, s, strlen_or_zero(s)) -} - -/// Constructs a `z_owned_encoding_t` from a specified string. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_encoding_from_str( - this: &mut MaybeUninit, - s: *const c_char, -) -> result::z_result_t { - z_encoding_from_substr(this, s, strlen_or_zero(s)) -} - -/// Constructs an owned non-null-terminated string from encoding -/// -/// @param this_: Encoding. -/// @param out_str: Uninitialized memory location where a string to be constructed. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_encoding_to_string( - this: &z_loaned_encoding_t, - out_str: &mut MaybeUninit, -) { - let s: Cow<'static, str> = this.as_rust_type_ref().into(); - z_string_copy_from_substr(out_str, s.as_bytes().as_ptr() as _, s.len()); -} - -/// Returns a loaned default `z_loaned_encoding_t`. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub extern "C" fn z_encoding_loan_default() -> &'static z_loaned_encoding_t { - Encoding::ZENOH_BYTES.as_loaned_c_type_ref() -} - -/// Constructs a default `z_owned_encoding_t`. -#[no_mangle] -pub extern "C" fn z_internal_encoding_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(Encoding::default()); -} - -/// Frees the memory and resets the encoding it to its default value. -#[no_mangle] -pub extern "C" fn z_encoding_drop(this_: &mut z_moved_encoding_t) { - let _ = this_.take_rust_type(); -} - -/// Returns ``true`` if encoding is in non-default state, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_internal_encoding_check(this_: &'static z_owned_encoding_t) -> bool { - *this_.as_rust_type_ref() != Encoding::default() -} - -/// Borrows encoding. -#[no_mangle] -pub extern "C" fn z_encoding_loan(this_: &z_owned_encoding_t) -> &z_loaned_encoding_t { - this_.as_rust_type_ref().as_loaned_c_type_ref() -} - -/// Mutably borrows encoding. -#[no_mangle] -pub extern "C" fn z_encoding_loan_mut(this_: &mut z_owned_encoding_t) -> &mut z_loaned_encoding_t { - this_.as_rust_type_mut().as_loaned_c_type_mut() -} - -/// Constructs an owned copy of the encoding in provided uninitilized memory location. -#[no_mangle] -pub extern "C" fn z_encoding_clone( - dst: &mut MaybeUninit, - this: &z_loaned_encoding_t, -) { - dst.as_rust_type_mut_uninit() - .write(this.as_rust_type_ref().clone()); -} - -/// Returns ``true`` if `this_` equals to `other`, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_encoding_equals( - this_: &z_loaned_encoding_t, - other: &z_loaned_encoding_t, -) -> bool { - this_.as_rust_type_ref() == other.as_rust_type_ref() -} - -/// Just some bytes. -/// -/// Constant alias for string: `"zenoh/bytes"`. -/// -/// This encoding supposes that the payload was created with `z_bytes_from_buf()`, `z_bytes_from_slice()` or -/// similar functions and its data can be accessed via `z_bytes_to_slice()`. -#[no_mangle] -pub extern "C" fn z_encoding_zenoh_bytes() -> &'static z_loaned_encoding_t { - Encoding::ZENOH_BYTES.as_loaned_c_type_ref() -} -/// A UTF-8 string. -/// -/// Constant alias for string: `"zenoh/string"`. -/// -/// This encoding supposes that the payload was created with `z_bytes_from_str()`, `z_bytes_from_string()` or -/// similar functions and its data can be accessed via `z_bytes_to_string()`. -#[no_mangle] -pub extern "C" fn z_encoding_zenoh_string() -> &'static z_loaned_encoding_t { - Encoding::ZENOH_STRING.as_loaned_c_type_ref() -} - -/// Zenoh serialized data. -/// -/// Constant alias for string: `"zenoh/serialized"`. -/// -/// This encoding supposes that the payload was created with serialization functions. -/// The `schema` field may contain the details of serialziation format. -#[no_mangle] -pub extern "C" fn z_encoding_zenoh_serialized() -> &'static z_loaned_encoding_t { - Encoding::ZENOH_SERIALIZED.as_loaned_c_type_ref() -} - -// - Advanced types may be supported in some of the Zenoh bindings. -/// An application-specific stream of bytes. -/// -/// Constant alias for string: `"application/octet-stream"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_octet_stream() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_OCTET_STREAM.as_loaned_c_type_ref() -} -/// A textual file. -/// -/// Constant alias for string: `"text/plain"`. -#[no_mangle] -pub extern "C" fn z_encoding_text_plain() -> &'static z_loaned_encoding_t { - Encoding::TEXT_PLAIN.as_loaned_c_type_ref() -} -/// JSON data intended to be consumed by an application. -/// -/// Constant alias for string: `"application/json"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_json() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_JSON.as_loaned_c_type_ref() -} -/// JSON data intended to be human readable. -/// -/// Constant alias for string: `"text/json"`. -#[no_mangle] -pub extern "C" fn z_encoding_text_json() -> &'static z_loaned_encoding_t { - Encoding::TEXT_JSON.as_loaned_c_type_ref() -} -/// A Common Data Representation (CDR)-encoded data. -/// -/// Constant alias for string: `"application/cdr"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_cdr() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_CDR.as_loaned_c_type_ref() -} -/// A Concise Binary Object Representation (CBOR)-encoded data. -/// -/// Constant alias for string: `"application/cbor"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_cbor() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_CBOR.as_loaned_c_type_ref() -} -/// YAML data intended to be consumed by an application. -/// -/// Constant alias for string: `"application/yaml"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_yaml() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_YAML.as_loaned_c_type_ref() -} -/// YAML data intended to be human readable. -/// -/// Constant alias for string: `"text/yaml"`. -#[no_mangle] -pub extern "C" fn z_encoding_text_yaml() -> &'static z_loaned_encoding_t { - Encoding::TEXT_YAML.as_loaned_c_type_ref() -} -/// JSON5 encoded data that are human readable. -/// -/// Constant alias for string: `"text/json5"`. -#[no_mangle] -pub extern "C" fn z_encoding_text_json5() -> &'static z_loaned_encoding_t { - Encoding::TEXT_JSON5.as_loaned_c_type_ref() -} -/// A Python object serialized using [pickle](https://docs.python.org/3/library/pickle.html). -/// -/// Constant alias for string: `"application/python-serialized-object"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_python_serialized_object() -> &'static z_loaned_encoding_t -{ - Encoding::APPLICATION_PYTHON_SERIALIZED_OBJECT.as_loaned_c_type_ref() -} -/// An application-specific protobuf-encoded data. -/// -/// Constant alias for string: `"application/protobuf"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_protobuf() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_PROTOBUF.as_loaned_c_type_ref() -} -/// A Java serialized object. -/// -/// Constant alias for string: `"application/java-serialized-object"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_java_serialized_object() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_JAVA_SERIALIZED_OBJECT.as_loaned_c_type_ref() -} -/// An [openmetrics](https://github.com/OpenObservability/OpenMetrics) data, common used by [Prometheus](https://prometheus.io/). -/// -/// Constant alias for string: `"application/openmetrics-text"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_openmetrics_text() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_OPENMETRICS_TEXT.as_loaned_c_type_ref() -} -/// A Portable Network Graphics (PNG) image. -/// -/// Constant alias for string: `"image/png"`. -#[no_mangle] -pub extern "C" fn z_encoding_image_png() -> &'static z_loaned_encoding_t { - Encoding::IMAGE_PNG.as_loaned_c_type_ref() -} -/// A Joint Photographic Experts Group (JPEG) image. -/// -/// Constant alias for string: `"image/jpeg"`. -#[no_mangle] -pub extern "C" fn z_encoding_image_jpeg() -> &'static z_loaned_encoding_t { - Encoding::IMAGE_JPEG.as_loaned_c_type_ref() -} -/// A Graphics Interchange Format (GIF) image. -/// -/// Constant alias for string: `"image/gif"`. -#[no_mangle] -pub extern "C" fn z_encoding_image_gif() -> &'static z_loaned_encoding_t { - Encoding::IMAGE_GIF.as_loaned_c_type_ref() -} -/// A BitMap (BMP) image. -/// -/// Constant alias for string: `"image/bmp"`. -#[no_mangle] -pub extern "C" fn z_encoding_image_bmp() -> &'static z_loaned_encoding_t { - Encoding::IMAGE_BMP.as_loaned_c_type_ref() -} -/// A Web Portable (WebP) image. -/// -/// Constant alias for string: `"image/webp"`. -#[no_mangle] -pub extern "C" fn z_encoding_image_webp() -> &'static z_loaned_encoding_t { - Encoding::IMAGE_WEBP.as_loaned_c_type_ref() -} -/// An XML file intended to be consumed by an application.. -/// -/// Constant alias for string: `"application/xml"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_xml() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_XML.as_loaned_c_type_ref() -} -/// An encoded a list of tuples, each consisting of a name and a value. -/// -/// Constant alias for string: `"application/x-www-form-urlencoded"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_x_www_form_urlencoded() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_X_WWW_FORM_URLENCODED.as_loaned_c_type_ref() -} -/// An HTML file. -/// -/// Constant alias for string: `"text/html"`. -#[no_mangle] -pub extern "C" fn z_encoding_text_html() -> &'static z_loaned_encoding_t { - Encoding::TEXT_HTML.as_loaned_c_type_ref() -} -/// An XML file that is human readable. -/// -/// Constant alias for string: `"text/xml"`. -#[no_mangle] -pub extern "C" fn z_encoding_text_xml() -> &'static z_loaned_encoding_t { - Encoding::TEXT_XML.as_loaned_c_type_ref() -} -/// A CSS file. -/// -/// Constant alias for string: `"text/css"`. -#[no_mangle] -pub extern "C" fn z_encoding_text_css() -> &'static z_loaned_encoding_t { - Encoding::TEXT_CSS.as_loaned_c_type_ref() -} -/// A JavaScript file. -/// -/// Constant alias for string: `"text/javascript"`. -#[no_mangle] -pub extern "C" fn z_encoding_text_javascript() -> &'static z_loaned_encoding_t { - Encoding::TEXT_JAVASCRIPT.as_loaned_c_type_ref() -} -/// A MarkDown file. -/// -/// Constant alias for string: `"text/markdown"`. -#[no_mangle] -pub extern "C" fn z_encoding_text_markdown() -> &'static z_loaned_encoding_t { - Encoding::TEXT_MARKDOWN.as_loaned_c_type_ref() -} -/// A CSV file. -/// -/// Constant alias for string: `"text/csv"`. -#[no_mangle] -pub extern "C" fn z_encoding_text_csv() -> &'static z_loaned_encoding_t { - Encoding::TEXT_CSV.as_loaned_c_type_ref() -} -/// An application-specific SQL query. -/// -/// Constant alias for string: `"application/sql"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_sql() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_SQL.as_loaned_c_type_ref() -} -/// Constrained Application Protocol (CoAP) data intended for CoAP-to-HTTP and HTTP-to-CoAP proxies. -/// -/// Constant alias for string: `"application/coap-payload"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_coap_payload() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_COAP_PAYLOAD.as_loaned_c_type_ref() -} -/// Defines a JSON document structure for expressing a sequence of operations to apply to a JSON document. -/// -/// Constant alias for string: `"application/json-patch+json"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_json_patch_json() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_JSON_PATCH_JSON.as_loaned_c_type_ref() -} -/// A JSON text sequence consists of any number of JSON texts, all encoded in UTF-8. -/// -/// Constant alias for string: `"application/json-seq"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_json_seq() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_JSON_SEQ.as_loaned_c_type_ref() -} -/// A JSONPath defines a string syntax for selecting and extracting JSON values from within a given JSON value. -/// -/// Constant alias for string: `"application/jsonpath"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_jsonpath() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_JSONPATH.as_loaned_c_type_ref() -} -/// A JSON Web Token (JWT). -/// -/// Constant alias for string: `"application/jwt"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_jwt() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_JWT.as_loaned_c_type_ref() -} -/// An application-specific MPEG-4 encoded data, either audio or video. -/// -/// Constant alias for string: `"application/mp4"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_mp4() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_MP4.as_loaned_c_type_ref() -} -/// A SOAP 1.2 message serialized as XML 1.0. -/// -/// Constant alias for string: `"application/soap+xml"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_soap_xml() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_SOAP_XML.as_loaned_c_type_ref() -} -/// A YANG-encoded data commonly used by the Network Configuration Protocol (NETCONF). -/// -/// Constant alias for string: `"application/yang"`. -#[no_mangle] -pub extern "C" fn z_encoding_application_yang() -> &'static z_loaned_encoding_t { - Encoding::APPLICATION_YANG.as_loaned_c_type_ref() -} -/// A MPEG-4 Advanced Audio Coding (AAC) media. -/// -/// Constant alias for string: `"audio/aac"`. -#[no_mangle] -pub extern "C" fn z_encoding_audio_aac() -> &'static z_loaned_encoding_t { - Encoding::AUDIO_AAC.as_loaned_c_type_ref() -} -/// A Free Lossless Audio Codec (FLAC) media. -/// -/// Constant alias for string: `"audio/flac"`. -#[no_mangle] -pub extern "C" fn z_encoding_audio_flac() -> &'static z_loaned_encoding_t { - Encoding::AUDIO_FLAC.as_loaned_c_type_ref() -} -/// An audio codec defined in MPEG-1, MPEG-2, MPEG-4, or registered at the MP4 registration authority. -/// -/// Constant alias for string: `"audio/mp4"`. -#[no_mangle] -pub extern "C" fn z_encoding_audio_mp4() -> &'static z_loaned_encoding_t { - Encoding::AUDIO_MP4.as_loaned_c_type_ref() -} -/// An Ogg-encapsulated audio stream. -/// -/// Constant alias for string: `"audio/ogg"`. -#[no_mangle] -pub extern "C" fn z_encoding_audio_ogg() -> &'static z_loaned_encoding_t { - Encoding::AUDIO_OGG.as_loaned_c_type_ref() -} -/// A Vorbis-encoded audio stream. -/// -/// Constant alias for string: `"audio/vorbis"`. -#[no_mangle] -pub extern "C" fn z_encoding_audio_vorbis() -> &'static z_loaned_encoding_t { - Encoding::AUDIO_VORBIS.as_loaned_c_type_ref() -} -/// A h261-encoded video stream. -/// -/// Constant alias for string: `"video/h261"`. -#[no_mangle] -pub extern "C" fn z_encoding_video_h261() -> &'static z_loaned_encoding_t { - Encoding::VIDEO_H261.as_loaned_c_type_ref() -} -/// A h263-encoded video stream. -/// -/// Constant alias for string: `"video/h263"`. -#[no_mangle] -pub extern "C" fn z_encoding_video_h263() -> &'static z_loaned_encoding_t { - Encoding::VIDEO_H263.as_loaned_c_type_ref() -} -/// A h264-encoded video stream. -/// -/// Constant alias for string: `"video/h264"`. -#[no_mangle] -pub extern "C" fn z_encoding_video_h264() -> &'static z_loaned_encoding_t { - Encoding::VIDEO_H264.as_loaned_c_type_ref() -} -/// A h265-encoded video stream. -/// -/// Constant alias for string: `"video/h265"`. -#[no_mangle] -pub extern "C" fn z_encoding_video_h265() -> &'static z_loaned_encoding_t { - Encoding::VIDEO_H265.as_loaned_c_type_ref() -} -/// A h266-encoded video stream. -/// -/// Constant alias for string: `"video/h266"`. -#[no_mangle] -pub extern "C" fn z_encoding_video_h266() -> &'static z_loaned_encoding_t { - Encoding::VIDEO_H266.as_loaned_c_type_ref() -} -/// A video codec defined in MPEG-1, MPEG-2, MPEG-4, or registered at the MP4 registration authority. -/// -/// Constant alias for string: `"video/mp4"`. -#[no_mangle] -pub extern "C" fn z_encoding_video_mp4() -> &'static z_loaned_encoding_t { - Encoding::VIDEO_MP4.as_loaned_c_type_ref() -} -/// An Ogg-encapsulated video stream. -/// -/// Constant alias for string: `"video/ogg"`. -#[no_mangle] -pub extern "C" fn z_encoding_video_ogg() -> &'static z_loaned_encoding_t { - Encoding::VIDEO_OGG.as_loaned_c_type_ref() -} -/// An uncompressed, studio-quality video stream. -/// -/// Constant alias for string: `"video/raw"`. -#[no_mangle] -pub extern "C" fn z_encoding_video_raw() -> &'static z_loaned_encoding_t { - Encoding::VIDEO_RAW.as_loaned_c_type_ref() -} -/// A VP8-encoded video stream. -/// -/// Constant alias for string: `"video/vp8"`. -#[no_mangle] -pub extern "C" fn z_encoding_video_vp8() -> &'static z_loaned_encoding_t { - Encoding::VIDEO_VP8.as_loaned_c_type_ref() -} -/// A VP9-encoded video stream. -/// -/// Constant alias for string: `"video/vp9"`. -#[no_mangle] -pub extern "C" fn z_encoding_video_vp9() -> &'static z_loaned_encoding_t { - Encoding::VIDEO_VP9.as_loaned_c_type_ref() -} - -#[repr(C)] -pub struct zc_internal_encoding_data_t { - id: u16, - schema_ptr: *const u8, - schema_len: usize, -} - -#[no_mangle] -pub extern "C" fn zc_internal_encoding_get_data( - this: &'static z_loaned_encoding_t, -) -> zc_internal_encoding_data_t { - let encoding = this.as_rust_type_ref(); - let schema = encoding.schema(); - match schema { - Some(s) => zc_internal_encoding_data_t { - id: encoding.id(), - schema_ptr: s.as_ptr(), - schema_len: s.len(), - }, - None => zc_internal_encoding_data_t { - id: encoding.id(), - schema_ptr: null(), - schema_len: 0, - }, - } -} - -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn zc_internal_encoding_from_data( - this: &mut MaybeUninit, - data: zc_internal_encoding_data_t, -) { - let schema = (!data.schema_ptr.is_null() && data.schema_len > 0).then_some( - from_raw_parts(data.schema_ptr, data.schema_len) - .to_vec() - .into(), - ); - this.as_rust_type_mut_uninit() - .write(Encoding::new(data.id, schema)); -} diff --git a/src/get.rs b/src/get.rs deleted file mode 100644 index db1a20c6d..000000000 --- a/src/get.rs +++ /dev/null @@ -1,532 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::{ - mem::MaybeUninit, - ptr::{null, null_mut}, -}; - -use libc::c_char; -use zenoh::{ - qos::{CongestionControl, Priority}, - query::{ConsolidationMode, QueryConsolidation, QueryTarget, Reply, ReplyError, Selector}, - session::SessionClosedError, - Wait, -}; - -pub use crate::opaque_types::{z_loaned_reply_err_t, z_moved_reply_err_t, z_owned_reply_err_t}; -use crate::{ - result::{self, Z_EINVAL}, - strlen_or_zero, - transmute::{Gravestone, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_closure_reply_call, z_closure_reply_loan, z_congestion_control_t, z_consolidation_mode_t, - z_loaned_bytes_t, z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_sample_t, - z_loaned_session_t, z_moved_bytes_t, z_moved_closure_reply_t, z_moved_encoding_t, z_priority_t, - z_query_target_t, zc_locality_default, zc_locality_t, CStringView, -}; -#[cfg(feature = "unstable")] -use crate::{ - transmute::IntoCType, z_entity_global_id_t, z_moved_source_info_t, zc_reply_keyexpr_default, - zc_reply_keyexpr_t, -}; -decl_c_type!( - owned(z_owned_reply_err_t, ReplyError), - loaned(z_loaned_reply_err_t, ReplyError), -); - -impl Gravestone for ReplyError { - fn gravestone() -> Self { - ReplyError::empty() - } - fn is_gravestone(&self) -> bool { - self.payload().is_empty() - } -} - -/// Constructs an empty `z_owned_reply_err_t`. -#[no_mangle] -pub extern "C" fn z_internal_reply_err_null(this_: &mut MaybeUninit) { - this_ - .as_rust_type_mut_uninit() - .write(ReplyError::gravestone()); -} - -/// Returns ``true`` if reply error is in non-default state, ``false`` otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_internal_reply_err_check(this_: &'static z_owned_reply_err_t) -> bool { - !this_.as_rust_type_ref().is_gravestone() -} - -/// Returns reply error payload. -#[no_mangle] -pub extern "C" fn z_reply_err_payload(this_: &z_loaned_reply_err_t) -> &z_loaned_bytes_t { - this_.as_rust_type_ref().payload().as_loaned_c_type_ref() -} - -/// Returns mutable reply error payload. -#[no_mangle] -pub extern "C" fn z_reply_err_payload_mut( - this_: &mut z_loaned_reply_err_t, -) -> &mut z_loaned_bytes_t { - this_ - .as_rust_type_mut() - .payload_mut() - .as_loaned_c_type_mut() -} - -/// Returns reply error encoding. -#[no_mangle] -pub extern "C" fn z_reply_err_encoding(this_: &z_loaned_reply_err_t) -> &z_loaned_encoding_t { - this_.as_rust_type_ref().encoding().as_loaned_c_type_ref() -} - -/// Borrows reply error. -#[no_mangle] -pub extern "C" fn z_reply_err_loan(this_: &z_owned_reply_err_t) -> &z_loaned_reply_err_t { - this_.as_rust_type_ref().as_loaned_c_type_ref() -} - -/// Mutably borrows reply error. -#[no_mangle] -pub extern "C" fn z_reply_err_loan_mut( - this_: &mut z_owned_reply_err_t, -) -> &mut z_loaned_reply_err_t { - this_.as_rust_type_mut().as_loaned_c_type_mut() -} - -/// Frees the memory and resets the reply error it to its default value. -#[no_mangle] -pub extern "C" fn z_reply_err_drop(this_: &mut z_moved_reply_err_t) { - let _ = this_.take_rust_type(); -} - -pub use crate::opaque_types::{z_loaned_reply_t, z_moved_reply_t, z_owned_reply_t}; -decl_c_type!( - owned(z_owned_reply_t, option Reply), - loaned(z_loaned_reply_t), -); - -/// Returns ``true`` if reply contains a valid response, ``false`` otherwise (in this case it contains a errror value). -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_reply_is_ok(this_: &z_loaned_reply_t) -> bool { - this_.as_rust_type_ref().result().is_ok() -} - -/// Yields the contents of the reply by asserting it indicates a success. -/// -/// Returns `NULL` if reply does not contain a sample (i. e. if `z_reply_is_ok` returns ``false``). -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_reply_ok(this_: &z_loaned_reply_t) -> *const z_loaned_sample_t { - match this_.as_rust_type_ref().result() { - Ok(sample) => sample.as_loaned_c_type_ref() as _, - Err(_) => null(), - } -} - -/// Yields the contents of the reply by asserting it indicates a success. -/// -/// Returns `NULL` if reply does not contain a sample (i. e. if `z_reply_is_ok` returns ``false``). -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_reply_ok_mut(this_: &mut z_loaned_reply_t) -> *mut z_loaned_sample_t { - match this_.as_rust_type_mut().result_mut() { - Ok(sample) => sample.as_loaned_c_type_mut() as _, - Err(_) => null_mut(), - } -} - -/// Yields the contents of the reply by asserting it indicates a failure. -/// -/// Returns `NULL` if reply does not contain a error (i. e. if `z_reply_is_ok` returns ``true``). -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_reply_err(this_: &z_loaned_reply_t) -> *const z_loaned_reply_err_t { - match this_.as_rust_type_ref().result() { - Ok(_) => null(), - Err(v) => v.as_loaned_c_type_ref(), - } -} - -/// Yields the contents of the reply by asserting it indicates a failure. -/// -/// Returns `NULL` if reply does not contain a error (i. e. if `z_reply_is_ok` returns ``true``). -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_reply_err_mut( - this_: &mut z_loaned_reply_t, -) -> *mut z_loaned_reply_err_t { - match this_.as_rust_type_mut().result_mut() { - Ok(_) => null_mut(), - Err(v) => v.as_loaned_c_type_mut(), - } -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Gets the global id of the zenoh entity that answered this Reply. -/// @return `true` if id is present. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_reply_replier_id( - this: &z_loaned_reply_t, - out_id: &mut MaybeUninit, -) -> bool { - match this.as_rust_type_ref().replier_id() { - Some(val) => { - out_id.write(val.into_c_type()); - true - } - None => false, - } -} - -/// Constructs the reply in its gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_reply_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} -/// Constructs an owned shallow copy of reply in provided uninitialized memory location. -#[no_mangle] -pub extern "C" fn z_reply_clone(dst: &mut MaybeUninit, this_: &z_loaned_reply_t) { - dst.as_rust_type_mut_uninit() - .write(Some(this_.as_rust_type_ref().clone())); -} - -/// Options passed to the `z_get()` function. -#[repr(C)] -pub struct z_get_options_t { - /// The Queryables that should be target of the query. - pub target: z_query_target_t, - /// The replies consolidation strategy to apply on replies to the query. - pub consolidation: z_query_consolidation_t, - /// An optional payload to attach to the query. - pub payload: Option<&'static mut z_moved_bytes_t>, - /// An optional encoding of the query payload and or attachment. - pub encoding: Option<&'static mut z_moved_encoding_t>, - /// The congestion control to apply when routing the query. - pub congestion_control: z_congestion_control_t, - /// If set to ``true``, this message will not be batched. This usually has a positive impact on latency but negative impact on throughput. - pub is_express: bool, - /// The allowed destination for the query. - pub allowed_destination: zc_locality_t, - #[cfg(feature = "unstable")] - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - /// - /// The accepted replies for the query. - pub accept_replies: zc_reply_keyexpr_t, - /// The priority of the query. - pub priority: z_priority_t, - #[cfg(feature = "unstable")] - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - /// - /// The source info for the query. - pub source_info: Option<&'static mut z_moved_source_info_t>, - /// An optional attachment to attach to the query. - pub attachment: Option<&'static mut z_moved_bytes_t>, - /// The timeout for the query in milliseconds. 0 means default query timeout from zenoh configuration. - pub timeout_ms: u64, -} - -impl z_get_options_t { - fn clear(&mut self) { - if let Some(p) = self.payload.take() { - p.take_rust_type(); - } - if let Some(e) = self.encoding.take() { - e.take_rust_type(); - } - if let Some(a) = self.attachment.take() { - a.take_rust_type(); - } - #[cfg(feature = "unstable")] - if let Some(si) = self.source_info.take() { - si.take_rust_type(); - } - } -} - -/// Constructs default `z_get_options_t` -#[no_mangle] -pub extern "C" fn z_get_options_default(this_: &mut MaybeUninit) { - this_.write(z_get_options_t { - target: QueryTarget::default().into(), - consolidation: QueryConsolidation::default().into(), - congestion_control: CongestionControl::DEFAULT_REQUEST.into(), - allowed_destination: zc_locality_default(), - #[cfg(feature = "unstable")] - accept_replies: zc_reply_keyexpr_default(), - priority: Priority::default().into(), - is_express: false, - timeout_ms: 0, - payload: None, - encoding: None, - #[cfg(feature = "unstable")] - source_info: None, - attachment: None, - }); -} - -/// Query data from the matching queryables in the system. -/// Replies are provided through a callback function. -/// -/// @param session: The zenoh session. -/// @param key_expr: The key expression matching resources to query. -/// @param parameters: The query's parameters null-terminated string, similar to a url's query segment. -/// @param callback: The callback function that will be called on reception of replies for this query. It will be automatically dropped once all replies are processed. -/// @param options: Additional options for the get. All owned fields will be consumed. -/// -/// @return 0 in case of success, a negative error value upon failure. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_get( - session: &z_loaned_session_t, - key_expr: &z_loaned_keyexpr_t, - parameters: *const c_char, - callback: &mut z_moved_closure_reply_t, - options: Option<&mut z_get_options_t>, -) -> result::z_result_t { - z_get_with_parameters_substr( - session, - key_expr, - parameters, - strlen_or_zero(parameters), - callback, - options, - ) -} - -/// Query data from the matching queryables in the system. -/// Replies are provided through a callback function. -/// -/// @param session: The zenoh session. -/// @param key_expr: The key expression matching resources to query. -/// @param parameters: The query's parameters string, similar to a url's query segment. -/// @param parameters_len: The parameters substring length. -/// @param callback: The callback function that will be called on reception of replies for this query. It will be automatically dropped once all replies are processed. -/// @param options: Additional options for the get. All owned fields will be consumed. -/// -/// @return 0 in case of success, a negative error value upon failure. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_get_with_parameters_substr( - session: &z_loaned_session_t, - key_expr: &z_loaned_keyexpr_t, - parameters: *const c_char, - parameters_len: usize, - callback: &mut z_moved_closure_reply_t, - options: Option<&mut z_get_options_t>, -) -> result::z_result_t { - let callback = callback.take_rust_type(); - let pcs = match CStringView::new_borrowed(parameters as *const c_char, parameters_len) { - Ok(cs) => cs, - Err(r) => { - if let Some(o) = options { - o.clear(); - } - return r; - } - }; - - let p: &str = match (&pcs).try_into() { - Ok(s) => s, - Err(e) => { - if let Some(o) = options { - o.clear(); - } - crate::report_error!("Parameters is not a valid utf-8 string: {e}"); - return Z_EINVAL; - } - }; - - let session = session.as_rust_type_ref(); - let key_expr = key_expr.as_rust_type_ref(); - let mut get = session.get(Selector::from((key_expr, p))); - if let Some(options) = options { - if let Some(payload) = options.payload.take() { - get = get.payload(payload.take_rust_type()); - } - if let Some(encoding) = options.encoding.take() { - get = get.encoding(encoding.take_rust_type()); - } - #[cfg(feature = "unstable")] - if let Some(source_info) = options.source_info.take() { - get = get.source_info(source_info.take_rust_type()); - } - if let Some(attachment) = options.attachment.take() { - get = get.attachment(attachment.take_rust_type()); - } - - get = get - .consolidation(options.consolidation) - .target(options.target.into()) - .congestion_control(options.congestion_control.into()) - .priority(options.priority.into()) - .express(options.is_express); - #[cfg(feature = "unstable")] - { - get = get - .allowed_destination(options.allowed_destination.into()) - .accept_replies(options.accept_replies.into()); - } - - if options.timeout_ms != 0 { - get = get.timeout(std::time::Duration::from_millis(options.timeout_ms)); - } - } - match get - .callback(move |response| { - let mut owned_response = Some(response); - z_closure_reply_call( - z_closure_reply_loan(&callback), - owned_response - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut(), - ) - }) - .wait() - { - Ok(()) => result::Z_OK, - Err(e) if e.downcast_ref::().is_some() => result::Z_ESESSION_CLOSED, - Err(e) => { - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -/// Frees reply, resetting it to its gravestone state. -#[no_mangle] -pub extern "C" fn z_reply_drop(this_: &mut z_moved_reply_t) { - let _ = this_.take_rust_type(); -} - -/// Returns ``true`` if `reply` is valid, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_internal_reply_check(this_: &z_owned_reply_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// Borrows reply. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_reply_loan(this_: &z_owned_reply_t) -> &z_loaned_reply_t { - this_ - .as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// Mutably borrows reply. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_reply_loan_mut(this_: &mut z_owned_reply_t) -> &mut z_loaned_reply_t { - this_ - .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - -/// Takes ownership of the mutably borrowed reply -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_reply_take_from_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_reply_t, -) { - let dst = dst.as_rust_type_mut_uninit(); - let src = src.as_rust_type_mut(); - let src = std::mem::replace(src, Reply::empty()); - dst.write(Some(src)); -} - -/// The replies consolidation strategy to apply on replies to a `z_get()`. -#[repr(C)] -#[derive(Clone, Copy)] -pub struct z_query_consolidation_t { - pub mode: z_consolidation_mode_t, -} - -impl From for z_query_consolidation_t { - #[inline] - fn from(qc: QueryConsolidation) -> Self { - z_query_consolidation_t { - mode: qc.mode().into(), - } - } -} - -impl From for QueryConsolidation { - #[inline] - fn from(val: z_query_consolidation_t) -> Self { - let cm: ConsolidationMode = val.mode.into(); - cm.into() - } -} - -/// Creates a default `z_query_consolidation_t` (consolidation mode AUTO). -#[no_mangle] -pub extern "C" fn z_query_consolidation_default() -> z_query_consolidation_t { - QueryConsolidation::default().into() -} - -/// Automatic query consolidation strategy selection. -/// -/// A query consolidation strategy will automatically be selected depending the query selector. -/// If the selector contains time range properties, no consolidation is performed. -/// Otherwise the `z_query_consolidation_latest` strategy is used. -#[no_mangle] -pub extern "C" fn z_query_consolidation_auto() -> z_query_consolidation_t { - QueryConsolidation::AUTO.into() -} - -/// Latest consolidation. -/// -/// This strategy optimizes bandwidth on all links in the system but will provide a very poor latency. -#[no_mangle] -pub extern "C" fn z_query_consolidation_latest() -> z_query_consolidation_t { - QueryConsolidation::from(ConsolidationMode::Latest).into() -} - -/// Monotonic consolidation. -/// -/// This strategy offers the best latency. Replies are directly transmitted to the application when received -/// without needing to wait for all replies. This mode does not guarantee that there will be no duplicates. -#[no_mangle] -pub extern "C" fn z_query_consolidation_monotonic() -> z_query_consolidation_t { - QueryConsolidation::from(ConsolidationMode::Monotonic).into() -} - -/// No consolidation. -/// -/// This strategy is useful when querying timeseries data bases or when using quorums. -#[no_mangle] -pub extern "C" fn z_query_consolidation_none() -> z_query_consolidation_t { - QueryConsolidation::from(ConsolidationMode::None).into() -} - -/// Constructs a copy of the reply error message. -#[no_mangle] -extern "C" fn z_reply_err_clone( - dst: &mut MaybeUninit, - this: &z_loaned_reply_err_t, -) { - dst.as_rust_type_mut_uninit() - .write(this.as_rust_type_ref().clone()); -} diff --git a/src/info.rs b/src/info.rs deleted file mode 100644 index d056fc01b..000000000 --- a/src/info.rs +++ /dev/null @@ -1,90 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// -use std::mem::MaybeUninit; - -use zenoh::{session::ZenohId, Wait}; - -pub use crate::opaque_types::z_id_t; -use crate::{ - result, - transmute::{CTypeRef, IntoCType, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_closure_zid_call, z_closure_zid_loan, z_loaned_session_t, z_moved_closure_zid_t, - z_owned_string_t, -}; -decl_c_type!(copy(z_id_t, ZenohId)); - -impl From<[u8; 16]> for z_id_t { - fn from(value: [u8; 16]) -> Self { - z_id_t { id: value } - } -} - -/// @brief Formats the `z_id_t` into 16-digit hex string (LSB-first order) -#[no_mangle] -pub extern "C" fn z_id_to_string(zid: &z_id_t, dst: &mut MaybeUninit) { - let zid = zid.as_rust_type_ref(); - dst.as_rust_type_mut_uninit().write(zid.to_string().into()); -} - -/// @brief Returns the session's Zenoh ID. -/// -/// Unless the `session` is invalid, that ID is guaranteed to be non-zero. -/// In other words, this function returning an array of 16 zeros means you failed -/// to pass it a valid session. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_info_zid(session: &z_loaned_session_t) -> z_id_t { - let session = session.as_rust_type_ref(); - session.info().zid().wait().into_c_type() -} - -/// @brief Fetches the Zenoh IDs of all connected peers. -/// -/// `callback` will be called once for each ID, is guaranteed to never be called concurrently, -/// and is guaranteed to be dropped before this function exits. -/// -/// Retuns 0 on success, negative values on failure -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_info_peers_zid( - session: &z_loaned_session_t, - callback: &mut z_moved_closure_zid_t, -) -> result::z_result_t { - let session = session.as_rust_type_ref(); - let callback = callback.take_rust_type(); - for mut id in session.info().peers_zid().wait() { - z_closure_zid_call(z_closure_zid_loan(&callback), id.as_ctype_mut()); - } - result::Z_OK -} - -/// @brief Fetches the Zenoh IDs of all connected routers. -/// -/// `callback` will be called once for each ID, is guaranteed to never be called concurrently, -/// and is guaranteed to be dropped before this function exits. -/// -/// Retuns 0 on success, negative values on failure. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_info_routers_zid( - session: &z_loaned_session_t, - callback: &mut z_moved_closure_zid_t, -) -> result::z_result_t { - let session = session.as_rust_type_ref(); - let callback = callback.take_rust_type(); - for mut id in session.info().routers_zid().wait() { - z_closure_zid_call(z_closure_zid_loan(&callback), id.as_ctype_mut()); - } - result::Z_OK -} diff --git a/src/keyexpr.rs b/src/keyexpr.rs deleted file mode 100644 index 134c9ddee..000000000 --- a/src/keyexpr.rs +++ /dev/null @@ -1,629 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// -use std::{error::Error, mem::MaybeUninit}; - -use libc::c_char; -#[cfg(feature = "unstable")] -use zenoh::key_expr::SetIntersectionLevel; -use zenoh::{ - key_expr::{keyexpr, Canonize, KeyExpr}, - Wait, -}; - -pub use crate::opaque_types::{ - z_loaned_keyexpr_t, z_moved_keyexpr_t, z_owned_keyexpr_t, z_view_keyexpr_t, -}; -use crate::{ - result::{self, z_result_t, Z_OK}, - strlen_or_zero, - transmute::{Gravestone, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_loaned_session_t, z_view_string_from_substr, z_view_string_t, -}; - -decl_c_type! { - owned(z_owned_keyexpr_t, KeyExpr<'static>), - loaned(z_loaned_keyexpr_t), - view(z_view_keyexpr_t, KeyExpr<'static>), -} - -impl Gravestone for KeyExpr<'static> { - fn gravestone() -> Self { - KeyExpr::dummy() - } - fn is_gravestone(&self) -> bool { - self.is_dummy() - } -} - -/// Constructs an owned key expression in a gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_keyexpr_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(KeyExpr::gravestone()); -} - -/// Constructs a view key expression in empty state -#[no_mangle] -pub extern "C" fn z_view_keyexpr_empty(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(KeyExpr::gravestone()); -} - -fn keyexpr_create_inner( - mut name: &'static mut str, - should_auto_canonize: bool, - should_copy: bool, -) -> Result, Box> { - if should_copy { - let s = name.to_string(); - match should_auto_canonize { - true => KeyExpr::<'static>::autocanonize(s), - false => KeyExpr::<'static>::try_from(s), - } - } else { - if should_auto_canonize { - name.canonize(); - } - keyexpr::new(name).map(|k| k.into()) - } -} - -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -unsafe fn keyexpr_create( - name: &'static mut [u8], - should_auto_canonize: bool, - should_copy: bool, -) -> Result, result::z_result_t> { - match std::str::from_utf8_mut(name) { - Ok(name) => match keyexpr_create_inner(name, should_auto_canonize, should_copy) { - Ok(v) => Ok(v), - Err(e) => { - crate::report_error!("Couldn't construct keyexpr: {}", e); - Err(result::Z_EINVAL) - } - }, - Err(e) => { - crate::report_error!("Key expression is not a valid utf-8 string: {}", e); - Err(result::Z_EPARSE) - } - } -} - -/// Constructs a `z_owned_keyexpr_t` from a string, copying the passed string. -/// @return 0 in case of success, negative error code in case of failure (for example if `expr` is not a valid key expression or if it is -/// not in canon form. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_keyexpr_from_str( - this: &mut MaybeUninit, - expr: *const c_char, -) -> result::z_result_t { - z_keyexpr_from_substr(this, expr, strlen_or_zero(expr)) -} - -/// Constructs `z_owned_keyexpr_t` from a string, copying the passed string. The copied string is canonized. -/// @return 0 in case of success, negative error code in case of failure (for example if expr is not a valid key expression -/// even despite canonization). -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_keyexpr_from_str_autocanonize( - this: &mut MaybeUninit, - expr: *const c_char, -) -> z_result_t { - let mut len = strlen_or_zero(expr); - z_keyexpr_from_substr_autocanonize(this, expr, &mut len) -} - -/// Borrows `z_owned_keyexpr_t`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_keyexpr_loan(this_: &z_owned_keyexpr_t) -> &z_loaned_keyexpr_t { - this_.as_rust_type_ref().as_loaned_c_type_ref() -} - -/// Borrows `z_view_keyexpr_t`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_view_keyexpr_loan(this_: &z_view_keyexpr_t) -> &z_loaned_keyexpr_t { - this_.as_rust_type_ref().as_loaned_c_type_ref() -} - -/// Frees key expression and resets it to its gravestone state. -#[no_mangle] -pub extern "C" fn z_keyexpr_drop(this_: &mut z_moved_keyexpr_t) { - let _ = this_.take_rust_type(); -} - -/// Returns ``true`` if `keyexpr` is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_keyexpr_check(this_: &z_owned_keyexpr_t) -> bool { - !this_.as_rust_type_ref().is_gravestone() -} - -/// Returns ``true`` if `keyexpr` is valid, ``false`` if it is in gravestone state. -#[no_mangle] -pub extern "C" fn z_view_keyexpr_is_empty(this_: &z_view_keyexpr_t) -> bool { - this_.as_rust_type_ref().is_gravestone() -} - -/// Returns 0 if the passed string is a valid (and canon) key expression. -/// Otherwise returns negative error value. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_keyexpr_is_canon(start: *const c_char, len: usize) -> z_result_t { - let name = std::slice::from_raw_parts_mut(start as _, len); - match keyexpr_create(name, false, false) { - Ok(_) => result::Z_OK, - Err(e) => e, - } -} - -/// Canonizes the passed string in place, possibly shortening it by placing a new null-terminator. -/// May SEGFAULT if `start` is NULL or lies in read-only memory (as values initialized with string litterals do). -/// -/// @return 0 upon success, negative error values upon failure (if the passed string was an invalid -/// key expression for reasons other than a non-canon form). -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_keyexpr_canonize_null_terminated(start: *mut c_char) -> z_result_t { - let mut len = strlen_or_zero(start); - match z_keyexpr_canonize(start, &mut len) { - Z_OK => { - *start.add(len) = 0; - Z_OK - } - err => err, - } -} -/// Canonizes the passed string in place, possibly shortening it by modifying `len`. -/// -/// May SEGFAULT if `start` is NULL or lies in read-only memory (as values initialized with string litterals do). -/// -/// @return 0 upon success, negative error values upon failure (if the passed string was an invalid -/// key expression for reasons other than a non-canon form). -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_keyexpr_canonize(start: *mut c_char, len: &mut usize) -> z_result_t { - if start.is_null() { - crate::report_error!("Key expression can not be constructed from null string"); - return result::Z_EINVAL; - } - let name = std::slice::from_raw_parts_mut(start as _, *len); - match keyexpr_create(name, true, false) { - Ok(ke) => { - *len = ke.len(); - result::Z_OK - } - Err(e) => e, - } -} - -/// Constructs a `z_view_keyexpr_t` by aliasing a substring. -/// `expr` must outlive the constucted key expression. -/// -/// @param this_: An uninitialized location in memory where key expression will be constructed. -/// @param expr: A buffer with length >= `len`. -/// @param len: Number of characters from `expr` to consider. -/// @return 0 in case of success, negative error code otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_view_keyexpr_from_substr( - this: &mut MaybeUninit, - expr: *const c_char, - len: usize, -) -> z_result_t { - let this = this.as_rust_type_mut_uninit(); - if expr.is_null() { - this.write(KeyExpr::gravestone()); - return result::Z_EINVAL; - } - let expr = std::slice::from_raw_parts_mut(expr as _, len); - match keyexpr_create(expr, false, false) { - Ok(ke) => { - this.write(ke); - result::Z_OK - } - Err(e) => { - this.write(KeyExpr::gravestone()); - e - } - } -} - -/// Constructs a `z_owned_keyexpr_t` by copying a substring. -/// -/// @param this_: An uninitialized location in memory where key expression will be constructed. -/// @param expr: A buffer with length >= `len`. -/// @param len: Number of characters from `expr` to consider. -/// @return 0 in case of success, negative error code otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_keyexpr_from_substr( - this: &mut MaybeUninit, - expr: *const c_char, - len: usize, -) -> z_result_t { - let this = this.as_rust_type_mut_uninit(); - if expr.is_null() { - this.write(KeyExpr::gravestone()); - return result::Z_EINVAL; - } - let expr = std::slice::from_raw_parts_mut(expr as _, len); - match keyexpr_create(expr, false, true) { - Ok(ke) => { - this.write(ke); - result::Z_OK - } - Err(e) => { - this.write(KeyExpr::gravestone()); - e - } - } -} - -/// Constructs a `z_view_keyexpr_t` by aliasing a substring. -/// May SEGFAULT if `start` is NULL or lies in read-only memory (as values initialized with string litterals do). -/// `expr` must outlive the constucted key expression. -/// -/// @param this_: An uninitialized location in memory where key expression will be constructed -/// @param start: A buffer of with length >= `len`. -/// @param len: Number of characters from `expr` to consider. Will be modified to be equal to canonized key expression length. -/// @return 0 in case of success, negative error code otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_view_keyexpr_from_substr_autocanonize( - this: &mut MaybeUninit, - start: *mut c_char, - len: &mut usize, -) -> z_result_t { - let this = this.as_rust_type_mut_uninit(); - if start.is_null() { - this.write(KeyExpr::gravestone()); - return result::Z_EINVAL; - } - let name = std::slice::from_raw_parts_mut(start as _, *len); - - match keyexpr_create(name, true, false) { - Ok(ke) => { - *len = ke.len(); - this.write(ke); - result::Z_OK - } - Err(e) => { - this.write(KeyExpr::gravestone()); - e - } - } -} - -/// Constructs a `z_keyexpr_t` by copying a substring. -/// -/// @param this_: An uninitialized location in memory where key expression will be constructed. -/// @param start: A buffer of with length >= `len`. -/// @param len: Number of characters from `expr` to consider. Will be modified to be equal to canonized key expression length. -/// @return 0 in case of success, negative error code otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_keyexpr_from_substr_autocanonize( - this: &mut MaybeUninit, - start: *const c_char, - len: &mut usize, -) -> z_result_t { - let this = this.as_rust_type_mut_uninit(); - if start.is_null() { - this.write(KeyExpr::gravestone()); - return result::Z_EINVAL; - } - let name = std::slice::from_raw_parts_mut(start as _, *len); - - match keyexpr_create(name, true, true) { - Ok(ke) => { - *len = ke.len(); - this.write(ke); - result::Z_OK - } - Err(e) => { - this.write(KeyExpr::gravestone()); - e - } - } -} - -/// Constructs a `z_view_keyexpr_t` by aliasing a string. -/// @return 0 in case of success, negative error code in case of failure (for example if expr is not a valid key expression or if it is -/// not in canon form. -/// `expr` must outlive the constucted key expression. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_view_keyexpr_from_str( - this: &mut MaybeUninit, - expr: *const c_char, -) -> z_result_t { - if expr.is_null() { - this.as_rust_type_mut_uninit().write(KeyExpr::gravestone()); - result::Z_EINVAL - } else { - z_view_keyexpr_from_substr(this, expr, strlen_or_zero(expr)) - } -} - -/// Constructs a `z_view_keyexpr_t` by aliasing a string. -/// The string is canonized in-place before being passed to keyexpr, possibly shortening it by modifying `len`. -/// May SEGFAULT if `expr` is NULL or lies in read-only memory (as values initialized with string litterals do). -/// `expr` must outlive the constucted key expression. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_view_keyexpr_from_str_autocanonize( - this: &mut MaybeUninit, - expr: *mut c_char, -) -> z_result_t { - let mut len = strlen_or_zero(expr); - let res = z_view_keyexpr_from_substr_autocanonize(this, expr, &mut len); - if res == result::Z_OK { - *expr.add(len) = 0; - } - res -} - -/// Constructs a `z_view_keyexpr_t` by aliasing a substring without checking any of `z_view_keyexpr_t`'s assertions: -/// -/// - `start` MUST be valid UTF8. -/// - `start` MUST follow the Key Expression specification, i.e.: -/// - MUST NOT contain ``//``, MUST NOT start nor end with ``/``, MUST NOT contain any of the characters ``?#$``. -/// - any instance of ``**`` may only be lead or followed by ``/``. -/// - the key expression must have canon form. -/// -/// `start` must outlive constructed key expression. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_view_keyexpr_from_substr_unchecked( - this: &mut MaybeUninit, - start: *const c_char, - len: usize, -) { - if start.is_null() { - this.as_rust_type_mut_uninit().write(KeyExpr::gravestone()); - return; - } - let name = std::slice::from_raw_parts(start as _, len); - let name = std::str::from_utf8_unchecked(name); - let name: KeyExpr = keyexpr::from_str_unchecked(name).into(); - this.as_rust_type_mut_uninit().write(name); -} - -/// Constructs a `z_view_keyexpr_t` by aliasing a string without checking any of `z_view_keyexpr_t`'s assertions: -/// -/// - `s` MUST be valid UTF8. -/// - `s` MUST follow the Key Expression specification, i.e.: -/// - MUST NOT contain `//`, MUST NOT start nor end with `/`, MUST NOT contain any of the characters `?#$`. -/// - any instance of `**` may only be lead or followed by `/`. -/// - the key expression must have canon form. -/// -/// `s` must outlive constructed key expression. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_view_keyexpr_from_str_unchecked( - this: &mut MaybeUninit, - s: *const c_char, -) { - z_view_keyexpr_from_substr_unchecked(this, s, strlen_or_zero(s)) -} - -/// Constructs a non-owned non-null-terminated string from key expression. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_keyexpr_as_view_string( - this: &z_loaned_keyexpr_t, - out_string: &mut MaybeUninit, -) { - let this = this.as_rust_type_ref(); - unsafe { z_view_string_from_substr(out_string, this.as_bytes().as_ptr() as _, this.len()) }; -} - -/// Constructs and declares a key expression on the network. This reduces key key expression to a numerical id, -/// which allows to save the bandwitdth, when passing key expression between Zenoh entities. -/// -/// @param session: Session on which to declare key expression. -/// @param declared_key_expr: An uninitialized location in memory where key expression will be constructed. -/// @param key_expr: Key expression to declare on network. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn z_declare_keyexpr( - session: &z_loaned_session_t, - declared_key_expr: &mut MaybeUninit, - key_expr: &z_loaned_keyexpr_t, -) -> z_result_t { - let this = declared_key_expr.as_rust_type_mut_uninit(); - let key_expr = key_expr.as_rust_type_ref(); - let session = session.as_rust_type_ref(); - match session.declare_keyexpr(key_expr).wait() { - Ok(id) => { - this.write(id.into_owned()); - result::Z_OK - } - Err(e) => { - tracing::debug!("{}", e); - this.write(KeyExpr::gravestone()); - result::Z_EGENERIC - } - } -} - -/// Undeclares the key expression generated by a call to `z_declare_keyexpr()`. -/// The key expression is consumed. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn z_undeclare_keyexpr( - session: &z_loaned_session_t, - key_expr: &mut z_moved_keyexpr_t, -) -> result::z_result_t { - let kexpr = key_expr.take_rust_type(); - if kexpr.is_gravestone() { - tracing::debug!("Attempted to undeclare dropped keyexpr"); - return result::Z_EINVAL; - }; - let session = session.as_rust_type_ref(); - match session.undeclare(kexpr).wait() { - Ok(()) => result::Z_OK, - Err(e) => { - tracing::debug!("{}", e); - result::Z_EGENERIC - } - } -} - -/// Returns ``true`` if both ``left`` and ``right`` are equal, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_keyexpr_equals(left: &z_loaned_keyexpr_t, right: &z_loaned_keyexpr_t) -> bool { - let l = left.as_rust_type_ref(); - let r = right.as_rust_type_ref(); - *l == *r -} - -/// Returns ``true`` if the keyexprs intersect, i.e. there exists at least one key which is contained in both of the -/// sets defined by ``left`` and ``right``, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_keyexpr_intersects( - left: &z_loaned_keyexpr_t, - right: &z_loaned_keyexpr_t, -) -> bool { - let l = left.as_rust_type_ref(); - let r = right.as_rust_type_ref(); - l.intersects(r) -} - -/// Returns ``true`` if ``left`` includes ``right``, i.e. the set defined by ``left`` contains every key belonging to the set -/// defined by ``right``, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_keyexpr_includes( - left: &z_loaned_keyexpr_t, - right: &z_loaned_keyexpr_t, -) -> bool { - let l = left.as_rust_type_ref(); - let r = right.as_rust_type_ref(); - l.includes(r) -} - -/// Constructs key expression by concatenation of key expression in `left` with a string in `right`. -/// Returns 0 in case of success, negative error code otherwise. -/// -/// You should probably prefer `z_keyexpr_join` as Zenoh may then take advantage of the hierachical separation it inserts. -/// To avoid odd behaviors, concatenating a key expression starting with `*` to one ending with `*` is forbidden by this operation, -/// as this would extremely likely cause bugs. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_keyexpr_concat( - this: &mut MaybeUninit, - left: &z_loaned_keyexpr_t, - right_start: *const c_char, - right_len: usize, -) -> result::z_result_t { - let this = this.as_rust_type_mut_uninit(); - let left = left.as_rust_type_ref(); - let right = std::slice::from_raw_parts(right_start as _, right_len); - let right = match std::str::from_utf8(right) { - Ok(r) => r, - Err(e) => { - crate::report_error!( - "Couldn't concatenate {:02x?} to {} because it is not valid UTF8: {}", - right, - left, - e - ); - this.write(KeyExpr::gravestone()); - return result::Z_EINVAL; - } - }; - match left.concat(right) { - Ok(result) => { - this.write(result); - result::Z_OK - } - Err(e) => { - crate::report_error!("{}", e); - this.write(KeyExpr::gravestone()); - result::Z_EGENERIC - } - } -} - -/// Constructs key expression by performing path-joining (automatically inserting '/' in-between) of `left` with `right`. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn z_keyexpr_join( - this: &mut MaybeUninit, - left: &z_loaned_keyexpr_t, - right: &z_loaned_keyexpr_t, -) -> result::z_result_t { - let left = left.as_rust_type_ref(); - let right = right.as_rust_type_ref(); - let this = this.as_rust_type_mut_uninit(); - match left.join(right.as_str()) { - Ok(result) => { - this.write(result); - result::Z_OK - } - Err(e) => { - crate::report_error!("{}", e); - this.write(KeyExpr::gravestone()); - result::Z_EGENERIC - } - } -} -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Intersection level of 2 key expressions. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[repr(C)] -pub enum z_keyexpr_intersection_level_t { - /// 2 key expressions do not intersect. - DISJOINT = 0, - /// 2 key expressions intersect, i.e. there exists at least one key expression that is included by both. - INTERSECTS = 1, - /// First key expression is the superset of second one. - INCLUDES = 2, - /// 2 key expressions are equal. - EQUALS = 3, -} -#[cfg(feature = "unstable")] -impl From for z_keyexpr_intersection_level_t { - fn from(val: SetIntersectionLevel) -> Self { - match val { - SetIntersectionLevel::Disjoint => z_keyexpr_intersection_level_t::DISJOINT, - SetIntersectionLevel::Intersects => z_keyexpr_intersection_level_t::INTERSECTS, - SetIntersectionLevel::Includes => z_keyexpr_intersection_level_t::INCLUDES, - SetIntersectionLevel::Equals => z_keyexpr_intersection_level_t::EQUALS, - } - } -} -#[cfg(feature = "unstable")] -#[no_mangle] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns the relation between `left` and `right` from `left`'s point of view. -/// -/// @note This is slower than `z_keyexpr_intersects` and `keyexpr_includes`, so you should favor these methods for most applications. -pub extern "C" fn z_keyexpr_relation_to( - left: &z_loaned_keyexpr_t, - right: &z_loaned_keyexpr_t, -) -> z_keyexpr_intersection_level_t { - let l = left.as_rust_type_ref(); - let r = right.as_rust_type_ref(); - l.relation_to(r).into() -} - -/// Constructs a copy of the key expression. -#[no_mangle] -extern "C" fn z_keyexpr_clone(dst: &mut MaybeUninit, this: &z_loaned_keyexpr_t) { - dst.as_rust_type_mut_uninit() - .write(this.as_rust_type_ref().clone()); -} diff --git a/src/lib.rs b/src/lib.rs index b6cf266d5..6519d595a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ // -// Copyright (c) 2017, 2022 ZettaScale Technology. +// Copyright (c) 2017, 2025 ZettaScale Technology. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License 2.0 which is available at @@ -13,225 +13,4 @@ // #![allow(non_camel_case_types)] - -use std::{cmp::min, slice}; - -use libc::c_void; - -use crate::transmute::{LoanedCTypeRef, TakeRustType}; -#[macro_use] -mod transmute; -pub mod opaque_types; -pub use crate::opaque_types::*; - -mod collections; -pub mod result; -pub use crate::collections::*; -mod config; -pub use crate::config::*; -#[cfg(feature = "unstable")] -mod close; -#[cfg(feature = "unstable")] -pub use crate::close::*; -pub mod encoding; -pub use crate::encoding::*; -mod commons; -pub use crate::commons::*; -mod zbytes; -pub use crate::zbytes::*; -mod keyexpr; -pub use crate::keyexpr::*; -mod info; -pub use crate::info::*; -mod get; -pub use crate::get::*; -mod querier; -pub use crate::querier::*; -mod queryable; -pub use crate::queryable::*; -mod put; -pub use crate::put::*; -mod scouting; -pub use crate::scouting::*; -mod session; -pub use crate::session::*; -mod subscriber; -pub use crate::subscriber::*; -mod publisher; -pub use crate::publisher::*; -mod closures; -pub use closures::*; -pub mod platform; -pub use platform::*; -mod liveliness; -pub use liveliness::*; -mod matching; -pub use matching::*; -#[cfg(feature = "unstable")] -mod publication_cache; -#[cfg(feature = "unstable")] -pub use publication_cache::*; -#[cfg(feature = "unstable")] -mod querying_subscriber; -#[cfg(feature = "unstable")] -pub use querying_subscriber::*; -#[cfg(feature = "unstable")] -mod advanced_subscriber; -#[cfg(feature = "unstable")] -pub use advanced_subscriber::*; -#[cfg(feature = "unstable")] -mod advanced_publisher; -#[cfg(feature = "unstable")] -pub use advanced_publisher::*; -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -pub mod context; - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -pub mod shm; - -mod serialization; - -// This is the entry point for zenoh-c -// When compiling normal Rust executable, it includes rusty entry point `lang_start` that internally -// calls `std::rt::init()` that is intended to initialize some of the internals for Rust and std. -// However, when Rust library is used with non-rusty executable (this is exactly zenoh-c's case), -// there will be no rusty `lang_start` entry point and our rusty code will run without some initialization -// that is done there. In most of the cases this is OK, but sometimes lack of this initialization bites us. -// This entry point is made as a replacement for our case and contains some necessary init. -#[cfg(unix)] -#[ctor::ctor] -fn alternative_rusty_entry_point() { - // See - // https://github.com/eclipse-zenoh/zenoh-c/issues/294#issuecomment-2783671006 - // and - // https://github.com/rust-lang/rust/issues/62569 - unsafe { - libc::signal(libc::SIGPIPE, libc::SIG_IGN); - } - - // TODO: do we need to call zenoh::try_init_log_from_env(); here??? -} - -/// Initializes the zenoh runtime logger, using rust environment settings. -/// E.g.: `RUST_LOG=info` will enable logging at info level. Similarly, you can set the variable to `error` or `debug`. -/// -/// Note that if the environment variable is not set, then logging will not be enabled. -/// See https://docs.rs/env_logger/latest/env_logger/index.html for accepted filter format. -#[no_mangle] -pub extern "C" fn zc_try_init_log_from_env() { - zenoh::try_init_log_from_env(); -} - -/// Initializes the zenoh runtime logger, using rust environment settings or the provided fallback level. -/// E.g.: `RUST_LOG=info` will enable logging at info level. Similarly, you can set the variable to `error` or `debug`. -/// -/// Note that if the environment variable is not set, then fallback filter will be used instead. -/// See https://docs.rs/env_logger/latest/env_logger/index.html for accepted filter format. -/// -/// @param fallback_filter: The fallback filter if the `RUST_LOG` environment variable is not set. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn zc_init_log_from_env_or( - fallback_filter: *const libc::c_char, -) -> result::z_result_t { - match std::ffi::CStr::from_ptr(fallback_filter).to_str() { - Ok(s) => { - zenoh::init_log_from_env_or(s); - result::Z_OK - } - Err(_) => result::Z_EINVAL, - } -} - -/// Initializes the zenoh runtime logger with custom callback. -/// -/// @param min_severity: Minimum severity level of log message to be be passed to the `callback`. -/// Messages with lower severity levels will be ignored. -/// @param callback: A closure that will be called with each log message severity level and content. -#[no_mangle] -pub extern "C" fn zc_init_log_with_callback( - min_severity: zc_log_severity_t, - callback: &mut zc_moved_closure_log_t, -) { - let callback = callback.take_rust_type(); - zenoh_util::log::init_log_with_callback( - move |meta| min_severity <= (*meta.level()).into(), - move |record| { - if let Some(s) = record.message.as_ref() { - let c = CStringView::new_borrowed_from_slice(s.as_bytes()); - zc_closure_log_call( - zc_closure_log_loan(&callback), - record.level.into(), - c.as_loaned_c_type_ref(), - ); - } - }, - ); -} - -// Test should be runned with `cargo test --no-default-features` -#[test] -#[cfg(not(feature = "default"))] -fn test_no_default_features() { - assert_eq!( - zenoh::FEATURES, - concat!( - // " zenoh/auth_pubkey", - // " zenoh/auth_usrpwd", - // " zenoh/complete_n", - //" zenoh/shared-memory", - // " zenoh/stats", - // " zenoh/transport_multilink", - // " zenoh/transport_quic", - // " zenoh/transport_serial", - // " zenoh/transport_unixpipe", - // " zenoh/transport_tcp", - // " zenoh/transport_tls", - // " zenoh/transport_udp", - // " zenoh/transport_unixsock-stream", - // " zenoh/transport_ws", - // " zenoh/unstable", - // " zenoh/default", - ) - ); -} - -trait CopyableToCArray { - fn copy_to_c_array(&self, buf: *mut c_void, len: usize) -> usize; -} - -impl CopyableToCArray for &[u8] { - fn copy_to_c_array(&self, buf: *mut c_void, len: usize) -> usize { - if buf.is_null() || (len == 0 && !self.is_empty()) { - return 0; - } - - let max_len = min(len, self.len()); - let b = unsafe { slice::from_raw_parts_mut(buf as *mut u8, max_len) }; - b[0..max_len].copy_from_slice(&self[0..max_len]); - max_len - } -} - -impl CopyableToCArray for &str { - fn copy_to_c_array(&self, buf: *mut c_void, len: usize) -> usize { - self.as_bytes().copy_to_c_array(buf, len) - } -} - -/// Stops all Zenoh tasks and drops all related static variables. -/// All Zenoh-related structures should be properly dropped/undeclared PRIOR to this call. -/// None of Zenoh functionality can be used after this call. -/// Useful to suppress memory leaks messages due to Zenoh static variables (since they are never destroyed due to Rust language design). -#[no_mangle] -pub extern "C" fn zc_stop_z_runtime() { - let _z = zenoh_runtime::ZRuntimePoolGuard; -} - -#[allow(clippy::missing_safety_doc)] -pub(crate) unsafe fn strlen_or_zero(ptr: *const libc::c_char) -> usize { - match ptr.is_null() { - true => 0, - false => libc::strlen(ptr), - } -} +include!(concat!(env!("OUT_DIR"), "/zenoh_ffi.rs")); diff --git a/src/liveliness.rs b/src/liveliness.rs deleted file mode 100644 index 10d0efd28..000000000 --- a/src/liveliness.rs +++ /dev/null @@ -1,276 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use std::mem::MaybeUninit; - -use zenoh::{ - handlers::Callback, - liveliness::{LivelinessSubscriberBuilder, LivelinessToken}, - sample::Sample, - Wait, -}; - -use crate::{ - opaque_types::{z_loaned_liveliness_token_t, z_owned_liveliness_token_t}, - result, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_closure_reply_call, z_closure_reply_loan, z_closure_sample_call, z_closure_sample_loan, - z_loaned_keyexpr_t, z_loaned_session_t, z_moved_closure_reply_t, z_moved_closure_sample_t, - z_moved_liveliness_token_t, z_owned_subscriber_t, -}; -decl_c_type!( - owned(z_owned_liveliness_token_t, option LivelinessToken), - loaned(z_loaned_liveliness_token_t), -); - -/// @brief Constructs liveliness token in its gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_liveliness_token_null( - this_: &mut MaybeUninit, -) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @brief Returns ``true`` if liveliness token is valid, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_internal_liveliness_token_check(this_: &z_owned_liveliness_token_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @brief Undeclares liveliness token, frees memory and resets it to a gravestone state. -#[no_mangle] -pub extern "C" fn z_liveliness_token_drop(this_: &mut z_moved_liveliness_token_t) { - let _ = this_.take_rust_type(); -} - -/// @brief The options for `z_liveliness_declare_token()`. -#[repr(C)] -pub struct z_liveliness_token_options_t { - _dummy: u8, -} - -/// @brief Constructs default value for `z_liveliness_token_options_t`. -#[no_mangle] -pub extern "C" fn z_liveliness_token_options_default( - this: &mut MaybeUninit, -) { - this.write(z_liveliness_token_options_t { _dummy: 0 }); -} - -/// @brief Borrows token. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_liveliness_token_loan( - this: &z_owned_liveliness_token_t, -) -> &z_loaned_liveliness_token_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// @brief Constructs and declares a liveliness token on the network. -/// -/// Liveliness token subscribers on an intersecting key expression will receive a PUT sample when connectivity -/// is achieved, and a DELETE sample if it's lost. -/// -/// @param session: A Zenos session to declare the liveliness token. -/// @param token: An uninitialized memory location where liveliness token will be constructed. -/// @param key_expr: A keyexpr to declare a liveliess token for. -/// @param _options: Liveliness token declaration properties. -#[no_mangle] -pub extern "C" fn z_liveliness_declare_token( - session: &z_loaned_session_t, - token: &mut MaybeUninit, - key_expr: &z_loaned_keyexpr_t, - _options: Option<&z_liveliness_token_options_t>, -) -> result::z_result_t { - let this = token.as_rust_type_mut_uninit(); - let session = session.as_rust_type_ref(); - let key_expr = key_expr.as_rust_type_ref(); - match session.liveliness().declare_token(key_expr).wait() { - Ok(token) => { - this.write(Some(token)); - result::Z_OK - } - Err(e) => { - crate::report_error!("Failed to undeclare liveliness token: {e}"); - this.write(None); - result::Z_EGENERIC - } - } -} - -/// @brief Destroys a liveliness token, notifying subscribers of its destruction. -#[no_mangle] -pub extern "C" fn z_liveliness_undeclare_token( - this: &mut z_moved_liveliness_token_t, -) -> result::z_result_t { - if let Some(token) = this.take_rust_type() { - if let Err(e) = token.undeclare().wait() { - crate::report_error!("Failed to undeclare token: {e}"); - return result::Z_EGENERIC; - } - } - result::Z_OK -} - -/// @brief The options for `z_liveliness_declare_subscriber()` -#[repr(C)] -pub struct z_liveliness_subscriber_options_t { - /// If true, subscriber will receive the state change notifications for liveliness tokens that were declared before its declaration. - pub history: bool, -} - -/// @brief Constucts default value for `z_liveliness_declare_subscriber_options_t`. -#[no_mangle] -pub extern "C" fn z_liveliness_subscriber_options_default( - this: &mut MaybeUninit, -) { - this.write(z_liveliness_subscriber_options_t { history: false }); -} - -fn _liveliness_declare_subscriber_inner<'a, 'b>( - session: &'a z_loaned_session_t, - key_expr: &'b z_loaned_keyexpr_t, - callback: &mut z_moved_closure_sample_t, - options: Option<&mut z_liveliness_subscriber_options_t>, -) -> LivelinessSubscriberBuilder<'a, 'b, Callback> { - let session = session.as_rust_type_ref(); - let key_expr = key_expr.as_rust_type_ref(); - let callback = callback.take_rust_type(); - let sub = session - .liveliness() - .declare_subscriber(key_expr) - .history(options.is_some_and(|o| o.history)) - .callback(move |sample| { - let mut owned_sample = Some(sample); - z_closure_sample_call(z_closure_sample_loan(&callback), unsafe { - owned_sample - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() - }) - }); - sub -} -/// @brief Declares a subscriber on liveliness tokens that intersect `key_expr`. -/// -/// @param session: A Zenoh session. -/// @param subscriber: An uninitialized memory location where subscriber will be constructed. -/// @param key_expr: The key expression to subscribe to. -/// @param callback: The callback function that will be called each time a liveliness token status is changed. -/// @param options: The options to be passed to the liveliness subscriber declaration. -/// -/// @return 0 in case of success, negative error values otherwise. -#[no_mangle] -pub extern "C" fn z_liveliness_declare_subscriber( - session: &z_loaned_session_t, - subscriber: &mut MaybeUninit, - key_expr: &z_loaned_keyexpr_t, - callback: &mut z_moved_closure_sample_t, - options: Option<&mut z_liveliness_subscriber_options_t>, -) -> result::z_result_t { - let this = subscriber.as_rust_type_mut_uninit(); - let subscriber = _liveliness_declare_subscriber_inner(session, key_expr, callback, options); - match subscriber.wait() { - Ok(subscriber) => { - this.write(Some(subscriber)); - result::Z_OK - } - Err(e) => { - crate::report_error!("Failed to subscribe to liveliness: {e}"); - this.write(None); - result::Z_EGENERIC - } - } -} - -/// @brief Declares a background subscriber on liveliness tokens that intersect `key_expr`. Subscriber callback will be called to process the messages, -/// until the corresponding session is closed or dropped. -/// @param session: The Zenoh session. -/// @param key_expr: The key expression to subscribe to. -/// @param callback: The callback function that will be called each time a liveliness token status is changed. -/// @param options: The options to be passed to the liveliness subscriber declaration. -/// -/// @return 0 in case of success, negative error values otherwise. -#[no_mangle] -pub extern "C" fn z_liveliness_declare_background_subscriber( - session: &z_loaned_session_t, - key_expr: &z_loaned_keyexpr_t, - callback: &mut z_moved_closure_sample_t, - options: Option<&mut z_liveliness_subscriber_options_t>, -) -> result::z_result_t { - let subscriber = _liveliness_declare_subscriber_inner(session, key_expr, callback, options); - match subscriber.background().wait() { - Ok(_) => result::Z_OK, - Err(e) => { - crate::report_error!("Failed to subscribe to liveliness: {e}"); - result::Z_EGENERIC - } - } -} - -/// @brief The options for `z_liveliness_get()` -#[repr(C)] -pub struct z_liveliness_get_options_t { - /// The timeout for the liveliness query in milliseconds. 0 means default query timeout from zenoh configuration. - timeout_ms: u64, -} - -/// @brief Constructs default value `z_liveliness_get_options_t`. -#[no_mangle] -pub extern "C" fn z_liveliness_get_options_default( - this: &mut MaybeUninit, -) { - this.write(z_liveliness_get_options_t { timeout_ms: 10000 }); -} - -/// @brief Queries liveliness tokens currently on the network with a key expression intersecting with `key_expr`. -/// -/// @param session: The Zenoh session. -/// @param key_expr: The key expression to query liveliness tokens for. -/// @param callback: The callback function that will be called for each received reply. -/// @param options: Additional options for the liveliness get operation. -#[no_mangle] -pub extern "C" fn z_liveliness_get( - session: &z_loaned_session_t, - key_expr: &z_loaned_keyexpr_t, - callback: &mut z_moved_closure_reply_t, - options: Option<&mut z_liveliness_get_options_t>, -) -> result::z_result_t { - let session = session.as_rust_type_ref(); - let key_expr = key_expr.as_rust_type_ref(); - let callback = callback.take_rust_type(); - let liveliness = session.liveliness(); - let mut builder = liveliness.get(key_expr).callback(move |response| { - let mut owned_response = Some(response); - z_closure_reply_call(z_closure_reply_loan(&callback), unsafe { - owned_response - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() - }) - }); - if let Some(options) = options { - builder = builder.timeout(core::time::Duration::from_millis(options.timeout_ms)); - } - match builder.wait() { - Ok(()) => result::Z_OK, - Err(e) => { - crate::report_error!("Failed to subscribe to liveliness: {e}"); - result::Z_EGENERIC - } - } -} diff --git a/src/matching.rs b/src/matching.rs deleted file mode 100644 index 2b56baee0..000000000 --- a/src/matching.rs +++ /dev/null @@ -1,71 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::mem::MaybeUninit; - -use zenoh::{matching::MatchingListener, Wait}; - -pub use crate::opaque_types::{z_moved_matching_listener_t, z_owned_matching_listener_t}; -use crate::{ - result, - transmute::{RustTypeRef, RustTypeRefUninit, TakeRustType}, -}; -decl_c_type!( - owned(z_owned_matching_listener_t, option MatchingListener<()>), -); - -#[no_mangle] -/// @brief Constructs an empty matching listener. -pub extern "C" fn z_internal_matching_listener_null( - this_: &mut MaybeUninit, -) { - this_.as_rust_type_mut_uninit().write(None); -} - -#[no_mangle] -/// @brief Checks the matching listener is for the gravestone state -pub extern "C" fn z_internal_matching_listener_check(this_: &z_owned_matching_listener_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @brief A struct that indicates if there exist Subscribers matching the Publisher's key expression or Queryables matching Querier's key expression and target. -#[repr(C)] -#[derive(Debug, Clone, Copy)] -pub struct z_matching_status_t { - /// True if there exist matching Zenoh entities, false otherwise. - pub matching: bool, -} - -/// @brief Undeclares the given matching listener, droping and invalidating it. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_matching_listener_drop(this: &mut z_moved_matching_listener_t) { - std::mem::drop(this.take_rust_type()) -} - -/// @brief Undeclares the given matching listener, droping and invalidating it. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_undeclare_matching_listener( - this: &mut z_moved_matching_listener_t, -) -> result::z_result_t { - if let Some(m) = this.take_rust_type() { - if let Err(e) = m.undeclare().wait() { - crate::report_error!("{}", e); - return result::Z_ENETWORK; - } - } - result::Z_OK -} diff --git a/src/opaque_types/mod.rs b/src/opaque_types/mod.rs deleted file mode 100644 index 2e937399d..000000000 --- a/src/opaque_types/mod.rs +++ /dev/null @@ -1 +0,0 @@ -include!(concat!(env!("OUT_DIR"), "/opaque_types.rs")); diff --git a/src/platform/clock.rs b/src/platform/clock.rs deleted file mode 100644 index 39a908903..000000000 --- a/src/platform/clock.rs +++ /dev/null @@ -1,143 +0,0 @@ -use std::{ - os::raw::c_void, - time::{Duration, Instant, SystemTime, UNIX_EPOCH}, -}; - -use chrono::{DateTime, Local}; -use lazy_static::lazy_static; -use libc::c_char; - -use crate::CopyableToCArray; - -// Use initial time stored in static variable as a reference time, -// to be able to return number of ns passed since. -// This is to avoid wrapping Instant into a c type and not -// have to account for its platform-dependent size and alignment. -lazy_static! { - static ref CLOCK_BASE: Instant = Instant::now(); -} - -/// Monotonic clock -#[repr(C)] -#[derive(Clone, Copy)] -pub struct z_clock_t { - t: u64, - t_base: *const c_void, -} - -/// Returns monotonic clock time point corresponding to the current time instant. -#[no_mangle] -pub extern "C" fn z_clock_now() -> z_clock_t { - z_clock_t { - t: CLOCK_BASE.elapsed().as_nanos() as u64, - t_base: &CLOCK_BASE as *const CLOCK_BASE as *const c_void, - } -} - -/// Get number of nanoseconds passed since creation of `time`. -#[allow(clippy::missing_safety_doc)] -unsafe fn get_elapsed_nanos(time: *const z_clock_t) -> u64 { - if time.is_null() { - return 0; - } - let now_t = (*((*time).t_base as *const CLOCK_BASE)) - .elapsed() - .as_nanos() as u64; - if now_t > (*time).t { - now_t - (*time).t - } else { - 0 - } -} - -/// Get number of seconds passed since creation of `time`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_clock_elapsed_s(time: *const z_clock_t) -> u64 { - get_elapsed_nanos(time) / 1_000_000_000 -} - -/// Get number of milliseconds passed since creation of `time`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_clock_elapsed_ms(time: *const z_clock_t) -> u64 { - get_elapsed_nanos(time) / 1_000_000 -} - -/// Get number of microseconds passed since creation of `time`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_clock_elapsed_us(time: *const z_clock_t) -> u64 { - get_elapsed_nanos(time) / 1_000 -} - -/// Returns system clock time point corresponding to the current time instant. -#[repr(C)] -#[derive(Clone, Copy)] -pub struct z_time_t { - t: u64, -} - -/// Converts current system time into null-terminated human readable string and writes it to the `buf`. -/// -/// @param buf: A buffer where the string will be writtent -/// @param len: Maximum number of characters to write (including terminating 0). The string will be truncated -/// if it is longer than `len`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_time_now_as_str(buf: *const c_char, len: usize) -> *const c_char { - if len == 0 || buf.is_null() { - return buf; - } - let datetime: DateTime = SystemTime::now().into(); - let s = datetime.format("%Y-%m-%dT%H:%M:%SZ").to_string(); - let res = s.as_str().copy_to_c_array(buf as *mut c_void, len - 1); - *((buf as usize + res) as *mut c_char) = 0; - buf -} - -/// Initialize clock with current time instant. -#[no_mangle] -pub extern "C" fn z_time_now() -> z_time_t { - z_time_t { - t: SystemTime::now() - .duration_since(UNIX_EPOCH) - .unwrap_or(Duration::new(0, 0)) - .as_nanos() as u64, - } -} - -/// Get number of nanoseconds passed since creation of `time`. -#[allow(clippy::missing_safety_doc)] -unsafe fn get_elapsed_nanos_system_clock(time: *const z_time_t) -> u64 { - if time.is_null() { - return 0; - } - let now_t = z_time_now().t; - if now_t > (*time).t { - now_t - (*time).t - } else { - 0 - } -} - -/// Get number of seconds passed since creation of `time`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_time_elapsed_s(time: *const z_time_t) -> u64 { - get_elapsed_nanos_system_clock(time) / 1_000_000_000 -} - -/// Get number of milliseconds passed since creation of `time`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_time_elapsed_ms(time: *const z_time_t) -> u64 { - get_elapsed_nanos_system_clock(time) / 1_000_000 -} - -/// Get number of microseconds passed since creation of `time`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_time_elapsed_us(time: *const z_time_t) -> u64 { - get_elapsed_nanos_system_clock(time) / 1_000 -} diff --git a/src/platform/mod.rs b/src/platform/mod.rs deleted file mode 100644 index 438763afe..000000000 --- a/src/platform/mod.rs +++ /dev/null @@ -1,23 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -pub use clock::*; -mod clock; -pub use sleep::*; -mod sleep; -pub use synchronization::*; -mod synchronization; - -pub use random::*; -mod random; diff --git a/src/platform/random.rs b/src/platform/random.rs deleted file mode 100644 index c83d97e39..000000000 --- a/src/platform/random.rs +++ /dev/null @@ -1,39 +0,0 @@ -use std::slice::from_raw_parts_mut; - -use libc::c_void; -use rand::{random, rng, RngCore}; - -/// Generates random `uint8_t`. -#[no_mangle] -pub extern "C" fn z_random_u8() -> u8 { - random::() -} - -/// Generates random `uint16_t`. -#[no_mangle] -pub extern "C" fn z_random_u16() -> u16 { - random::() -} - -/// Generates random `uint32_t`. -#[no_mangle] -pub extern "C" fn z_random_u32() -> u32 { - random::() -} - -/// Generates random `uint64_t`. -#[no_mangle] -pub extern "C" fn z_random_u64() -> u64 { - random::() -} - -/// Fills buffer with random data. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_random_fill(buf: *mut c_void, len: usize) { - if buf.is_null() || len == 0 { - return; - } - let b: &mut [u8] = from_raw_parts_mut(buf as *mut u8, len); - rng().fill_bytes(b); -} diff --git a/src/platform/sleep.rs b/src/platform/sleep.rs deleted file mode 100644 index 4a197a020..000000000 --- a/src/platform/sleep.rs +++ /dev/null @@ -1,24 +0,0 @@ -use std::{thread, time}; - -use crate::result; - -/// Puts current thread to sleep for specified amount of seconds. -#[no_mangle] -pub extern "C" fn z_sleep_s(time: usize) -> result::z_result_t { - thread::sleep(time::Duration::from_secs(time as u64)); - result::Z_OK -} - -/// Puts current thread to sleep for specified amount of milliseconds. -#[no_mangle] -pub extern "C" fn z_sleep_ms(time: usize) -> result::z_result_t { - thread::sleep(time::Duration::from_millis(time as u64)); - result::Z_OK -} - -/// Puts current thread to sleep for specified amount of microseconds. -#[no_mangle] -pub extern "C" fn z_sleep_us(time: usize) -> result::z_result_t { - thread::sleep(time::Duration::from_micros(time as u64)); - result::Z_OK -} diff --git a/src/platform/synchronization.rs b/src/platform/synchronization.rs deleted file mode 100644 index 8f2718614..000000000 --- a/src/platform/synchronization.rs +++ /dev/null @@ -1,281 +0,0 @@ -use std::{ - mem::MaybeUninit, - sync::{Condvar, Mutex, MutexGuard}, - thread::{self, JoinHandle}, -}; - -use libc::c_void; - -pub use crate::opaque_types::{z_loaned_mutex_t, z_moved_mutex_t, z_owned_mutex_t}; -use crate::{ - result, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, -}; - -decl_c_type_inequal!( - owned(z_owned_mutex_t, option(Mutex<()>, Option>)), - loaned(z_loaned_mutex_t), -); - -/// Constructs a mutex. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn z_mutex_init(this_: &mut MaybeUninit) -> result::z_result_t { - this_.as_rust_type_mut_uninit().write(Some(( - Mutex::<()>::new(()), - None::>, - ))); - result::Z_OK -} - -/// Drops mutex and resets it to its gravestone state. -#[no_mangle] -pub extern "C" fn z_mutex_drop(this_: &mut z_moved_mutex_t) { - let _ = this_.take_rust_type(); -} - -/// Returns ``true`` if mutex is valid, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_internal_mutex_check(this_: &z_owned_mutex_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// Constructs mutex in a gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_mutex_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// Mutably borrows mutex. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_mutex_loan_mut(this_: &mut z_owned_mutex_t) -> &mut z_loaned_mutex_t { - this_ - .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - -/// Locks mutex. If mutex is already locked, blocks the thread until it aquires the lock. -/// @return 0 in case of success, negative error code in case of failure. -#[no_mangle] -pub extern "C" fn z_mutex_lock(this_: &'static mut z_loaned_mutex_t) -> result::z_result_t { - let this = this_.as_rust_type_mut(); - - match this.0.lock() { - Ok(new_lock) => { - let old_lock = this.1.replace(new_lock); - std::mem::forget(old_lock); - } - Err(_) => { - return result::Z_EPOISON_MUTEX; - } - } - result::Z_OK -} - -/// Unlocks previously locked mutex. If mutex was not locked by the current thread, the behaviour is undefined. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn z_mutex_unlock(this_: &mut z_loaned_mutex_t) -> result::z_result_t { - let this = this_.as_rust_type_mut(); - if this.1.is_none() { - return result::Z_EINVAL_MUTEX; - } else { - this.1.take(); - } - result::Z_OK -} - -/// Tries to lock mutex. If mutex is already locked, return immediately. -/// @return 0 in case of success, negative value if failed to aquire the lock. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_mutex_try_lock( - this: &'static mut z_loaned_mutex_t, -) -> result::z_result_t { - let this = this.as_rust_type_mut(); - match this.0.try_lock() { - Ok(new_lock) => { - let old_lock = this.1.replace(new_lock); - std::mem::forget(old_lock); - } - Err(_) => { - return result::Z_EBUSY_MUTEX; - } - } - result::Z_OK -} - -pub use crate::opaque_types::{z_loaned_condvar_t, z_moved_condvar_t, z_owned_condvar_t}; -decl_c_type_inequal!( - owned(z_owned_condvar_t, option Condvar), - loaned(z_loaned_condvar_t), -); - -/// Constructs conditional variable. -#[no_mangle] -pub extern "C" fn z_condvar_init(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(Some(Condvar::new())); -} - -/// Constructs conditional variable in a gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_condvar_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// Drops conditional variable. -#[no_mangle] -pub extern "C" fn z_condvar_drop(this_: &mut z_moved_condvar_t) { - let _ = this_.take_rust_type(); -} - -/// Returns ``true`` if conditional variable is valid, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_internal_condvar_check(this_: &z_owned_condvar_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// Borrows conditional variable. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_condvar_loan(this_: &z_owned_condvar_t) -> &z_loaned_condvar_t { - this_ - .as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// Mutably borrows conditional variable. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_condvar_loan_mut( - this: &mut z_owned_condvar_t, -) -> &mut z_loaned_condvar_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - -/// Wakes up one blocked thread waiting on this condiitonal variable. -/// @return 0 in case of success, negative error code in case of failure. -#[no_mangle] -pub extern "C" fn z_condvar_signal(this_: &z_loaned_condvar_t) -> result::z_result_t { - let this = this_.as_rust_type_ref(); - this.notify_one(); - result::Z_OK -} - -/// Blocks the current thread until the conditional variable receives a notification. -/// -/// The function atomically unlocks the guard mutex `m` and blocks the current thread. -/// When the function returns the lock will have been re-aquired again. -/// Note: The function may be subject to spurious wakeups. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_condvar_wait( - this: &z_loaned_condvar_t, - m: &mut z_loaned_mutex_t, -) -> result::z_result_t { - let this = this.as_rust_type_ref(); - let m = m.as_rust_type_mut(); - if m.1.is_none() { - return result::Z_EINVAL_MUTEX; // lock was not aquired prior to wait call - } - - let lock = m.1.take().unwrap(); - match this.wait(lock) { - Ok(new_lock) => m.1 = Some(new_lock), - Err(_) => return result::Z_EPOISON_MUTEX, - } - - result::Z_OK -} - -pub use crate::opaque_types::{z_moved_task_t, z_owned_task_t}; -decl_c_type!( - owned(z_owned_task_t, option JoinHandle<()>), -); - -#[repr(C)] -#[derive(Clone, Copy)] -pub struct z_task_attr_t(usize); - -/// Constructs task in a gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_task_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// Detaches the task and releases all allocated resources. -#[no_mangle] -pub extern "C" fn z_task_detach(this_: &mut z_moved_task_t) { - let _ = this_.take_rust_type(); -} - -/// Joins the task and releases all allocated resources -#[no_mangle] -pub extern "C" fn z_task_join(this_: &mut z_moved_task_t) -> result::z_result_t { - let Some(task) = this_.take_rust_type() else { - return result::Z_OK; - }; - match task.join() { - Ok(_) => result::Z_OK, - Err(_) => result::Z_EINVAL_MUTEX, - } -} - -/// Drop the task. Same as `z_task_detach`. Use `z_task_join` to wait for the task completion. -#[no_mangle] -pub extern "C" fn z_task_drop(this_: &mut z_moved_task_t) { - let _ = this_.take_rust_type(); -} - -/// Returns ``true`` if task is valid, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_internal_task_check(this_: &z_owned_task_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -struct FunArgPair { - fun: unsafe extern "C" fn(arg: *mut c_void) -> *mut c_void, - arg: *mut c_void, -} - -impl FunArgPair { - unsafe fn call(self) { - (self.fun)(self.arg); - } -} - -unsafe impl Send for FunArgPair {} - -/// Constructs a new task. -/// -/// @param this_: An uninitialized memory location where task will be constructed. -/// @param _attr: Attributes of the task (currently unused). -/// @param fun: Function to be executed by the task. -/// @param arg: Argument that will be passed to the function `fun`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_task_init( - this: &mut MaybeUninit, - _attr: *const z_task_attr_t, - fun: unsafe extern "C" fn(arg: *mut c_void) -> *mut c_void, - arg: *mut c_void, -) -> result::z_result_t { - let this = this.as_rust_type_mut_uninit(); - let fun_arg_pair = FunArgPair { fun, arg }; - - match thread::Builder::new().spawn(move || fun_arg_pair.call()) { - Ok(join_handle) => { - this.write(Some(join_handle)); - } - Err(_) => return result::Z_EAGAIN_MUTEX, - } - result::Z_OK -} diff --git a/src/publication_cache.rs b/src/publication_cache.rs deleted file mode 100644 index bab6d6858..000000000 --- a/src/publication_cache.rs +++ /dev/null @@ -1,214 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// -#![allow(deprecated)] - -use std::{mem::MaybeUninit, ptr::null}; - -use zenoh::Wait; -use zenoh_ext::{PublicationCacheBuilder, SessionExt}; - -use crate::{ - result, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_loaned_keyexpr_t, z_loaned_session_t, zc_locality_default, zc_locality_t, -}; - -/// @warning This API is deprecated. Please use ze_advanced_publisher. -/// @brief Options passed to the `ze_declare_publication_cache()` function. -#[repr(C)] -pub struct ze_publication_cache_options_t { - /// The suffix used for queryable. - pub queryable_suffix: *const z_loaned_keyexpr_t, - /// The restriction for the matching queries that will be receive by this publication cache. - pub queryable_origin: zc_locality_t, - /// The `complete` option for the queryable. - pub queryable_complete: bool, - /// The the history size (i.e. maximum number of messages to store). - pub history: usize, - /// The limit number of cached resources. - pub resources_limit: usize, -} - -/// @warning This API is deprecated. Please use ze_advanced_publisher. -/// @brief Constructs the default value for `ze_publication_cache_options_t`. -#[no_mangle] -pub extern "C" fn ze_publication_cache_options_default( - this: &mut MaybeUninit, -) { - this.write(ze_publication_cache_options_t { - queryable_suffix: null(), - queryable_origin: zc_locality_default(), - queryable_complete: false, - history: 1, - resources_limit: 0, - }); -} - -pub use crate::opaque_types::{ - ze_loaned_publication_cache_t, ze_moved_publication_cache_t, ze_owned_publication_cache_t, -}; -decl_c_type!( - owned( - ze_owned_publication_cache_t, - option zenoh_ext::PublicationCache, - ), - loaned(ze_loaned_publication_cache_t), -); - -fn _declare_publication_cache_inner<'a, 'b, 'c>( - session: &'a z_loaned_session_t, - key_expr: &'b z_loaned_keyexpr_t, - options: Option<&'c mut ze_publication_cache_options_t>, -) -> PublicationCacheBuilder<'a, 'b, 'c> { - let session = session.as_rust_type_ref(); - let key_expr = key_expr.as_rust_type_ref(); - let mut p = session.declare_publication_cache(key_expr); - if let Some(options) = options { - p = p - .history(options.history) - .queryable_allowed_origin(options.queryable_origin.into()); - p = p.queryable_complete(options.queryable_complete); - if options.resources_limit != 0 { - p = p.resources_limit(options.resources_limit) - } - if let Some(queryable_suffix) = unsafe { options.queryable_suffix.as_ref() } { - let queryable_suffix = queryable_suffix.as_rust_type_ref(); - p = p.queryable_suffix(queryable_suffix.clone()); - } - } - p -} - -/// @warning This API is deprecated. Please use ze_advanced_publisher. -/// @brief Constructs and declares a publication cache. -/// -/// @param session: A Zenoh session. -/// @param pub_cache: An uninitialized location in memory where publication cache will be constructed. -/// @param key_expr: The key expression to publish to. -/// @param options: Additional options for the publication cache. -/// -/// @returns 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_declare_publication_cache( - session: &z_loaned_session_t, - pub_cache: &mut MaybeUninit, - key_expr: &z_loaned_keyexpr_t, - options: Option<&mut ze_publication_cache_options_t>, -) -> result::z_result_t { - let this = pub_cache.as_rust_type_mut_uninit(); - let p = _declare_publication_cache_inner(session, key_expr, options); - match p.wait() { - Ok(publication_cache) => { - this.write(Some(publication_cache)); - result::Z_OK - } - Err(e) => { - crate::report_error!("{}", e); - this.write(None); - result::Z_EGENERIC - } - } -} - -/// @warning This API is deprecated. Please use ze_advanced_publisher. -/// @brief Declares a background publication cache. It will function in background until the corresponding session is closed or dropped. -/// -/// @param session: A Zenoh session. -/// @param key_expr: The key expression to publish to. -/// @param options: Additional options for the publication cache. -/// -/// @returns 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_declare_background_publication_cache( - session: &z_loaned_session_t, - key_expr: &z_loaned_keyexpr_t, - options: Option<&mut ze_publication_cache_options_t>, -) -> result::z_result_t { - let p = _declare_publication_cache_inner(session, key_expr, options); - match p.background().wait() { - Ok(_) => result::Z_OK, - Err(e) => { - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -/// @warning This API is deprecated. Please use ze_advanced_publisher. -/// @brief Constructs a publication cache in a gravestone state. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_internal_publication_cache_null( - this_: &mut MaybeUninit, -) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @warning This API is deprecated. Please use ze_advanced_publisher. -/// @brief Returns ``true`` if publication cache is valid, ``false`` otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_internal_publication_cache_check( - this_: &ze_owned_publication_cache_t, -) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @warning This API is deprecated. Please use ze_advanced_publisher. -/// @brief Drops publication cache and resets it to its gravestone state. -/// This is equivalent to calling `ze_undeclare_publication_cache()` and discarding its return value. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_publication_cache_drop(this: &mut ze_moved_publication_cache_t) { - std::mem::drop(this.take_rust_type()) -} - -/// @warning This API is deprecated. Please use ze_advanced_publisher. -/// @brief Returns the key expression of the publication cache. -#[no_mangle] -pub extern "C" fn ze_publication_cache_keyexpr( - this_: &ze_loaned_publication_cache_t, -) -> &z_loaned_keyexpr_t { - this_.as_rust_type_ref().key_expr().as_loaned_c_type_ref() -} - -/// @warning This API is deprecated. Please use ze_advanced_publisher. -/// @brief Borrows publication cache. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_publication_cache_loan( - this_: &ze_owned_publication_cache_t, -) -> &ze_loaned_publication_cache_t { - this_ - .as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// @warning This API is deprecated. Please use ze_advanced_publisher. -/// @brief Undeclares publication cache. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_undeclare_publication_cache( - this: &mut ze_moved_publication_cache_t, -) -> result::z_result_t { - if let Some(p) = this.take_rust_type() { - if let Err(e) = p.undeclare().wait() { - crate::report_error!("{}", e); - return result::Z_EGENERIC; - } - } - result::Z_OK -} diff --git a/src/publisher.rs b/src/publisher.rs deleted file mode 100644 index fc77e2bef..000000000 --- a/src/publisher.rs +++ /dev/null @@ -1,445 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::mem::MaybeUninit; - -use zenoh::{ - handlers::Callback, - internal::traits::{EncodingBuilderTrait, SampleBuilderTrait, TimestampBuilderTrait}, - matching::MatchingStatus, - pubsub::{Publisher, PublisherBuilder}, - qos::{CongestionControl, Priority}, - session::SessionClosedError, - Wait, -}; - -use crate::{ - result::{self}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_closure_matching_status_call, z_closure_matching_status_loan, z_congestion_control_t, - z_loaned_keyexpr_t, z_loaned_session_t, z_matching_status_t, z_moved_bytes_t, - z_moved_closure_matching_status_t, z_moved_encoding_t, z_owned_matching_listener_t, - z_priority_t, z_timestamp_t, zc_locality_default, zc_locality_t, -}; -#[cfg(feature = "unstable")] -use crate::{ - transmute::IntoCType, z_entity_global_id_t, z_moved_source_info_t, z_reliability_default, - z_reliability_t, -}; -/// Options passed to the `z_declare_publisher()` function. -#[repr(C)] -pub struct z_publisher_options_t { - /// Default encoding for messages put by this publisher. - pub encoding: Option<&'static mut z_moved_encoding_t>, - /// The congestion control to apply when routing messages from this publisher. - pub congestion_control: z_congestion_control_t, - /// The priority of messages from this publisher. - pub priority: z_priority_t, - /// If set to ``true``, this message will not be batched. This usually has a positive impact on latency but negative impact on throughput. - pub is_express: bool, - #[cfg(feature = "unstable")] - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - /// - /// The publisher reliability. - pub reliability: z_reliability_t, - /// The allowed destination for this publisher. - pub allowed_destination: zc_locality_t, -} - -impl Default for z_publisher_options_t { - fn default() -> Self { - Self { - encoding: None, - congestion_control: CongestionControl::DEFAULT_PUSH.into(), - priority: Priority::default().into(), - is_express: false, - #[cfg(feature = "unstable")] - reliability: z_reliability_default(), - allowed_destination: zc_locality_default(), - } - } -} - -/// Constructs the default value for `z_publisher_options_t`. -#[no_mangle] -pub extern "C" fn z_publisher_options_default(this_: &mut MaybeUninit) { - this_.write(z_publisher_options_t::default()); -} - -pub use crate::opaque_types::{z_loaned_publisher_t, z_moved_publisher_t, z_owned_publisher_t}; -decl_c_type!( - owned(z_owned_publisher_t, option Publisher<'static>), - loaned(z_loaned_publisher_t), -); - -pub(crate) fn _declare_publisher_inner( - session: &'static z_loaned_session_t, - key_expr: &'static z_loaned_keyexpr_t, - options: Option<&mut z_publisher_options_t>, -) -> PublisherBuilder<'static, 'static> { - let session = session.as_rust_type_ref(); - let key_expr = key_expr.as_rust_type_ref().clone().into_owned(); - let mut p = session.declare_publisher(key_expr); - if let Some(options) = options { - p = p - .congestion_control(options.congestion_control.into()) - .priority(options.priority.into()) - .express(options.is_express) - .allowed_destination(options.allowed_destination.into()); - #[cfg(feature = "unstable")] - { - p = p.reliability(options.reliability.into()); - } - if let Some(encoding) = options.encoding.take() { - p = p.encoding(encoding.take_rust_type()); - } - } - p -} - -/// Constructs and declares a publisher for the given key expression. -/// -/// Data can be put and deleted with this publisher with the help of the -/// `z_publisher_put()` and `z_publisher_delete()` functions. -/// -/// @param session: The Zenoh session. -/// @param publisher: An uninitialized location in memory where publisher will be constructed. -/// @param key_expr: The key expression to publish. -/// @param options: Additional options for the publisher. -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn z_declare_publisher( - session: &'static z_loaned_session_t, - publisher: &'static mut MaybeUninit, - key_expr: &'static z_loaned_keyexpr_t, - options: Option<&'static mut z_publisher_options_t>, -) -> result::z_result_t { - let this = publisher.as_rust_type_mut_uninit(); - let p = _declare_publisher_inner(session, key_expr, options); - match p.wait() { - Err(e) => { - crate::report_error!("{}", e); - this.write(None); - result::Z_EGENERIC - } - Ok(publisher) => { - this.write(Some(publisher)); - result::Z_OK - } - } -} - -/// Constructs a publisher in a gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_publisher_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// Returns ``true`` if publisher is valid, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_internal_publisher_check(this_: &z_owned_publisher_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// Borrows publisher. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_publisher_loan(this_: &z_owned_publisher_t) -> &z_loaned_publisher_t { - this_ - .as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// Mutably borrows publisher. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_publisher_loan_mut( - this: &mut z_owned_publisher_t, -) -> &mut z_loaned_publisher_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - -/// Options passed to the `z_publisher_put()` function. -#[repr(C)] -#[derive(Default)] -pub struct z_publisher_put_options_t { - /// The encoding of the data to publish. - pub encoding: Option<&'static mut z_moved_encoding_t>, - /// The timestamp of the publication. - pub timestamp: Option<&'static z_timestamp_t>, - #[cfg(feature = "unstable")] - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - /// - /// The source info for the publication. - pub source_info: Option<&'static mut z_moved_source_info_t>, - /// The attachment to attach to the publication. - pub attachment: Option<&'static mut z_moved_bytes_t>, -} - -/// Constructs the default value for `z_publisher_put_options_t`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_publisher_put_options_default( - this: &mut MaybeUninit, -) { - this.write(z_publisher_put_options_t { - encoding: None, - timestamp: None, - #[cfg(feature = "unstable")] - source_info: None, - attachment: None, - }); -} - -pub(crate) fn _apply_pubisher_put_options< - T: SampleBuilderTrait + TimestampBuilderTrait + EncodingBuilderTrait, ->( - builder: T, - options: &mut z_publisher_put_options_t, -) -> T { - let mut builder = builder; - if let Some(encoding) = options.encoding.take() { - builder = builder.encoding(encoding.take_rust_type()); - }; - #[cfg(feature = "unstable")] - if let Some(source_info) = options.source_info.take() { - builder = builder.source_info(source_info.take_rust_type()); - }; - if let Some(attachment) = options.attachment.take() { - builder = builder.attachment(attachment.take_rust_type()); - } - if let Some(timestamp) = options.timestamp { - builder = builder.timestamp(Some(*timestamp.as_rust_type_ref())); - } - builder -} - -/// Sends a `PUT` message onto the publisher's key expression, transfering the payload ownership. -/// -/// -/// The payload and all owned options fields are consumed upon function return. -/// -/// @param this_: The publisher. -/// @param payload: The data to publish. Will be consumed. -/// @param options: The publisher put options. All owned fields will be consumed. -/// -/// @return 0 in case of success, negative error values in case of failure. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_publisher_put( - this: &z_loaned_publisher_t, - payload: &mut z_moved_bytes_t, - options: Option<&mut z_publisher_put_options_t>, -) -> result::z_result_t { - let publisher = this.as_rust_type_ref(); - let payload = payload.take_rust_type(); - let mut put = publisher.put(payload); - if let Some(options) = options { - put = _apply_pubisher_put_options(put, options); - } - - match put.wait() { - Ok(_) => result::Z_OK, - Err(e) if e.downcast_ref::().is_some() => result::Z_ESESSION_CLOSED, - Err(e) => { - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -/// Represents the set of options that can be applied to the delete operation by a previously declared publisher, -/// whenever issued via `z_publisher_delete()`. -#[repr(C)] -#[derive(Default)] -pub struct z_publisher_delete_options_t { - /// The timestamp of this message. - pub timestamp: Option<&'static z_timestamp_t>, -} - -/// Constructs the default values for the delete operation via a publisher entity. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_publisher_delete_options_default( - this: &mut MaybeUninit, -) { - this.write(z_publisher_delete_options_t::default()); -} - -pub(crate) fn _apply_pubisher_delete_options( - builder: T, - options: &mut z_publisher_delete_options_t, -) -> T { - let mut builder = builder; - if let Some(timestamp) = options.timestamp { - builder = builder.timestamp(Some(*timestamp.as_rust_type_ref())); - } - builder -} - -/// Sends a `DELETE` message onto the publisher's key expression. -/// -/// @return 0 in case of success, negative error code in case of failure. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_publisher_delete( - publisher: &z_loaned_publisher_t, - options: Option<&mut z_publisher_delete_options_t>, -) -> result::z_result_t { - let publisher = publisher.as_rust_type_ref(); - let mut del = publisher.delete(); - if let Some(options) = options { - del = _apply_pubisher_delete_options(del, options); - } - if let Err(e) = del.wait() { - crate::report_error!("{}", e); - result::Z_EGENERIC - } else { - result::Z_OK - } -} -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns the ID of the publisher. -#[no_mangle] -pub extern "C" fn z_publisher_id(publisher: &z_loaned_publisher_t) -> z_entity_global_id_t { - publisher.as_rust_type_ref().id().into_c_type() -} - -/// Returns the key expression of the publisher. -#[no_mangle] -pub extern "C" fn z_publisher_keyexpr(publisher: &z_loaned_publisher_t) -> &z_loaned_keyexpr_t { - publisher - .as_rust_type_ref() - .key_expr() - .as_loaned_c_type_ref() -} - -fn _publisher_matching_listener_declare_inner<'a>( - publisher: &'a z_loaned_publisher_t, - callback: &mut z_moved_closure_matching_status_t, -) -> zenoh::matching::MatchingListenerBuilder<'a, Callback> { - let publisher = publisher.as_rust_type_ref(); - let callback = callback.take_rust_type(); - let listener = publisher - .matching_listener() - .callback_mut(move |matching_status| { - let status = z_matching_status_t { - matching: matching_status.matching(), - }; - z_closure_matching_status_call(z_closure_matching_status_loan(&callback), &status); - }); - listener -} - -/// @brief Constructs matching listener, registering a callback for notifying subscribers matching with a given publisher. -/// -/// @param publisher: A publisher to associate with matching listener. -/// @param matching_listener: An uninitialized memory location where matching listener will be constructed. The matching listener's callback will be automatically dropped when the publisher is dropped. -/// @param callback: A closure that will be called every time the matching status of the publisher changes (If last subscriber disconnects or when the first subscriber connects). -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn z_publisher_declare_matching_listener( - publisher: &'static z_loaned_publisher_t, - matching_listener: &mut MaybeUninit, - callback: &mut z_moved_closure_matching_status_t, -) -> result::z_result_t { - let this = matching_listener.as_rust_type_mut_uninit(); - let listener = _publisher_matching_listener_declare_inner(publisher, callback); - match listener.wait() { - Ok(listener) => { - this.write(Some(listener)); - result::Z_OK - } - Err(e) => { - this.write(None); - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -/// @brief Declares a matching listener, registering a callback for notifying subscribers matching with a given publisher. -/// The callback will be run in the background until the corresponding publisher is dropped. -/// -/// @param publisher: A publisher to associate with matching listener. -/// @param callback: A closure that will be called every time the matching status of the publisher changes (If last subscriber disconnects or when the first subscriber connects). -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn z_publisher_declare_background_matching_listener( - publisher: &'static z_loaned_publisher_t, - callback: &mut z_moved_closure_matching_status_t, -) -> result::z_result_t { - let listener = _publisher_matching_listener_declare_inner(publisher, callback); - match listener.background().wait() { - Ok(_) => result::Z_OK, - Err(e) => { - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -/// @brief Gets publisher matching status - i.e. if there are any subscribers matching its key expression. -/// -/// @return 0 in case of success, negative error code otherwise (in this case matching_status is not updated). -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_publisher_get_matching_status( - this: &'static z_loaned_publisher_t, - matching_status: &mut MaybeUninit, -) -> result::z_result_t { - match this.as_rust_type_ref().matching_status().wait() { - Ok(s) => { - matching_status.write(z_matching_status_t { - matching: s.matching(), - }); - result::Z_OK - } - Err(e) => { - crate::report_error!("{}", e); - result::Z_ENETWORK - } - } -} - -/// Frees memory and resets publisher to its gravestone state. -/// This is equivalent to calling `z_undeclare_publisher()` and discarding its return value. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_publisher_drop(this: &mut z_moved_publisher_t) { - std::mem::drop(this.take_rust_type()) -} - -#[no_mangle] -/// @brief Undeclares the given publisher. -/// -/// @return 0 in case of success, negative error code otherwise. -pub extern "C" fn z_undeclare_publisher(this_: &mut z_moved_publisher_t) -> result::z_result_t { - if let Some(p) = this_.take_rust_type() { - if let Err(e) = p.undeclare().wait() { - crate::report_error!("{}", e); - return result::Z_ENETWORK; - } - } - result::Z_OK -} diff --git a/src/put.rs b/src/put.rs deleted file mode 100644 index d8834edaa..000000000 --- a/src/put.rs +++ /dev/null @@ -1,212 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// -use std::mem::MaybeUninit; - -use zenoh::{ - qos::{CongestionControl, Priority}, - session::SessionClosedError, - Wait, -}; - -#[cfg(feature = "unstable")] -use crate::z_moved_source_info_t; -use crate::{ - commons::*, - result, - transmute::{IntoRustType, RustTypeRef, TakeRustType}, - z_loaned_keyexpr_t, z_loaned_session_t, z_moved_bytes_t, z_moved_encoding_t, z_timestamp_t, - zc_locality_default, zc_locality_t, -}; - -/// Options passed to the `z_put()` function. -#[repr(C)] -#[allow(non_camel_case_types)] -pub struct z_put_options_t { - /// The encoding of the message. - pub encoding: Option<&'static mut z_moved_encoding_t>, - /// The congestion control to apply when routing this message. - pub congestion_control: z_congestion_control_t, - /// The priority of this message. - pub priority: z_priority_t, - /// If set to ``true``, this message will not be batched. This usually has a positive impact on latency but negative impact on throughput. - pub is_express: bool, - /// The timestamp of this message. - pub timestamp: Option<&'static mut z_timestamp_t>, - #[cfg(feature = "unstable")] - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - /// - /// The put operation reliability. - reliability: z_reliability_t, - /// The allowed destination of this message. - pub allowed_destination: zc_locality_t, - #[cfg(feature = "unstable")] - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - /// - /// The source info for the message. - pub source_info: Option<&'static mut z_moved_source_info_t>, - /// The attachment to this message. - pub attachment: Option<&'static mut z_moved_bytes_t>, -} - -/// Constructs the default value for `z_put_options_t`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_put_options_default(this_: &mut MaybeUninit) { - this_.write(z_put_options_t { - encoding: None, - congestion_control: CongestionControl::DEFAULT_PUSH.into(), - priority: Priority::default().into(), - is_express: false, - timestamp: None, - #[cfg(feature = "unstable")] - reliability: z_reliability_default(), - allowed_destination: zc_locality_default(), - #[cfg(feature = "unstable")] - source_info: None, - attachment: None, - }); -} - -/// Publishes data on specified key expression. -/// -/// @param session: The Zenoh session. -/// @param key_expr: The key expression to publish to. -/// @param payload: The value to put (consumed upon function return). -/// @param options: The put options (all owned values will be consumed upon function return). -/// -/// @return 0 in case of success, negative error values in case of failure. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_put( - session: &z_loaned_session_t, - key_expr: &z_loaned_keyexpr_t, - payload: &mut z_moved_bytes_t, - options: Option<&mut z_put_options_t>, -) -> result::z_result_t { - let session = session.as_rust_type_ref(); - let key_expr = key_expr.as_rust_type_ref(); - let payload = payload.take_rust_type(); - let mut put = session.put(key_expr, payload); - if let Some(options) = options { - if let Some(encoding) = options.encoding.take() { - put = put.encoding(encoding.take_rust_type()); - }; - if let Some(attachment) = options.attachment.take() { - put = put.attachment(attachment.take_rust_type()); - } - if let Some(timestamp) = options.timestamp.as_ref() { - put = put.timestamp(Some(timestamp.into_rust_type())); - } - put = put - .priority(options.priority.into()) - .congestion_control(options.congestion_control.into()) - .express(options.is_express); - #[cfg(feature = "unstable")] - { - put = put - .reliability(options.reliability.into()) - .allowed_destination(options.allowed_destination.into()); - if let Some(source_info) = options.source_info.take() { - put = put.source_info(source_info.take_rust_type()); - }; - } - } - match put.wait() { - Ok(_) => result::Z_OK, - Err(e) if e.downcast_ref::().is_some() => result::Z_ESESSION_CLOSED, - Err(e) => { - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -/// Options passed to the `z_delete()` function. -#[repr(C)] -#[allow(non_camel_case_types)] -pub struct z_delete_options_t { - /// The congestion control to apply when routing this delete message. - pub congestion_control: z_congestion_control_t, - /// The priority of the delete message. - pub priority: z_priority_t, - /// If set to ``true``, this message will not be batched. This usually has a positive impact on latency but negative impact on throughput. - pub is_express: bool, - /// The timestamp of this message. - pub timestamp: Option<&'static mut z_timestamp_t>, - #[cfg(feature = "unstable")] - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - /// - /// The delete operation reliability. - pub reliability: z_reliability_t, - /// The allowed destination of this message. - pub allowed_destination: zc_locality_t, -} - -/// Constructs the default value for `z_delete_options_t`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_delete_options_default(this_: &mut MaybeUninit) { - this_.write(z_delete_options_t { - congestion_control: CongestionControl::DEFAULT_PUSH.into(), - priority: Priority::default().into(), - is_express: false, - timestamp: None, - #[cfg(feature = "unstable")] - reliability: z_reliability_default(), - allowed_destination: zc_locality_default(), - }); -} - -/// Sends request to delete data on specified key expression (used when working with Zenoh storages ). -/// -/// @param session: The zenoh session. -/// @param key_expr: The key expression to delete. -/// @param options: The delete options. -/// -/// @return 0 in case of success, negative values in case of failure. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_delete( - session: &z_loaned_session_t, - key_expr: &z_loaned_keyexpr_t, - options: Option<&mut z_delete_options_t>, -) -> result::z_result_t { - let session = session.as_rust_type_ref(); - let key_expr = key_expr.as_rust_type_ref(); - let mut del = session.delete(key_expr); - if let Some(options) = options { - if let Some(timestamp) = options.timestamp.as_ref() { - del = del.timestamp(Some(timestamp.into_rust_type())); - } - del = del - .congestion_control(options.congestion_control.into()) - .priority(options.priority.into()) - .express(options.is_express); - - #[cfg(feature = "unstable")] - { - del = del - .reliability(options.reliability.into()) - .allowed_destination(options.allowed_destination.into()); - } - } - - match del.wait() { - Err(e) => { - crate::report_error!("{}", e); - result::Z_EGENERIC - } - Ok(()) => result::Z_OK, - } -} diff --git a/src/querier.rs b/src/querier.rs deleted file mode 100644 index d1766cadb..000000000 --- a/src/querier.rs +++ /dev/null @@ -1,457 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::mem::MaybeUninit; - -use libc::c_char; -use zenoh::{ - handlers::Callback, - matching::MatchingStatus, - qos::{CongestionControl, Priority}, - query::{Querier, QueryConsolidation, QueryTarget}, - session::SessionClosedError, - Wait, -}; - -use crate::{ - result, strlen_or_zero, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_closure_matching_status_call, z_closure_matching_status_loan, z_closure_reply_call, - z_closure_reply_loan, z_congestion_control_t, z_loaned_keyexpr_t, z_loaned_querier_t, - z_loaned_session_t, z_matching_status_t, z_moved_bytes_t, z_moved_closure_matching_status_t, - z_moved_closure_reply_t, z_moved_encoding_t, z_moved_querier_t, z_owned_matching_listener_t, - z_owned_querier_t, z_priority_t, z_query_consolidation_t, z_query_target_t, - zc_locality_default, zc_locality_t, -}; -#[cfg(feature = "unstable")] -use crate::{ - transmute::IntoCType, z_entity_global_id_t, z_moved_source_info_t, zc_reply_keyexpr_default, - zc_reply_keyexpr_t, -}; - -/// @brief Options passed to the `z_declare_querier()` function. -#[repr(C)] -pub struct z_querier_options_t { - /// The Queryables that should be target of the querier queries. - pub target: z_query_target_t, - /// The replies consolidation strategy to apply on replies to the querier queries. - pub consolidation: z_query_consolidation_t, - /// The congestion control to apply when routing the querier queries. - pub congestion_control: z_congestion_control_t, - /// If set to ``true``, the querier queries will not be batched. This usually has a positive impact on latency but negative impact on throughput. - pub is_express: bool, - /// The allowed destination for the querier queries. - pub allowed_destination: zc_locality_t, - #[cfg(feature = "unstable")] - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - /// - /// The accepted replies for the querier queries. - pub accept_replies: zc_reply_keyexpr_t, - /// The priority of the querier queries. - pub priority: z_priority_t, - /// The timeout for the querier queries in milliseconds. 0 means default query timeout from zenoh configuration. - pub timeout_ms: u64, -} - -/// @brief Constructs the default value for `z_querier_options_t`. -#[no_mangle] -pub extern "C" fn z_querier_options_default(this_: &mut MaybeUninit) { - this_.write(z_querier_options_t { - target: QueryTarget::default().into(), - consolidation: QueryConsolidation::default().into(), - congestion_control: CongestionControl::DEFAULT_REQUEST.into(), - priority: Priority::default().into(), - is_express: false, - allowed_destination: zc_locality_default(), - #[cfg(feature = "unstable")] - accept_replies: zc_reply_keyexpr_default(), - timeout_ms: 0, - }); -} - -decl_c_type!( - owned(z_owned_querier_t, option Querier<'static>), - loaned(z_loaned_querier_t), -); - -/// @brief Constructs and declares a querier on the given key expression. -/// -/// The queries can be send with the help of the `z_querier_get()` function. -/// -/// @param session: The Zenoh session. -/// @param querier: An uninitialized location in memory where querier will be constructed. -/// @param key_expr: The key expression to send queries on. -/// @param options: Additional options for the querier. -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_declare_querier( - session: &z_loaned_session_t, - querier: &mut MaybeUninit, - key_expr: &z_loaned_keyexpr_t, - options: Option<&mut z_querier_options_t>, -) -> result::z_result_t { - let this = querier.as_rust_type_mut_uninit(); - let session = session.as_rust_type_ref(); - let key_expr = key_expr.as_rust_type_ref().clone().into_owned(); - let mut q = session.declare_querier(key_expr); - if let Some(options) = options { - q = q - .congestion_control(options.congestion_control.into()) - .priority(options.priority.into()) - .express(options.is_express) - .target(options.target.into()) - .consolidation(options.consolidation) - .allowed_destination(options.allowed_destination.into()); - if options.timeout_ms != 0 { - q = q.timeout(std::time::Duration::from_millis(options.timeout_ms)); - } - #[cfg(feature = "unstable")] - { - q = q.accept_replies(options.accept_replies.into()); - } - } - match q.wait() { - Err(e) => { - crate::report_error!("{}", e); - this.write(None); - result::Z_EGENERIC - } - Ok(querier) => { - this.write(Some(querier)); - result::Z_OK - } - } -} - -/// @brief Constructs a querier in a gravestone state. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_internal_querier_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @brief Returns ``true`` if querier is valid, ``false`` otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub extern "C" fn z_internal_querier_check(this_: &z_owned_querier_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @brief Borrows querier. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_querier_loan(this_: &z_owned_querier_t) -> &z_loaned_querier_t { - this_ - .as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// @brief Mutably borrows querier. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_querier_loan_mut( - this: &mut z_owned_querier_t, -) -> &mut z_loaned_querier_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - -/// @brief Options passed to the `z_querier_get()` function. -#[repr(C)] -pub struct z_querier_get_options_t { - /// An optional payload to attach to the query. - pub payload: Option<&'static mut z_moved_bytes_t>, - /// An optional encoding of the query payload and or attachment. - pub encoding: Option<&'static mut z_moved_encoding_t>, - #[cfg(feature = "unstable")] - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - /// - /// The source info for the query. - pub source_info: Option<&'static mut z_moved_source_info_t>, - /// An optional attachment to attach to the query. - pub attachment: Option<&'static mut z_moved_bytes_t>, -} - -impl z_querier_get_options_t { - fn clear(&mut self) { - if let Some(p) = self.payload.take() { - p.take_rust_type(); - } - if let Some(e) = self.encoding.take() { - e.take_rust_type(); - } - if let Some(a) = self.attachment.take() { - a.take_rust_type(); - } - #[cfg(feature = "unstable")] - if let Some(si) = self.source_info.take() { - si.take_rust_type(); - } - } -} - -/// @brief Constructs the default value for `z_querier_get_options_t`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_querier_get_options_default(this: &mut MaybeUninit) { - this.write(z_querier_get_options_t { - payload: None, - encoding: None, - #[cfg(feature = "unstable")] - source_info: None, - attachment: None, - }); -} - -/// @brief Query data from the matching queryables in the system. -/// Replies are provided through a callback function. -/// -/// @param querier: The querier to make query from. -/// @param parameters: The query's parameters null-terminated string, similar to a url's query segment. -/// @param callback: The callback function that will be called on reception of replies for this query. It will be automatically dropped once all replies are processed. -/// @param options: Additional options for the get. All owned fields will be consumed. -/// -/// @return 0 in case of success, a negative error value upon failure. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_querier_get( - querier: &z_loaned_querier_t, - parameters: *const c_char, - callback: &mut z_moved_closure_reply_t, - options: Option<&mut z_querier_get_options_t>, -) -> result::z_result_t { - z_querier_get_with_parameters_substr( - querier, - parameters, - strlen_or_zero(parameters), - callback, - options, - ) -} - -/// @brief Query data from the matching queryables in the system. -/// Replies are provided through a callback function. -/// -/// @param querier: The querier to make query from. -/// @param parameters: The query's parameters, similar to a url's query segment. -/// @param parameters_len: The length of the query's parameters substring. -/// @param callback: The callback function that will be called on reception of replies for this query. It will be automatically dropped once all replies are processed. -/// @param options: Additional options for the get. All owned fields will be consumed. -/// -/// @return 0 in case of success, a negative error value upon failure. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_querier_get_with_parameters_substr( - querier: &z_loaned_querier_t, - parameters: *const c_char, - parameters_len: usize, - callback: &mut z_moved_closure_reply_t, - options: Option<&mut z_querier_get_options_t>, -) -> result::z_result_t { - let querier = querier.as_rust_type_ref(); - let callback = callback.take_rust_type(); - - let pcs = match crate::CStringView::new_borrowed(parameters as *const c_char, parameters_len) { - Ok(cs) => cs, - Err(r) => { - if let Some(o) = options { - o.clear(); - } - return r; - } - }; - - let p: &str = match (&pcs).try_into() { - Ok(s) => s, - Err(e) => { - if let Some(o) = options { - o.clear(); - } - crate::report_error!("Parameters is not a valid utf-8 string: {e}"); - return result::Z_EINVAL; - } - }; - - let mut get = querier.get(); - if let Some(options) = options { - if let Some(payload) = options.payload.take() { - get = get.payload(payload.take_rust_type()); - } - if let Some(encoding) = options.encoding.take() { - get = get.encoding(encoding.take_rust_type()); - } - #[cfg(feature = "unstable")] - if let Some(source_info) = options.source_info.take() { - get = get.source_info(source_info.take_rust_type()); - } - if let Some(attachment) = options.attachment.take() { - get = get.attachment(attachment.take_rust_type()); - } - } - if !p.is_empty() { - get = get.parameters(p); - } - match get - .callback(move |response| { - let mut owned_response = Some(response); - z_closure_reply_call( - z_closure_reply_loan(&callback), - owned_response - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut(), - ) - }) - .wait() - { - Ok(()) => result::Z_OK, - Err(e) if e.downcast_ref::().is_some() => result::Z_ESESSION_CLOSED, - Err(e) => { - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns the ID of the querier. -#[no_mangle] -pub extern "C" fn z_querier_id(querier: &z_loaned_querier_t) -> z_entity_global_id_t { - querier.as_rust_type_ref().id().into_c_type() -} - -/// @brief Returns the key expression of the querier. -#[no_mangle] -pub extern "C" fn z_querier_keyexpr(querier: &z_loaned_querier_t) -> &z_loaned_keyexpr_t { - querier.as_rust_type_ref().key_expr().as_loaned_c_type_ref() -} - -fn _querier_matching_listener_declare_inner<'a>( - querier: &'a z_loaned_querier_t, - callback: &mut z_moved_closure_matching_status_t, -) -> zenoh::matching::MatchingListenerBuilder<'a, Callback> { - let querier = querier.as_rust_type_ref(); - let callback = callback.take_rust_type(); - let listener = querier - .matching_listener() - .callback_mut(move |matching_status| { - let status = z_matching_status_t { - matching: matching_status.matching(), - }; - z_closure_matching_status_call(z_closure_matching_status_loan(&callback), &status); - }); - listener -} - -/// @brief Constructs matching listener, registering a callback for notifying queryables matching with a given querier's key expression and target. -/// -/// @param querier: A querier to associate with matching listener. -/// @param matching_listener: An uninitialized memory location where matching listener will be constructed. The matching listener's callback will be automatically dropped when the querier is dropped. -/// @param callback: A closure that will be called every time the matching status of the querier changes (If last queryable disconnects or when the first queryable connects). -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn z_querier_declare_matching_listener( - querier: &'static z_loaned_querier_t, - matching_listener: &mut MaybeUninit, - callback: &mut z_moved_closure_matching_status_t, -) -> result::z_result_t { - let this = matching_listener.as_rust_type_mut_uninit(); - let listener = _querier_matching_listener_declare_inner(querier, callback); - match listener.wait() { - Ok(listener) => { - this.write(Some(listener)); - result::Z_OK - } - Err(e) => { - this.write(None); - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -/// @brief Declares a matching listener, registering a callback for notifying queryables matching the given querier key expression and target. -/// The callback will be run in the background until the corresponding querier is dropped. -/// -/// @param querier: A querier to associate with matching listener. -/// @param callback: A closure that will be called every time the matching status of the querier changes (If last queryable disconnects or when the first queryable connects). -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn z_querier_declare_background_matching_listener( - querier: &'static z_loaned_querier_t, - callback: &mut z_moved_closure_matching_status_t, -) -> result::z_result_t { - let listener = _querier_matching_listener_declare_inner(querier, callback); - match listener.background().wait() { - Ok(_) => result::Z_OK, - Err(e) => { - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -/// @brief Gets querier matching status - i.e. if there are any queryables matching its key expression and target. -/// -/// @return 0 in case of success, negative error code otherwise (in this case matching_status is not updated). -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_querier_get_matching_status( - this: &'static z_loaned_querier_t, - matching_status: &mut MaybeUninit, -) -> result::z_result_t { - match this.as_rust_type_ref().matching_status().wait() { - Ok(s) => { - matching_status.write(z_matching_status_t { - matching: s.matching(), - }); - result::Z_OK - } - Err(e) => { - crate::report_error!("{}", e); - result::Z_ENETWORK - } - } -} - -/// @brief Frees memory and resets querier to its gravestone state. -/// This is equivalent to calling `z_undeclare_querier()` and discarding its return value. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_querier_drop(this: &mut z_moved_querier_t) { - std::mem::drop(this.take_rust_type()) -} - -/// @brief Undeclares the given querier. -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn z_undeclare_querier(this_: &mut z_moved_querier_t) -> result::z_result_t { - if let Some(q) = this_.take_rust_type() { - if let Err(e) = q.undeclare().wait() { - crate::report_error!("{}", e); - return result::Z_ENETWORK; - } - } - result::Z_OK -} diff --git a/src/queryable.rs b/src/queryable.rs deleted file mode 100644 index 51e0ce13a..000000000 --- a/src/queryable.rs +++ /dev/null @@ -1,579 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// -use std::mem::MaybeUninit; - -use zenoh::{ - bytes::Encoding, - handlers::Callback, - qos::{CongestionControl, Priority}, - query::{Query, Queryable, QueryableBuilder}, - Wait, -}; - -pub use crate::opaque_types::{z_loaned_queryable_t, z_owned_queryable_t}; -use crate::{ - result, - transmute::{IntoRustType, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_closure_query_call, z_closure_query_loan, z_congestion_control_t, z_loaned_bytes_t, - z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_session_t, z_moved_bytes_t, - z_moved_closure_query_t, z_moved_encoding_t, z_moved_queryable_t, z_priority_t, z_timestamp_t, - z_view_string_from_substr, z_view_string_t, zc_locality_default, zc_locality_t, -}; -#[cfg(feature = "unstable")] -use crate::{transmute::IntoCType, z_entity_global_id_t, z_moved_source_info_t}; -decl_c_type!( - owned(z_owned_queryable_t, option Queryable<()>), - loaned(z_loaned_queryable_t), -); - -/// Constructs a queryable in its gravestone value. -#[no_mangle] -pub extern "C" fn z_internal_queryable_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -// Borrows Queryable -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_queryable_loan(this_: &z_owned_queryable_t) -> &z_loaned_queryable_t { - this_ - .as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -pub use crate::opaque_types::{z_loaned_query_t, z_moved_query_t, z_owned_query_t}; -decl_c_type!( - owned(z_owned_query_t, option Query), - loaned(z_loaned_query_t), -); - -/// Constructs query in its gravestone value. -#[no_mangle] -pub extern "C" fn z_internal_query_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} -/// Returns `false` if `this` is in a gravestone state, `true` otherwise. -#[no_mangle] -pub extern "C" fn z_internal_query_check(query: &z_owned_query_t) -> bool { - query.as_rust_type_ref().is_some() -} -/// Borrows the query. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_query_loan( - this_: &'static z_owned_query_t, -) -> &'static z_loaned_query_t { - this_ - .as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} -/// Mutably borrows the query. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_query_loan_mut( - this_: &'static mut z_owned_query_t, -) -> &'static mut z_loaned_query_t { - this_ - .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - -/// Takes ownership of the mutably borrowed query -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_query_take_from_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_query_t, -) { - let dst = dst.as_rust_type_mut_uninit(); - let src = src.as_rust_type_mut(); - let src = std::mem::replace(src, Query::empty()); - dst.write(Some(src)); -} - -/// Destroys the query resetting it to its gravestone value. -#[no_mangle] -pub extern "C" fn z_query_drop(this_: &mut z_moved_query_t) { - let _ = this_.take_rust_type(); -} -/// Constructs a shallow copy of the query, allowing to keep it in an "open" state past the callback's return. -/// -/// This operation is infallible, but may return a gravestone value if `query` itself was a gravestone value (which cannot be the case in a callback). -#[no_mangle] -pub extern "C" fn z_query_clone(dst: &mut MaybeUninit, this_: &z_loaned_query_t) { - dst.as_rust_type_mut_uninit() - .write(Some(this_.as_rust_type_ref().clone())); -} - -/// Options passed to the `z_declare_queryable()` function. -#[allow(non_camel_case_types)] -#[repr(C)] -pub struct z_queryable_options_t { - /// The completeness of the Queryable. - pub complete: bool, - /// Restricts the matching requests that will be received by this Queryable to the ones - /// that have the compatible allowed_destination. - pub allowed_origin: zc_locality_t, -} -/// Constructs the default value for `z_query_reply_options_t`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_queryable_options_default(this_: &mut MaybeUninit) { - this_.write(z_queryable_options_t { - complete: false, - allowed_origin: zc_locality_default(), - }); -} - -/// Represents the set of options that can be applied to a query reply, -/// sent via `z_query_reply()`. -#[allow(non_camel_case_types)] -#[repr(C)] -pub struct z_query_reply_options_t { - /// The encoding of the reply payload. - pub encoding: Option<&'static mut z_moved_encoding_t>, - /// The congestion control to apply when routing the reply. - pub congestion_control: z_congestion_control_t, - /// The priority of the reply. - pub priority: z_priority_t, - /// If set to ``true``, this reply will not be batched. This usually has a positive impact on latency but negative impact on throughput. - pub is_express: bool, - /// The timestamp of the reply. - pub timestamp: Option<&'static mut z_timestamp_t>, - #[cfg(feature = "unstable")] - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - /// - /// The source info for the reply. - pub source_info: Option<&'static mut z_moved_source_info_t>, - /// The attachment to this reply. - pub attachment: Option<&'static mut z_moved_bytes_t>, -} - -/// Constructs the default value for `z_query_reply_options_t`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_query_reply_options_default(this_: &mut MaybeUninit) { - this_.write(z_query_reply_options_t { - encoding: None, - congestion_control: CongestionControl::DEFAULT_RESPONSE.into(), - priority: Priority::default().into(), - is_express: false, - timestamp: None, - #[cfg(feature = "unstable")] - source_info: None, - attachment: None, - }); -} - -/// Represents the set of options that can be applied to a query reply error, -/// sent via `z_query_reply_err()`. -#[allow(non_camel_case_types)] -#[repr(C)] -pub struct z_query_reply_err_options_t { - /// The encoding of the error payload. - pub encoding: Option<&'static mut z_moved_encoding_t>, -} - -/// Constructs the default value for `z_query_reply_err_options_t`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_query_reply_err_options_default( - this: &mut MaybeUninit, -) { - this.write(z_query_reply_err_options_t { encoding: None }); -} - -/// Represents the set of options that can be applied to a query delete reply, -/// sent via `z_query_reply_del()`. -#[allow(non_camel_case_types)] -#[repr(C)] -pub struct z_query_reply_del_options_t { - /// The congestion control to apply when routing the reply. - pub congestion_control: z_congestion_control_t, - /// The priority of the reply. - pub priority: z_priority_t, - /// If set to ``true``, this reply will not be batched. This usually has a positive impact on latency but negative impact on throughput. - pub is_express: bool, - /// The timestamp of the reply. - pub timestamp: Option<&'static mut z_timestamp_t>, - #[cfg(feature = "unstable")] - /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. - /// - /// The source info for the reply. - pub source_info: Option<&'static mut z_moved_source_info_t>, - /// The attachment to this reply. - pub attachment: Option<&'static mut z_moved_bytes_t>, -} - -/// Constructs the default value for `z_query_reply_del_options_t`. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_query_reply_del_options_default( - this: &mut MaybeUninit, -) { - this.write(z_query_reply_del_options_t { - congestion_control: CongestionControl::DEFAULT_RESPONSE.into(), - priority: Priority::default().into(), - is_express: false, - timestamp: None, - #[cfg(feature = "unstable")] - source_info: None, - attachment: None, - }); -} - -fn _declare_queryable_inner<'a, 'b>( - session: &'a z_loaned_session_t, - key_expr: &'b z_loaned_keyexpr_t, - callback: &mut z_moved_closure_query_t, - options: Option<&mut z_queryable_options_t>, -) -> QueryableBuilder<'a, 'b, Callback> { - let session = session.as_rust_type_ref(); - let keyexpr = key_expr.as_rust_type_ref(); - let callback = callback.take_rust_type(); - let mut builder = session.declare_queryable(keyexpr); - if let Some(options) = options { - builder = builder - .complete(options.complete) - .allowed_origin(options.allowed_origin.into()); - } - let queryable = builder.callback(move |query| { - let mut owned_query = Some(query); - z_closure_query_call(z_closure_query_loan(&callback), unsafe { - owned_query - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() - }) - }); - queryable -} - -/// Constructs a Queryable for the given key expression. -/// -/// @param session: A Zenoh session. -/// @param queryable: An uninitialized memory location where queryable will be constructed. -/// @param key_expr: The key expression the Queryable will reply to. -/// @param callback: The callback function that will be called each time a matching query is received. Its ownership is passed to queryable. -/// @param options: Options for the queryable. -/// -/// @return 0 in case of success, negative error code otherwise (in this case ) -#[no_mangle] -pub extern "C" fn z_declare_queryable( - session: &z_loaned_session_t, - queryable: &mut MaybeUninit, - key_expr: &z_loaned_keyexpr_t, - callback: &mut z_moved_closure_query_t, - options: Option<&mut z_queryable_options_t>, -) -> result::z_result_t { - let this = queryable.as_rust_type_mut_uninit(); - let queryable = _declare_queryable_inner(session, key_expr, callback, options); - match queryable.wait() { - Ok(q) => { - this.write(Some(q)); - result::Z_OK - } - Err(e) => { - crate::report_error!("{}", e); - this.write(None); - result::Z_EGENERIC - } - } -} - -/// Declares a background queryable for a given keyexpr. The queryable callback will be be called -/// to proccess incoming queries until the corresponding session is closed or dropped. -/// -/// @param session: The zenoh session. -/// @param key_expr: The key expression the Queryable will reply to. -/// @param callback: The callback function that will be called each time a matching query is received. Its ownership is passed to queryable. -/// @param options: Options for the queryable. -/// -/// @return 0 in case of success, negative error code otherwise (in this case ) -#[no_mangle] -pub extern "C" fn z_declare_background_queryable( - session: &z_loaned_session_t, - key_expr: &z_loaned_keyexpr_t, - callback: &mut z_moved_closure_query_t, - options: Option<&mut z_queryable_options_t>, -) -> result::z_result_t { - let queryable = _declare_queryable_inner(session, key_expr, callback, options); - match queryable.background().wait() { - Ok(_) => result::Z_OK, - Err(e) => { - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -/// Undeclares queryable callback and resets it to its gravestone state. -/// This is equivalent to calling `z_undeclare_queryable()` and discarding its return value. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub extern "C" fn z_queryable_drop(this_: &mut z_moved_queryable_t) { - std::mem::drop(this_.take_rust_type()) -} - -/// Returns ``true`` if queryable is valid, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_internal_queryable_check(this_: &z_owned_queryable_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns the ID of the queryable. -#[no_mangle] -pub extern "C" fn z_queryable_id(queryable: &z_loaned_queryable_t) -> z_entity_global_id_t { - queryable.as_rust_type_ref().id().into_c_type() -} - -/// Sends a reply to a query. -/// -/// This function must be called inside of a Queryable callback passing the -/// query received as parameters of the callback function. This function can -/// be called multiple times to send multiple replies to a query. The reply -/// will be considered complete when the Queryable callback returns. -/// -/// @param this_: The query to reply to. -/// @param key_expr: The key of this reply. -/// @param payload: The payload of this reply. Will be consumed. -/// @param options: The options of this reply. All owned fields will be consumed. -/// -/// @return 0 in case of success, negative error code otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub extern "C" fn z_query_reply( - this: &z_loaned_query_t, - key_expr: &z_loaned_keyexpr_t, - payload: &mut z_moved_bytes_t, - options: Option<&mut z_query_reply_options_t>, -) -> result::z_result_t { - let query = this.as_rust_type_ref(); - let key_expr = key_expr.as_rust_type_ref(); - let payload = payload.take_rust_type(); - let mut reply = query.reply(key_expr, payload); - if let Some(options) = options { - if let Some(encoding) = options.encoding.take() { - reply = reply.encoding(encoding.take_rust_type()); - }; - #[cfg(feature = "unstable")] - if let Some(source_info) = options.source_info.take() { - reply = reply.source_info(source_info.take_rust_type()); - }; - if let Some(attachment) = options.attachment.take() { - reply = reply.attachment(attachment.take_rust_type()); - } - if let Some(timestamp) = options.timestamp.as_ref() { - reply = reply.timestamp(Some(timestamp.into_rust_type())); - } - reply = reply.priority(options.priority.into()); - reply = reply.congestion_control(options.congestion_control.into()); - reply = reply.express(options.is_express); - } - - if let Err(e) = reply.wait() { - crate::report_error!("{}", e); - return result::Z_EGENERIC; - } - result::Z_OK -} - -/// Sends a error reply to a query. -/// -/// This function must be called inside of a Queryable callback passing the -/// query received as parameters of the callback function. This function can -/// be called multiple times to send multiple replies to a query. The reply -/// will be considered complete when the Queryable callback returns. -/// -/// @param this_: The query to reply to. -/// @param payload: The payload carrying error message. Will be consumed. -/// @param options: The options of this reply. All owned fields will be consumed. -/// -/// @return 0 in case of success, negative error code otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_query_reply_err( - this: &z_loaned_query_t, - payload: &mut z_moved_bytes_t, - options: Option<&mut z_query_reply_err_options_t>, -) -> result::z_result_t { - let query = this.as_rust_type_ref(); - let payload = payload.take_rust_type(); - let reply = query.reply_err(payload).encoding( - options - .and_then(|o| o.encoding.take()) - .map(|e| e.take_rust_type()) - .unwrap_or(Encoding::default()), - ); - - if let Err(e) = reply.wait() { - crate::report_error!("{}", e); - return result::Z_EGENERIC; - } - result::Z_OK -} - -/// Sends a delete reply to a query. -/// -/// This function must be called inside of a Queryable callback passing the -/// query received as parameters of the callback function. This function can -/// be called multiple times to send multiple replies to a query. The reply -/// will be considered complete when the Queryable callback returns. -/// -/// @param this_: The query to reply to. -/// @param key_expr: The key of this delete reply. -/// @param options: The options of this delete reply. All owned fields will be consumed. -/// -/// @return 0 in case of success, negative error code otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_query_reply_del( - this: &z_loaned_query_t, - key_expr: &z_loaned_keyexpr_t, - options: Option<&mut z_query_reply_del_options_t>, -) -> result::z_result_t { - let query = this.as_rust_type_ref(); - let key_expr = key_expr.as_rust_type_ref(); - - let mut reply = query.reply_del(key_expr); - if let Some(options) = options { - #[cfg(feature = "unstable")] - if let Some(source_info) = options.source_info.take() { - reply = reply.source_info(source_info.take_rust_type()); - }; - if let Some(attachment) = options.attachment.take() { - reply = reply.attachment(attachment.take_rust_type()); - } - if let Some(timestamp) = options.timestamp.as_ref() { - reply = reply.timestamp(Some(timestamp.into_rust_type())); - } - reply = reply.priority(options.priority.into()); - reply = reply.congestion_control(options.congestion_control.into()); - reply = reply.express(options.is_express); - } - - if let Err(e) = reply.wait() { - crate::report_error!("{}", e); - return result::Z_EGENERIC; - } - result::Z_OK -} - -/// Gets query key expression. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub extern "C" fn z_query_keyexpr(this_: &z_loaned_query_t) -> &z_loaned_keyexpr_t { - this_.as_rust_type_ref().key_expr().as_loaned_c_type_ref() -} - -/// Gets query value selector. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_query_parameters( - this: &z_loaned_query_t, - parameters: &mut MaybeUninit, -) { - let query = this.as_rust_type_ref(); - let params = query.parameters().as_str(); - unsafe { z_view_string_from_substr(parameters, params.as_ptr() as _, params.len()) }; -} - -/// Gets query payload. -/// -/// Returns NULL if query does not contain a payload. -#[no_mangle] -pub extern "C" fn z_query_payload(this_: &z_loaned_query_t) -> Option<&z_loaned_bytes_t> { - this_ - .as_rust_type_ref() - .payload() - .map(|v| v.as_loaned_c_type_ref()) -} - -/// Gets mutable query payload. -/// -/// Returns NULL if query does not contain a payload. -#[no_mangle] -pub extern "C" fn z_query_payload_mut( - this_: &mut z_loaned_query_t, -) -> Option<&mut z_loaned_bytes_t> { - this_ - .as_rust_type_mut() - .payload_mut() - .map(|v| v.as_loaned_c_type_mut()) -} - -/// Gets query payload encoding. -/// -/// Returns NULL if query does not contain an encoding. -#[no_mangle] -pub extern "C" fn z_query_encoding(this_: &z_loaned_query_t) -> Option<&z_loaned_encoding_t> { - this_ - .as_rust_type_ref() - .encoding() - .map(|v| v.as_loaned_c_type_ref()) -} - -/// Gets query attachment. -/// -/// Returns NULL if query does not contain an attachment. -#[no_mangle] -pub extern "C" fn z_query_attachment(this_: &z_loaned_query_t) -> Option<&z_loaned_bytes_t> { - this_ - .as_rust_type_ref() - .attachment() - .map(|a| a.as_loaned_c_type_ref()) -} - -/// Gets mutable query attachment. -/// -/// Returns NULL if query does not contain an attachment. -#[no_mangle] -pub extern "C" fn z_query_attachment_mut( - this_: &mut z_loaned_query_t, -) -> Option<&mut z_loaned_bytes_t> { - this_ - .as_rust_type_mut() - .attachment_mut() - .map(|a| a.as_loaned_c_type_mut()) -} - -/// Undeclares a `z_owned_queryable_t`. -/// Returns 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn z_undeclare_queryable(this_: &mut z_moved_queryable_t) -> result::z_result_t { - if let Some(qable) = this_.take_rust_type() { - if let Err(e) = qable.undeclare().wait() { - crate::report_error!("{}", e); - return result::Z_EGENERIC; - } - } - result::Z_OK -} - -/// @brief Returns the key expression of the queryable. -#[no_mangle] -pub extern "C" fn z_queryable_keyexpr(queryable: &z_loaned_queryable_t) -> &z_loaned_keyexpr_t { - queryable - .as_rust_type_ref() - .key_expr() - .as_loaned_c_type_ref() -} diff --git a/src/querying_subscriber.rs b/src/querying_subscriber.rs deleted file mode 100644 index affbe457c..000000000 --- a/src/querying_subscriber.rs +++ /dev/null @@ -1,300 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// -#![allow(deprecated)] - -use std::mem::MaybeUninit; - -use zenoh::{handlers::Callback, sample::Sample, session::Session, Wait}; -use zenoh_ext::*; - -use crate::{ - opaque_types::{ze_loaned_querying_subscriber_t, ze_owned_querying_subscriber_t}, - result, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_closure_sample_call, z_closure_sample_loan, z_get_options_t, z_loaned_keyexpr_t, - z_loaned_session_t, z_moved_closure_sample_t, z_query_consolidation_none, - z_query_consolidation_t, z_query_target_default, z_query_target_t, zc_locality_default, - zc_locality_t, -}; -#[cfg(feature = "unstable")] -use crate::{zc_reply_keyexpr_default, zc_reply_keyexpr_t, ze_moved_querying_subscriber_t}; -decl_c_type!( - owned( - ze_owned_querying_subscriber_t, - option(zenoh_ext::FetchingSubscriber<()>, &'static Session), - ), - loaned(ze_loaned_querying_subscriber_t), -); - -/// Constructs a querying subscriber in a gravestone state. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_internal_querying_subscriber_null( - this: &mut MaybeUninit, -) { - this.as_rust_type_mut_uninit().write(None); -} - -/// @warning This API is deprecated. Please use ze_advanced_subscriber. -/// @brief A set of options that can be applied to a querying subscriber, -/// upon its declaration via `ze_declare_querying_subscriber()`. -/// -#[repr(C)] -#[allow(non_camel_case_types)] -pub struct ze_querying_subscriber_options_t { - /// The restriction for the matching publications that will be receive by this subscriber. - allowed_origin: zc_locality_t, - /// The selector to be used for queries. - query_selector: Option<&'static z_loaned_keyexpr_t>, - /// The target to be used for queries. - query_target: z_query_target_t, - /// The consolidation mode to be used for queries. - query_consolidation: z_query_consolidation_t, - #[cfg(feature = "unstable")] - /// The accepted replies for queries. - query_accept_replies: zc_reply_keyexpr_t, - /// The timeout to be used for queries. - query_timeout_ms: u64, -} - -/// @warning This API is deprecated. Please use ze_advanced_subscriber. -/// @brief Constructs the default value for `ze_querying_subscriber_options_t`. -#[no_mangle] -pub extern "C" fn ze_querying_subscriber_options_default( - this: &mut MaybeUninit, -) { - this.write(ze_querying_subscriber_options_t { - allowed_origin: zc_locality_default(), - query_selector: None, - query_target: z_query_target_default(), - query_consolidation: z_query_consolidation_none(), - #[cfg(feature = "unstable")] - query_accept_replies: zc_reply_keyexpr_default(), - query_timeout_ms: 0, - }); -} - -unsafe fn _declare_querying_subscriber_inner<'a, 'b>( - session: &'a z_loaned_session_t, - key_expr: &'b z_loaned_keyexpr_t, - callback: &mut z_moved_closure_sample_t, - options: Option<&mut ze_querying_subscriber_options_t>, -) -> QueryingSubscriberBuilder<'a, 'b, UserSpace, Callback> { - let session = session.as_rust_type_ref(); - let callback = callback.take_rust_type(); - let mut sub = session - .declare_subscriber(key_expr.as_rust_type_ref()) - .querying(); - if let Some(options) = options { - sub = sub - .query_target(options.query_target.into()) - .query_consolidation(options.query_consolidation) - .allowed_origin(options.allowed_origin.into()); - #[cfg(feature = "unstable")] - { - sub = sub.query_accept_replies(options.query_accept_replies.into()); - } - if let Some(query_selector) = options.query_selector { - let query_selector = query_selector.as_rust_type_ref().clone(); - sub = sub.query_selector(query_selector); - } - if options.query_timeout_ms != 0 { - sub = sub.query_timeout(std::time::Duration::from_millis(options.query_timeout_ms)); - } - } - let sub = sub.callback(move |sample| { - let mut owned_sample = Some(sample); - z_closure_sample_call( - z_closure_sample_loan(&callback), - owned_sample - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut(), - ); - }); - sub -} -/// @warning This API is deprecated. Please use ze_advanced_subscriber. -/// @brief Constructs and declares a querying subscriber for a given key expression. -/// -/// @param session: A Zenoh session. -/// @param querying_subscriber: An uninitialized memory location where querying subscriber will be constructed. -/// @param key_expr: A key expression to subscribe to. -/// @param callback: The callback function that will be called each time a data matching the subscribed expression is received. -/// @param options: Additional options for the querying subscriber. -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_declare_querying_subscriber( - session: &'static z_loaned_session_t, - querying_subscriber: &mut MaybeUninit, - key_expr: &z_loaned_keyexpr_t, - callback: &mut z_moved_closure_sample_t, - options: Option<&mut ze_querying_subscriber_options_t>, -) -> result::z_result_t { - let this = querying_subscriber.as_rust_type_mut_uninit(); - let sub = _declare_querying_subscriber_inner(session, key_expr, callback, options); - match sub.wait() { - Ok(sub) => { - let session = session.as_rust_type_ref(); - this.write(Some((sub, session))); - result::Z_OK - } - Err(e) => { - tracing::debug!("{}", e); - this.write(None); - result::Z_EGENERIC - } - } -} - -/// @warning This API is deprecated. Please use ze_advanced_subscriber. -/// @brief Declares a background querying subscriber for a given key expression. Subscriber callback will be called to process the messages, -/// until the corresponding session is closed or dropped. -/// -/// @param session: A Zenoh session. -/// @param key_expr: A key expression to subscribe to. -/// @param callback: The callback function that will be called each time a data matching the subscribed expression is received. -/// @param options: Additional options for the querying subscriber. -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_declare_background_querying_subscriber( - session: &'static z_loaned_session_t, - key_expr: &z_loaned_keyexpr_t, - callback: &mut z_moved_closure_sample_t, - options: Option<&mut ze_querying_subscriber_options_t>, -) -> result::z_result_t { - let sub = _declare_querying_subscriber_inner(session, key_expr, callback, options); - match sub.background().wait() { - Ok(_) => result::Z_OK, - Err(e) => { - tracing::debug!("{}", e); - result::Z_EGENERIC - } - } -} - -/// @warning This API is deprecated. Please use ze_advanced_subscriber. -/// @brief Make querying subscriber perform an additional query on a specified selector. -/// The queried samples will be merged with the received publications and made available in the subscriber callback. -/// @return 0 in case of success, negative error code otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn ze_querying_subscriber_get( - this: &ze_loaned_querying_subscriber_t, - selector: &z_loaned_keyexpr_t, - options: Option<&mut z_get_options_t>, -) -> result::z_result_t { - let sub = this.as_rust_type_ref(); - let session = sub.1; - let selector = selector.as_rust_type_ref().clone(); - if let Err(e) = sub - .0 - .fetch({ - move |cb| { - let mut get = session.get(selector); - - if let Some(options) = options { - if let Some(payload) = options.payload.take() { - get = get.payload(payload.take_rust_type()); - } - if let Some(encoding) = options.encoding.take() { - get = get.encoding(encoding.take_rust_type()); - } - if let Some(attachment) = options.attachment.take() { - get = get.attachment(attachment.take_rust_type()); - } - - get = get - .consolidation(options.consolidation) - .target(options.target.into()) - .congestion_control(options.congestion_control.into()) - .priority(options.priority.into()) - .express(options.is_express); - - #[cfg(feature = "unstable")] - { - if let Some(source_info) = options.source_info.take() { - get = get.source_info(source_info.take_rust_type()); - } - get = get - .allowed_destination(options.allowed_destination.into()) - .accept_replies(options.accept_replies.into()); - } - - if options.timeout_ms != 0 { - get = get.timeout(std::time::Duration::from_millis(options.timeout_ms)); - } - } - - get.callback(cb).wait() - } - }) - .wait() - { - tracing::debug!("{}", e); - return result::Z_EGENERIC; - } - result::Z_OK -} - -/// @warning This API is deprecated. Please use ze_advanced_subscriber. -/// @brief Undeclares querying subscriber callback and resets it to its gravestone state. -/// This is equivalent to calling `ze_undeclare_querying_subscriber()` and discarding its return value. -#[no_mangle] -pub extern "C" fn ze_querying_subscriber_drop(this_: &mut ze_moved_querying_subscriber_t) { - std::mem::drop(this_.take_rust_type()) -} - -/// @warning This API is deprecated. Please use ze_advanced_subscriber. -/// @brief Returns ``true`` if querying subscriber is valid, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn ze_internal_querying_subscriber_check( - this_: &ze_owned_querying_subscriber_t, -) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @warning This API is deprecated. Please use ze_advanced_subscriber. -/// @brief Borrows querying subscriber. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_querying_subscriber_loan( - this: &ze_owned_querying_subscriber_t, -) -> &ze_loaned_querying_subscriber_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// @warning This API is deprecated. Please use ze_advanced_subscriber. -/// @brief Undeclares the given querying subscriber. -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_undeclare_querying_subscriber( - this_: &mut ze_moved_querying_subscriber_t, -) -> result::z_result_t { - if let Some(s) = this_.take_rust_type() { - if let Err(e) = s.0.undeclare().wait() { - crate::report_error!("{}", e); - return result::Z_EGENERIC; - } - } - result::Z_OK -} diff --git a/src/result.rs b/src/result.rs deleted file mode 100644 index ac638e02b..000000000 --- a/src/result.rs +++ /dev/null @@ -1,92 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -#[cfg(feature = "unstable")] -use std::{cell::RefCell, mem::MaybeUninit, str}; - -#[cfg(feature = "unstable")] -use crate::{z_view_string_from_substr, z_view_string_t}; - -#[allow(non_camel_case_types)] -pub type z_result_t = i8; - -pub const Z_CHANNEL_DISCONNECTED: z_result_t = 1; -pub const Z_CHANNEL_NODATA: z_result_t = 2; -pub const Z_OK: z_result_t = 0; -pub const Z_EINVAL: z_result_t = -1; -pub const Z_EPARSE: z_result_t = -2; -pub const Z_EIO: z_result_t = -3; -pub const Z_ENETWORK: z_result_t = -4; -pub const Z_ENULL: z_result_t = -5; -pub const Z_EUNAVAILABLE: z_result_t = -6; -pub const Z_EDESERIALIZE: z_result_t = -7; -pub const Z_ESESSION_CLOSED: z_result_t = -8; -pub const Z_EUTF8: z_result_t = -9; -// negative pthread error codes (due to convention to return negative values on error) -pub const Z_EBUSY_MUTEX: z_result_t = -16; -pub const Z_EINVAL_MUTEX: z_result_t = -22; -pub const Z_EAGAIN_MUTEX: z_result_t = -11; -pub const Z_EPOISON_MUTEX: z_result_t = -22; // same as Z_EINVAL_MUTEX -pub const Z_EGENERIC: z_result_t = i8::MIN; - -#[cfg(feature = "unstable")] -pub struct Buffer { - buffer: [u8; N], - len: usize, -} - -#[cfg(feature = "unstable")] -impl Default for Buffer { - fn default() -> Self { - Self { - buffer: [0; N], - len: Default::default(), - } - } -} - -#[cfg(feature = "unstable")] -impl Buffer { - pub fn update(&mut self, error: &str) { - self.len = error.len().min(N); - (self.buffer[0..self.len]).copy_from_slice(&error.as_bytes()[0..self.len]); - } -} - -#[cfg(feature = "unstable")] -thread_local! { - pub static ERROR_DESCRIPTION: RefCell> = RefCell::default(); -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs a view string on last error message. -/// The view string only remains valid until next faillable zenoh API call from the same thread. -#[no_mangle] -extern "C" fn zc_get_last_error(out: &mut MaybeUninit) { - ERROR_DESCRIPTION.with_borrow(|b| unsafe { - z_view_string_from_substr(out, b.buffer.as_ptr() as *const libc::c_char, b.len) - }); -} - -#[macro_export] -macro_rules! report_error{ - ($($t: tt)*) => { - { - tracing::error!($($t)*); - #[cfg(feature = "unstable")] - $crate::result::ERROR_DESCRIPTION.with_borrow_mut(|b| b.update(&format!($($t)*))); - } - }; -} diff --git a/src/scouting.rs b/src/scouting.rs deleted file mode 100644 index 7e3e9ed6f..000000000 --- a/src/scouting.rs +++ /dev/null @@ -1,250 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// -use std::mem::MaybeUninit; - -use zenoh::{ - config::{WhatAmI, WhatAmIMatcher}, - scouting::Hello, -}; -use zenoh_runtime::ZRuntime; - -pub use crate::opaque_types::{z_loaned_hello_t, z_moved_hello_t, z_owned_hello_t}; -use crate::{ - result, - transmute::{IntoCType, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_closure_hello_call, z_closure_hello_loan, z_id_t, z_moved_closure_hello_t, z_moved_config_t, - z_owned_string_array_t, z_view_string_t, CStringInner, CStringView, ZVector, -}; -decl_c_type!( - owned(z_owned_hello_t, option Hello ), - loaned(z_loaned_hello_t), -); - -/// Frees memory and resets hello message to its gravestone state. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_hello_drop(this_: &mut z_moved_hello_t) { - let _ = this_.take_rust_type(); -} - -/// Borrows hello message. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_hello_loan(this_: &z_owned_hello_t) -> &z_loaned_hello_t { - this_ - .as_rust_type_ref() - .as_ref() - .unwrap() - .as_loaned_c_type_ref() -} - -/// Mutably borrows hello message. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_hello_loan_mut(this_: &mut z_owned_hello_t) -> &mut z_loaned_hello_t { - this_ - .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - -/// Takes ownership of the mutably borrowed hello -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_hello_take_from_loaned( - dst: &mut MaybeUninit, - src: &mut z_loaned_hello_t, -) { - let dst = dst.as_rust_type_mut_uninit(); - let src = src.as_rust_type_mut(); - let src = std::mem::replace(src, Hello::empty()); - dst.write(Some(src)); -} - -/// Returns ``true`` if `hello message` is valid, ``false`` if it is in a gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_hello_check(this_: &z_owned_hello_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// Constructs hello message in a gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_hello_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// Constructs an owned copy of hello message. -#[no_mangle] -pub extern "C" fn z_hello_clone(dst: &mut MaybeUninit, this_: &z_loaned_hello_t) { - dst.as_rust_type_mut_uninit() - .write(Some(this_.as_rust_type_ref().clone())); -} - -/// @brief Returns id of Zenoh entity that transmitted hello message. -#[no_mangle] -pub extern "C" fn z_hello_zid(this_: &z_loaned_hello_t) -> z_id_t { - this_.as_rust_type_ref().zid().into_c_type() -} - -/// Returns type of Zenoh entity that transmitted hello message. -#[no_mangle] -pub extern "C" fn z_hello_whatami(this_: &z_loaned_hello_t) -> z_whatami_t { - match this_.as_rust_type_ref().whatami() { - WhatAmI::Router => z_whatami_t::ROUTER, - WhatAmI::Peer => z_whatami_t::PEER, - WhatAmI::Client => z_whatami_t::CLIENT, - } -} - -/// Constructs an array of non-owned locators (in the form non-null-terminated strings) of Zenoh entity that sent hello message. -/// -/// The lifetime of locator strings is bound to `this_`. -#[no_mangle] -pub extern "C" fn z_hello_locators( - this: &z_loaned_hello_t, - locators_out: &mut MaybeUninit, -) { - let this = this.as_rust_type_ref(); - let mut locators = ZVector::with_capacity(this.locators().len()); - for l in this.locators().iter() { - locators.push(CStringInner::new_borrowed_from_slice(l.as_str().as_bytes())); - } - locators_out.as_rust_type_mut_uninit().write(locators); -} - -/// Options to pass to `z_scout()`. -#[derive(Clone)] -#[repr(C)] -pub struct z_scout_options_t { - /// The maximum duration in ms the scouting can take. - pub timeout_ms: u64, - /// Type of entities to scout for. - pub what: z_what_t, -} - -impl Default for z_scout_options_t { - fn default() -> Self { - z_scout_options_t { - timeout_ms: DEFAULT_SCOUTING_TIMEOUT, - what: DEFAULT_SCOUTING_WHAT, - } - } -} - -#[allow(non_camel_case_types)] -#[repr(C)] -#[derive(Clone, Copy, Debug)] -pub enum z_whatami_t { - ROUTER = 0x01, - PEER = 0x02, - CLIENT = 0x04, -} - -#[allow(non_camel_case_types)] -#[repr(C)] -#[derive(Clone, Copy, Debug)] -pub enum z_what_t { - ROUTER = 0x01, - PEER = 0x02, - CLIENT = 0x04, - ROUTER_PEER = 0x03, // 0x01 | 0x02, - ROUTER_CLIENT = 0x05, // 0x01 | 0x04, - PEER_CLIENT = 0x06, // 0x02 | 0x04, - ROUTER_PEER_CLIENT = 0x07, // 0x01 | 0x02 | 0x04, -} - -pub const DEFAULT_SCOUTING_WHAT: z_what_t = z_what_t::ROUTER_PEER; -pub const DEFAULT_SCOUTING_TIMEOUT: u64 = 1000; - -/// Constructs the default values for the scouting operation. -#[no_mangle] -pub extern "C" fn z_scout_options_default(this_: &mut MaybeUninit) { - this_.write(z_scout_options_t::default()); -} - -/// Scout for routers and/or peers. -/// -/// @param config: A set of properties to configure scouting session. -/// @param callback: A closure that will be called on each hello message received from discoverd Zenoh entities. -/// @param options: A set of scouting options -/// -/// @return 0 if successful, negative error values upon failure. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub extern "C" fn z_scout( - config: &mut z_moved_config_t, - callback: &mut z_moved_closure_hello_t, - options: Option<&z_scout_options_t>, -) -> result::z_result_t { - let callback = callback.take_rust_type(); - let options = options.cloned().unwrap_or_default(); - - let Ok(what) = WhatAmIMatcher::try_from(options.what as u8) else { - crate::report_error!("Invalid WhatAmIMatcher value: {:?}", options.what); - return result::Z_EINVAL; - }; - - #[allow(clippy::unnecessary_cast)] // Required for multi-target - let timeout = options.timeout_ms; - let Some(config) = config.take_rust_type() else { - crate::report_error!("Config not provided"); - return result::Z_EINVAL; - }; - - ZRuntime::Application.block_in_place(async move { - let res = zenoh::scout(what, config) - .callback(move |h| { - let mut owned_h = Some(h); - z_closure_hello_call(z_closure_hello_loan(&callback), unsafe { - owned_h.as_mut().unwrap_unchecked().as_loaned_c_type_mut() - }) - }) - .await; - - match res { - Ok(_) => { - tokio::time::sleep(std::time::Duration::from_millis(timeout)).await; - result::Z_OK - } - Err(e) => { - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } - }) -} - -/// Constructs a non-owned non-null-terminated string from the kind of zenoh entity. -/// -/// The string has static storage (i.e. valid until the end of the program). -/// @param whatami: A whatami bitmask of zenoh entity kind. -/// @param str_out: An uninitialized memory location where strring will be constructed. -/// -/// @return 0 if successful, negative error values if whatami contains an invalid bitmask. -#[no_mangle] -pub extern "C" fn z_whatami_to_view_string( - whatami: z_whatami_t, - str_out: &mut MaybeUninit, -) -> result::z_result_t { - match WhatAmIMatcher::try_from(whatami as u8) { - Err(_) => result::Z_EINVAL, - Ok(w) => { - let s = w.to_str(); - let slice = CStringView::new_borrowed_from_slice(s.as_bytes()); - str_out.as_rust_type_mut_uninit().write(slice); - result::Z_OK - } - } -} diff --git a/src/serialization.rs b/src/serialization.rs deleted file mode 100644 index 1c3b24f01..000000000 --- a/src/serialization.rs +++ /dev/null @@ -1,865 +0,0 @@ -// -// Copyright (c) 2024 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use core::str; -use std::{mem::MaybeUninit, slice::from_raw_parts}; - -use zenoh::bytes::ZBytes; -use zenoh_ext::{ - z_deserialize, z_serialize, Deserialize, Serialize, VarInt, ZDeserializer, ZSerializer, -}; - -pub use crate::opaque_types::{ - ze_deserializer_t, ze_loaned_serializer_t, ze_moved_serializer_t, ze_owned_serializer_t, -}; -use crate::{ - result::{self, z_result_t}, - strlen_or_zero, - transmute::{Gravestone, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_loaned_bytes_t, z_loaned_slice_t, z_loaned_string_t, z_owned_bytes_t, z_owned_slice_t, - z_owned_string_t, CSliceOwned, CStringOwned, -}; - -decl_c_type! { - owned(ze_owned_serializer_t, option ZSerializer), - loaned(ze_loaned_serializer_t), -} - -/// @brief Constructs a serializer with empty payload. -/// @param this_: An uninitialized memory location where serializer is to be constructed. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -extern "C" fn ze_serializer_empty(this: &mut MaybeUninit) -> z_result_t { - this.as_rust_type_mut_uninit() - .write(Some(ZSerializer::new())); - result::Z_OK -} - -/// @brief Drops `this_`, resetting it to gravestone value. -#[no_mangle] -extern "C" fn ze_serializer_drop(this_: &mut ze_moved_serializer_t) { - let _ = this_.take_rust_type(); -} - -/// @brief Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. -#[no_mangle] -extern "C" fn ze_internal_serializer_check(this: &ze_owned_serializer_t) -> bool { - this.as_rust_type_ref().is_some() -} - -/// @brief Borrows serializer. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_serializer_loan( - this: &ze_owned_serializer_t, -) -> &ze_loaned_serializer_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// @brief Muatably borrows serializer. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_serializer_loan_mut( - this: &mut ze_owned_serializer_t, -) -> &mut ze_loaned_serializer_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - -/// @brief Constructs a serializer in a gravestone state. -#[no_mangle] -pub extern "C" fn ze_internal_serializer_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @brief Drop serializer and extract underlying `bytes` object it was writing to. -/// @param this_: A serializer instance. -/// @param bytes: An uninitialized memory location where `bytes` object` will be written to. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn ze_serializer_finish( - this: &mut ze_moved_serializer_t, - bytes: &mut MaybeUninit, -) { - bytes - .as_rust_type_mut_uninit() - .write(this.take_rust_type().unwrap_unchecked().finish()); -} - -decl_c_type! {loaned(ze_deserializer_t, ZDeserializer<'static>)} - -fn ze_serialize_arithmetic(this: &mut MaybeUninit, val: &T) -where - T: Serialize, -{ - this.as_rust_type_mut_uninit().write(z_serialize(val)); -} - -fn ze_deserialize_arithmetic<'a, T>(this: &'a z_loaned_bytes_t, val: &'a mut T) -> z_result_t -where - T: Deserialize, -{ - match z_deserialize(this.as_rust_type_ref()) { - Ok(v) => { - *val = v; - result::Z_OK - } - Err(e) => { - crate::report_error!("Failed to deserialize the payload: {:?}", e); - result::Z_EPARSE - } - } -} - -/// @brief Serializes an unsigned integer. -#[no_mangle] -pub extern "C" fn ze_serialize_uint8( - this_: &mut MaybeUninit, - val: u8, -) -> z_result_t { - ze_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes an unsigned integer. -#[no_mangle] -pub extern "C" fn ze_serialize_uint16( - this_: &mut MaybeUninit, - val: u16, -) -> z_result_t { - ze_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes an unsigned integer. -#[no_mangle] -pub extern "C" fn ze_serialize_uint32( - this_: &mut MaybeUninit, - val: u32, -) -> z_result_t { - ze_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes an unsigned integer. -#[no_mangle] -pub extern "C" fn ze_serialize_uint64( - this_: &mut MaybeUninit, - val: u64, -) -> z_result_t { - ze_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes a signed integer. -#[no_mangle] -pub extern "C" fn ze_serialize_int8( - this_: &mut MaybeUninit, - val: i8, -) -> z_result_t { - ze_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes a signed integer. -#[no_mangle] -pub extern "C" fn ze_serialize_int16( - this_: &mut MaybeUninit, - val: i16, -) -> z_result_t { - ze_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes a signed integer. -#[no_mangle] -pub extern "C" fn ze_serialize_int32( - this_: &mut MaybeUninit, - val: i32, -) -> z_result_t { - ze_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes a signed integer. -#[no_mangle] -pub extern "C" fn ze_serialize_int64( - this_: &mut MaybeUninit, - val: i64, -) -> z_result_t { - ze_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes a float. -#[no_mangle] -pub extern "C" fn ze_serialize_float( - this_: &mut MaybeUninit, - val: f32, -) -> z_result_t { - ze_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes a double. -#[no_mangle] -pub extern "C" fn ze_serialize_double( - this_: &mut MaybeUninit, - val: f64, -) -> z_result_t { - ze_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes a bool. -#[no_mangle] -pub extern "C" fn ze_serialize_bool( - this_: &mut MaybeUninit, - val: bool, -) -> z_result_t { - ze_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Deserializes into an unsigned integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserialize_uint8(this: &z_loaned_bytes_t, dst: &mut u8) -> z_result_t { - ze_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into an unsigned integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserialize_uint16(this: &z_loaned_bytes_t, dst: &mut u16) -> z_result_t { - ze_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into an unsigned integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserialize_uint32(this: &z_loaned_bytes_t, dst: &mut u32) -> z_result_t { - ze_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into an unsigned integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserialize_uint64(this: &z_loaned_bytes_t, dst: &mut u64) -> z_result_t { - ze_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into a signed integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserialize_int8(this: &z_loaned_bytes_t, dst: &mut i8) -> z_result_t { - ze_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into a signed integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserialize_int16(this: &z_loaned_bytes_t, dst: &mut i16) -> z_result_t { - ze_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into a signed integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserialize_int32(this: &z_loaned_bytes_t, dst: &mut i32) -> z_result_t { - ze_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into a signed integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserialize_int64(this: &z_loaned_bytes_t, dst: &mut i64) -> z_result_t { - ze_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into a float. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserialize_float(this: &z_loaned_bytes_t, dst: &mut f32) -> z_result_t { - ze_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into a signed integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserialize_double(this: &z_loaned_bytes_t, dst: &mut f64) -> z_result_t { - ze_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into a bool. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserialize_bool(this: &z_loaned_bytes_t, dst: &mut bool) -> z_result_t { - ze_deserialize_arithmetic::(this, dst) -} - -/// @brief Serializes a slice. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_serialize_slice( - this: &mut MaybeUninit, - slice: &z_loaned_slice_t, -) -> z_result_t { - let cslice = slice.as_rust_type_ref().slice(); - this.as_rust_type_mut_uninit().write(z_serialize(cslice)); - result::Z_OK -} - -/// @brief Serializes a data from buffer by. -/// @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. -/// @param data: A pointer to the buffer containing data. -/// @param len: Length of the buffer. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_serialize_buf( - this: &mut MaybeUninit, - data: *const u8, - len: usize, -) -> z_result_t { - let slice = unsafe { from_raw_parts(data, len) }; - this.as_rust_type_mut_uninit().write(z_serialize(slice)); - result::Z_OK -} - -/// @brief Deserializes into a slice. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_deserialize_slice( - this: &z_loaned_bytes_t, - slice: &mut MaybeUninit, -) -> z_result_t { - let payload = this.as_rust_type_ref(); - match z_deserialize::>(payload) { - Ok(s) => { - slice.as_rust_type_mut_uninit().write(s.into()); - result::Z_OK - } - Err(e) => { - crate::report_error!("Failed to deserialize the payload: {}", e); - slice - .as_rust_type_mut_uninit() - .write(CSliceOwned::gravestone()); - result::Z_EDESERIALIZE - } - } -} - -/// @brief Serializes a string. -/// The string should be a valid UTF-8. -/// @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. -/// @param str: a string to serialize. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn ze_serialize_string( - this: &mut MaybeUninit, - str: &z_loaned_string_t, -) -> z_result_t { - match str::from_utf8(str.as_rust_type_ref().slice()) { - Ok(s) => { - this.as_rust_type_mut_uninit().write(z_serialize(s)); - result::Z_OK - } - Err(e) => { - crate::report_error!("{}", e); - this.as_rust_type_mut_uninit().write(ZBytes::new()); - result::Z_EUTF8 - } - } -} - -/// @brief Serializes a substring. -/// The substring should be a valid UTF-8. -/// @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. -/// @param start: a pointer to the the start of the substring. -/// @param len: the length of the substring. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_serialize_substr( - this: &mut MaybeUninit, - start: *const libc::c_char, - len: usize, -) -> z_result_t { - let slice = unsafe { from_raw_parts(start as *const u8, len) }; - match str::from_utf8(slice) { - Ok(s) => { - this.as_rust_type_mut_uninit().write(z_serialize(s)); - result::Z_OK - } - Err(e) => { - crate::report_error!("{}", e); - this.as_rust_type_mut_uninit().write(ZBytes::new()); - result::Z_EUTF8 - } - } -} - -/// @brief Serializes a null-terminated string. -/// The string should be a valid UTF-8. -/// @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. -/// @param str: a pointer to the null-terminated string. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_serialize_str( - this: &mut MaybeUninit, - str: *const libc::c_char, -) -> z_result_t { - unsafe { ze_serialize_substr(this, str, strlen_or_zero(str)) } -} - -/// @brief Deserializes into a UTF-8 string. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_deserialize_string( - this: &z_loaned_bytes_t, - str: &mut MaybeUninit, -) -> z_result_t { - let payload = this.as_rust_type_ref(); - match z_deserialize::(payload) { - Ok(s) => { - str.as_rust_type_mut_uninit().write(s.into()); - result::Z_OK - } - Err(e) => { - crate::report_error!("Failed to deserialize the payload: {}", e); - str.as_rust_type_mut_uninit() - .write(CStringOwned::gravestone()); - result::Z_EDESERIALIZE - } - } -} - -/// @brief Gets deserializer for`this_`. -#[no_mangle] -extern "C" fn ze_deserializer_from_bytes(this: &'static z_loaned_bytes_t) -> ze_deserializer_t { - *ZDeserializer::new(this.as_rust_type_ref()).as_loaned_c_type_ref() -} - -/// @brief Checks if deserializer parsed all of its data. -/// @return `true` if there is no more data to parse, `false` otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn ze_deserializer_is_done(this_: &ze_deserializer_t) -> bool { - let deserializer = this_.as_rust_type_ref(); - deserializer.done() -} - -fn ze_serializer_serialize_arithmetic(this: &mut ze_loaned_serializer_t, val: &T) -where - T: Serialize, -{ - this.as_rust_type_mut().serialize(val); -} - -fn ze_deserializer_deserialize_arithmetic<'a, T>( - this: &'a mut ze_deserializer_t, - val: &'a mut T, -) -> z_result_t -where - T: Deserialize, -{ - match this.as_rust_type_mut().deserialize::() { - Ok(v) => { - *val = v; - result::Z_OK - } - Err(e) => { - crate::report_error!("Failed to deserialize the payload: {:?}", e); - result::Z_EDESERIALIZE - } - } -} - -/// @brief Serializes an unsigned integer. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_uint8( - this_: &mut ze_loaned_serializer_t, - val: u8, -) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes an unsigned integer. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_uint16( - this_: &mut ze_loaned_serializer_t, - val: u16, -) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes an unsigned integer. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_uint32( - this_: &mut ze_loaned_serializer_t, - val: u32, -) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes an unsigned integer. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_uint64( - this_: &mut ze_loaned_serializer_t, - val: u64, -) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes a signed integer. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_int8( - this_: &mut ze_loaned_serializer_t, - val: i8, -) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes a signed integer. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_int16( - this_: &mut ze_loaned_serializer_t, - val: i16, -) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes a signed integer. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_int32( - this_: &mut ze_loaned_serializer_t, - val: i32, -) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes a signed integer. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_int64( - this_: &mut ze_loaned_serializer_t, - val: i64, -) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes a float. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_float( - this_: &mut ze_loaned_serializer_t, - val: f32, -) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes a double. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_double( - this_: &mut ze_loaned_serializer_t, - val: f64, -) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Serializes a bool. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_bool( - this_: &mut ze_loaned_serializer_t, - val: bool, -) -> z_result_t { - ze_serializer_serialize_arithmetic::(this_, &val); - result::Z_OK -} - -/// @brief Deserializes into an unsigned integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserializer_deserialize_uint8( - this: &mut ze_deserializer_t, - dst: &mut u8, -) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into an unsigned integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserializer_deserialize_uint16( - this: &mut ze_deserializer_t, - dst: &mut u16, -) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into an unsigned integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserializer_deserialize_uint32( - this: &mut ze_deserializer_t, - dst: &mut u32, -) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into an unsigned integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserializer_deserialize_uint64( - this: &mut ze_deserializer_t, - dst: &mut u64, -) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into a signed integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserializer_deserialize_int8( - this: &mut ze_deserializer_t, - dst: &mut i8, -) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into a signed integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserializer_deserialize_int16( - this: &mut ze_deserializer_t, - dst: &mut i16, -) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into a signed integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserializer_deserialize_int32( - this: &mut ze_deserializer_t, - dst: &mut i32, -) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into a signed integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserializer_deserialize_int64( - this: &mut ze_deserializer_t, - dst: &mut i64, -) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into a float. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserializer_deserialize_float( - this: &mut ze_deserializer_t, - dst: &mut f32, -) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into a signed integer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserializer_deserialize_double( - this: &mut ze_deserializer_t, - dst: &mut f64, -) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) -} - -/// @brief Deserializes into a bool. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserializer_deserialize_bool( - this: &mut ze_deserializer_t, - dst: &mut bool, -) -> z_result_t { - ze_deserializer_deserialize_arithmetic::(this, dst) -} - -/// @brief Serializes a slice. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_slice( - this: &mut ze_loaned_serializer_t, - slice: &z_loaned_slice_t, -) -> z_result_t { - let cslice = slice.as_rust_type_ref().slice(); - this.as_rust_type_mut().serialize(cslice); - result::Z_OK -} - -/// @brief Serializes a data from buffer. -/// @param this_: A serializer instance. -/// @param data: A pointer to the buffer containing data. -/// @param len: Length of the buffer. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_buf( - this: &mut ze_loaned_serializer_t, - data: *const u8, - len: usize, -) -> z_result_t { - let slice = unsafe { from_raw_parts(data, len) }; - this.as_rust_type_mut().serialize(slice); - result::Z_OK -} - -/// @brief Deserializes into a slice. -#[no_mangle] -pub extern "C" fn ze_deserializer_deserialize_slice( - this: &mut ze_deserializer_t, - slice: &mut MaybeUninit, -) -> z_result_t { - match this.as_rust_type_mut().deserialize::>() { - Ok(s) => { - slice.as_rust_type_mut_uninit().write(s.into()); - result::Z_OK - } - Err(e) => { - crate::report_error!("Failed to deserialize the payload: {}", e); - slice - .as_rust_type_mut_uninit() - .write(CSliceOwned::gravestone()); - result::Z_EDESERIALIZE - } - } -} - -/// @brief Serializes a string. -/// The string should be a valid UTF-8. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_string( - this: &mut ze_loaned_serializer_t, - str: &z_loaned_string_t, -) -> z_result_t { - match str::from_utf8(str.as_rust_type_ref().slice()) { - Ok(s) => { - this.as_rust_type_mut().serialize(s); - result::Z_OK - } - Err(e) => { - crate::report_error!("{}", e); - result::Z_EUTF8 - } - } -} - -/// @brief Serializes a substring of specified length. -/// The subsstring should be a valid UTF-8. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_substr( - this: &mut ze_loaned_serializer_t, - start: *const libc::c_char, - len: usize, -) -> z_result_t { - let slice = unsafe { from_raw_parts(start as *const u8, len) }; - match str::from_utf8(slice) { - Ok(s) => { - this.as_rust_type_mut().serialize(s); - result::Z_OK - } - Err(e) => { - crate::report_error!("{}", e); - result::Z_EUTF8 - } - } -} - -/// @brief Serializes a null-terminated string. -/// The string should be a valid UTF-8. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_str( - this: &mut ze_loaned_serializer_t, - str: *const libc::c_char, -) -> z_result_t { - ze_serializer_serialize_substr(this, str, unsafe { strlen_or_zero(str) }) -} - -/// @brief Deserializes into a string. -#[no_mangle] -pub extern "C" fn ze_deserializer_deserialize_string( - this: &mut ze_deserializer_t, - str: &mut MaybeUninit, -) -> z_result_t { - match this.as_rust_type_mut().deserialize::() { - Ok(s) => { - str.as_rust_type_mut_uninit().write(s.into()); - result::Z_OK - } - Err(e) => { - crate::report_error!("Failed to deserialize the payload: {}", e); - str.as_rust_type_mut_uninit() - .write(CStringOwned::gravestone()); - result::Z_EDESERIALIZE - } - } -} - -/// @brief Initiates serialization of a sequence of multiple elements. -/// @param this_: A serializer instance. -/// @param len: Length of the sequence. Could be read during deserialization using `ze_deserializer_deserialize_sequence_length`. -#[no_mangle] -pub extern "C" fn ze_serializer_serialize_sequence_length( - this: &mut ze_loaned_serializer_t, - len: usize, -) -> z_result_t { - this.as_rust_type_mut().serialize(VarInt::(len)); - result::Z_OK -} - -/// @brief Initiates deserialization of a sequence of multiple elements. -/// @param this_: A serializer instance. -/// @param len: pointer where the length of the sequence (previously passed via `z_bytes_writer_serialize_sequence_begin`) will be written. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn ze_deserializer_deserialize_sequence_length( - this: &mut ze_deserializer_t, - len: &mut usize, -) -> z_result_t { - match this.as_rust_type_mut().deserialize::>() { - Ok(l) => { - *len = l.0; - result::Z_OK - } - Err(e) => { - crate::report_error!("Failed to read the sequence length: {}", e); - *len = 0; - result::Z_EDESERIALIZE - } - } -} diff --git a/src/session.rs b/src/session.rs deleted file mode 100644 index 69b4b71ae..000000000 --- a/src/session.rs +++ /dev/null @@ -1,229 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::mem::MaybeUninit; - -use zenoh::{Session, Wait}; - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -use crate::z_loaned_shm_client_storage_t; -#[cfg(feature = "unstable")] -use crate::zc_owned_concurrent_close_handle_t; -use crate::{ - opaque_types::{z_loaned_session_t, z_owned_session_t}, - result, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_moved_config_t, z_moved_session_t, -}; -decl_c_type!( - owned(z_owned_session_t, option Session), - loaned(z_loaned_session_t), -); - -/// Borrows session. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_session_loan(this_: &z_owned_session_t) -> &z_loaned_session_t { - this_ - .as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -// Mutably borrows session. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_session_loan_mut( - this_: &mut z_owned_session_t, -) -> &mut z_loaned_session_t { - this_ - .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - -/// Constructs a Zenoh session in its gravestone state. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_internal_session_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// Options passed to the `z_open()` function. -#[repr(C)] -pub struct z_open_options_t { - _dummy: u8, -} - -/// Constructs the default value for `z_open_options_t`. -#[no_mangle] -pub extern "C" fn z_open_options_default(this_: &mut MaybeUninit) { - this_.write(z_open_options_t { _dummy: 0 }); -} - -/// Constructs and opens a new Zenoh session. -/// -/// @return 0 in case of success, negative error code otherwise (in this case the session will be in its gravestone state). -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub extern "C" fn z_open( - this: &mut MaybeUninit, - config: &mut z_moved_config_t, - _options: Option<&z_open_options_t>, -) -> result::z_result_t { - let this = this.as_rust_type_mut_uninit(); - let Some(config) = config.take_rust_type() else { - crate::report_error!("Config not provided"); - this.write(None); - return result::Z_EINVAL; - }; - match zenoh::open(config).wait() { - Ok(s) => { - this.write(Some(s)); - result::Z_OK - } - Err(e) => { - crate::report_error!("Error opening session: {}", e); - this.write(None); - result::Z_ENETWORK - } - } -} - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs and opens a new Zenoh session with specified client storage. -/// -/// @return 0 in case of success, negative error code otherwise (in this case the session will be in its gravestone state). -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub extern "C" fn z_open_with_custom_shm_clients( - this: &mut MaybeUninit, - config: &mut z_moved_config_t, - shm_clients: &z_loaned_shm_client_storage_t, -) -> result::z_result_t { - let this = this.as_rust_type_mut_uninit(); - let Some(config) = config.take_rust_type() else { - crate::report_error!("Config not provided"); - this.write(None); - return result::Z_EINVAL; - }; - match zenoh::open(config) - .with_shm_clients(shm_clients.as_rust_type_ref().clone()) - .wait() - { - Ok(s) => { - this.write(Some(s)); - result::Z_OK - } - Err(e) => { - crate::report_error!("Error opening session: {}", e); - this.write(None); - result::Z_ENETWORK - } - } -} - -/// Returns ``true`` if `session` is valid, ``false`` otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub extern "C" fn z_internal_session_check(this_: &z_owned_session_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// Options passed to the `z_close()` function. -#[repr(C)] -pub struct z_close_options_t { - #[cfg(feature = "unstable")] - #[doc(hidden)] - /// The timeout for close operation in milliseconds. 0 means default close timeout which is 10 seconds. - internal_timeout_ms: u32, - - #[cfg(feature = "unstable")] - #[doc(hidden)] - /// An optional uninitialized concurrent close handle. If set, the close operation will be executed - /// concurrently in separate task, and this handle will be initialized to be used for controlling - /// it's execution. - internal_out_concurrent: Option<&'static mut MaybeUninit>, - - #[cfg(not(feature = "unstable"))] - _dummy: u8, -} - -/// Constructs the default value for `z_close_options_t`. -#[no_mangle] -#[allow(unused)] -pub extern "C" fn z_close_options_default(this_: &mut MaybeUninit) { - this_.write(z_close_options_t { - #[cfg(feature = "unstable")] - internal_timeout_ms: 0, - #[cfg(feature = "unstable")] - internal_out_concurrent: None, - #[cfg(not(feature = "unstable"))] - _dummy: 0, - }); -} - -/// Closes Zenoh session. This also drops all the closure callbacks remaining from not yet dropped or undeclared Zenoh entites (subscribers, queriers, etc). -/// After this operation, all calls for network operations for entites declared on this session will return a error. -/// -/// @return `0` in case of success, a negative value if an error occured while closing the session. -#[no_mangle] -pub extern "C" fn z_close( - session: &mut z_loaned_session_t, - #[allow(unused)] options: Option<&mut z_close_options_t>, -) -> result::z_result_t { - #[allow(unused_mut)] - let mut close_builder = session.as_rust_type_mut().close(); - - #[cfg(feature = "unstable")] - if let Some(options) = options { - if options.internal_timeout_ms != 0 { - close_builder = close_builder.timeout(core::time::Duration::from_millis( - options.internal_timeout_ms as u64, - )) - } - - if let Some(close_handle) = &mut options.internal_out_concurrent { - let handle = close_builder.in_background().wait(); - close_handle.as_rust_type_mut_uninit().write(Some(handle)); - return result::Z_OK; - } - } - - match close_builder.wait() { - Err(e) => { - crate::report_error!("Error closing session: {}", e); - result::Z_EGENERIC - } - Ok(_) => result::Z_OK, - } -} - -/// Checks if zenoh session is closed. -/// -/// @return `true` if session is closed, `false` otherwise. -#[no_mangle] -pub extern "C" fn z_session_is_closed(session: &z_loaned_session_t) -> bool { - let s = session.as_rust_type_ref(); - s.is_closed() -} - -/// Closes and invalidates the session. -#[no_mangle] -pub extern "C" fn z_session_drop(this_: &mut z_moved_session_t) { - let _ = this_.take_rust_type(); -} diff --git a/src/shm/buffer/mod.rs b/src/shm/buffer/mod.rs deleted file mode 100644 index 9238dcdc1..000000000 --- a/src/shm/buffer/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -pub mod zshm; -pub mod zshmmut; diff --git a/src/shm/buffer/zshm.rs b/src/shm/buffer/zshm.rs deleted file mode 100644 index bc682b7e6..000000000 --- a/src/shm/buffer/zshm.rs +++ /dev/null @@ -1,144 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use std::{ - borrow::{Borrow, BorrowMut}, - mem::MaybeUninit, -}; - -use zenoh::shm::{zshm, zshmmut, ZShm}; - -use crate::{ - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_loaned_shm_mut_t, z_loaned_shm_t, z_moved_shm_mut_t, z_moved_shm_t, z_owned_shm_t, -}; - -decl_c_type!( - owned(z_owned_shm_t, option ZShm), - loaned(z_loaned_shm_t, zshm), -); - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs ZShm slice from ZShmMut slice. -#[no_mangle] -pub extern "C" fn z_shm_from_mut( - this_: &mut MaybeUninit, - that: &mut z_moved_shm_mut_t, -) { - let shm: Option = that.take_rust_type().map(|val| val.into()); - this_.as_rust_type_mut_uninit().write(shm); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs ZShm slice in its gravestone value. -#[no_mangle] -pub extern "C" fn z_internal_shm_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @return ``true`` if `this` is valid. -#[no_mangle] -pub extern "C" fn z_internal_shm_check(this_: &z_owned_shm_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Converts borrowed ZShm slice to owned ZShm slice by performing a shallow SHM reference copy. -#[no_mangle] -pub extern "C" fn z_shm_clone(out: &mut MaybeUninit, this_: &z_loaned_shm_t) { - let this = this_.as_rust_type_ref(); - let copy = this.to_owned(); - out.as_rust_type_mut_uninit().write(Some(copy)); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Borrows ZShm slice. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_loan(this_: &z_owned_shm_t) -> &z_loaned_shm_t { - let this: &zshm = this_ - .as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .borrow(); - this.as_loaned_c_type_ref() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Mutably borrows ZShm slice. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_loan_mut(this_: &mut z_owned_shm_t) -> &mut z_loaned_shm_t { - let this: &mut zshm = this_ - .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .borrow_mut(); - this.as_loaned_c_type_mut() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Mutably borrows ZShm slice as borrowed ZShmMut slice. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_try_mut(this_: &mut z_owned_shm_t) -> *mut z_loaned_shm_mut_t { - let this = this_.as_rust_type_mut(); - let this: &mut ZShm = this.as_mut().unwrap_unchecked(); - let shm: &mut zshm = this.borrow_mut(); - match shm.try_into() { - Ok(val) => { - let v: &mut zshmmut = val; - v.as_loaned_c_type_mut() - } - Err(_) => std::ptr::null_mut(), - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Deletes ZShm slice. -#[no_mangle] -pub extern "C" fn z_shm_drop(this_: &mut z_moved_shm_t) { - let _ = this_.take_rust_type(); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Tries to reborrow mutably-borrowed ZShm slice as borrowed ZShmMut slice. -/// @return borrowed ZShmMut slice in case of success, NULL otherwise. -#[no_mangle] -pub extern "C" fn z_shm_try_reloan_mut(this_: &mut z_loaned_shm_t) -> *mut z_loaned_shm_mut_t { - let this = this_.as_rust_type_mut(); - match this.try_into() { - Ok(val) => { - let v: &mut zshmmut = val; - v.as_loaned_c_type_mut() - } - Err(_) => std::ptr::null_mut(), - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @return the length of the ZShm slice. -#[no_mangle] -pub extern "C" fn z_shm_len(this_: &z_loaned_shm_t) -> usize { - this_.as_rust_type_ref().len() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @return the pointer of the ZShm slice. -#[no_mangle] -pub extern "C" fn z_shm_data(this_: &z_loaned_shm_t) -> *const libc::c_uchar { - let s = this_.as_rust_type_ref(); - s.as_ref().as_ptr() -} diff --git a/src/shm/buffer/zshmmut.rs b/src/shm/buffer/zshmmut.rs deleted file mode 100644 index af1b68107..000000000 --- a/src/shm/buffer/zshmmut.rs +++ /dev/null @@ -1,131 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use std::{ - borrow::{Borrow, BorrowMut}, - mem::MaybeUninit, -}; - -use zenoh::shm::{zshmmut, ZShmMut}; - -use crate::{ - result, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_loaned_shm_mut_t, z_moved_shm_mut_t, z_moved_shm_t, z_owned_shm_mut_t, z_owned_shm_t, -}; - -decl_c_type!( - owned(z_owned_shm_mut_t, option ZShmMut), - loaned(z_loaned_shm_mut_t, zshmmut), -); - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Tries to obtain mutable SHM buffer instead of immutable one. -/// @param this_: mutable SHM buffer to be initialized upon success -/// @param that: immutable SHM buffer -/// @param immut: immutable SHM buffer returned back to caller's side -/// ONLY in case of Z_EUNAVAILABLE failure -/// @return Z_OK in case of success, Z_EUNAVAILABLE in case of unsuccessful write access, -/// Z_EINVAL if moved value is incorrect. -#[no_mangle] -pub extern "C" fn z_shm_mut_try_from_immut( - this: &mut MaybeUninit, - that: &mut z_moved_shm_t, - immut: &mut MaybeUninit, -) -> result::z_result_t { - if let Some(shm) = that.take_rust_type() { - return match ZShmMut::try_from(shm) { - Ok(val) => { - this.as_rust_type_mut_uninit().write(Some(val)); - result::Z_OK - } - Err(old) => { - immut.as_rust_type_mut_uninit().write(Some(old)); - result::Z_EUNAVAILABLE - } - }; - } - result::Z_EINVAL -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs ZShmMut slice in its gravestone value. -#[no_mangle] -pub extern "C" fn z_internal_shm_mut_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @return ``true`` if `this` is valid. -#[no_mangle] -pub extern "C" fn z_internal_shm_mut_check(this_: &z_owned_shm_mut_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Borrows ZShmMut slice. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_mut_loan(this_: &z_owned_shm_mut_t) -> &z_loaned_shm_mut_t { - let shmmut: &zshmmut = this_ - .as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .borrow(); - shmmut.as_loaned_c_type_ref() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Mutably borrows ZShmMut slice. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_mut_loan_mut( - this: &mut z_owned_shm_mut_t, -) -> &mut z_loaned_shm_mut_t { - let shmmut: &mut zshmmut = this - .as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .borrow_mut(); - shmmut.as_loaned_c_type_mut() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Deletes ZShmMut slice. -#[no_mangle] -pub extern "C" fn z_shm_mut_drop(this_: &mut z_moved_shm_mut_t) { - let _ = this_.take_rust_type(); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @return the length of the ZShmMut slice. -#[no_mangle] -pub extern "C" fn z_shm_mut_len(this_: &z_loaned_shm_mut_t) -> usize { - this_.as_rust_type_ref().len() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @return the immutable pointer to the underlying data. -#[no_mangle] -pub extern "C" fn z_shm_mut_data(this_: &z_loaned_shm_mut_t) -> *const libc::c_uchar { - let s = this_.as_rust_type_ref(); - s.as_ref().as_ptr() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @return the mutable pointer to the underlying data. -#[no_mangle] -pub extern "C" fn z_shm_mut_data_mut(this_: &mut z_loaned_shm_mut_t) -> *mut libc::c_uchar { - this_.as_rust_type_mut().as_mut().as_mut_ptr() -} diff --git a/src/shm/cleanup.rs b/src/shm/cleanup.rs deleted file mode 100644 index 922c21261..000000000 --- a/src/shm/cleanup.rs +++ /dev/null @@ -1,33 +0,0 @@ -// -// Copyright (c) 2024 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use zenoh::shm::cleanup_orphaned_shm_segments; - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Linux: Trigger cleanup for orphaned SHM segments -/// If process that created named SHM segment crashes or exits by a signal, the segment persists in the system -/// disregarding if it is used by other Zenoh processes or not. This is the detail of POSIX specification for -/// shared memory that is hard to bypass. To deal with this we developed a cleanup routine that enumerates all -/// segments and tries to find processes that are using it. If no such process found, segment will be removed. -/// There is no ideal signal to trigger this cleanup, so by default, zenoh triggers it in the following moments: -/// - first POSIX SHM segment creation -/// - process exit via exit() call or return from maint function -/// -/// It is OK to additionally trigger this function at any time, but be aware that this can be costly. -/// -/// For non-linux platforms this function currently does nothing -#[no_mangle] -pub extern "C" fn zc_cleanup_orphaned_shm_segments() { - cleanup_orphaned_shm_segments(); -} diff --git a/src/shm/client/mod.rs b/src/shm/client/mod.rs deleted file mode 100644 index 4a147cbf6..000000000 --- a/src/shm/client/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -pub mod shm_client; -pub mod shm_segment; diff --git a/src/shm/client/shm_client.rs b/src/shm/client/shm_client.rs deleted file mode 100644 index 8e037cab3..000000000 --- a/src/shm/client/shm_client.rs +++ /dev/null @@ -1,112 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// -use std::{mem::MaybeUninit, sync::Arc}; - -use libc::c_void; -use zenoh::{ - internal::bail, - shm::{ProtocolID, SegmentID, ShmClient, ShmSegment, WithProtocolID}, - Result, -}; - -use super::shm_segment::{z_shm_segment_t, DynamicShmSegment}; -pub use crate::opaque_types::{z_moved_shm_client_t, z_owned_shm_client_t}; -use crate::{ - context::{zc_threadsafe_context_t, DroppableContext, ThreadsafeContext}, - shm::common::types::{z_protocol_id_t, z_segment_id_t}, - transmute::{RustTypeRef, RustTypeRefUninit, TakeRustType}, -}; - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Callback for ShmClient. -#[derive(Debug)] -#[repr(C)] -pub struct zc_shm_client_callbacks_t { - /// Attach to particular shared memory segment - attach_fn: unsafe extern "C" fn( - out_segment: &mut MaybeUninit, - segment_id: z_segment_id_t, - context: *mut c_void, - ) -> bool, - - /// ID of SHM Protocol this client implements - id_fn: unsafe extern "C" fn(context: *mut c_void) -> z_protocol_id_t, -} - -decl_c_type!( - owned(z_owned_shm_client_t, option Arc), -); - -#[derive(Debug)] -pub struct DynamicShmClient { - context: ThreadsafeContext, - callbacks: zc_shm_client_callbacks_t, -} - -impl DynamicShmClient { - pub fn new(context: ThreadsafeContext, callbacks: zc_shm_client_callbacks_t) -> Self { - Self { context, callbacks } - } -} - -impl WithProtocolID for DynamicShmClient { - fn id(&self) -> ProtocolID { - unsafe { (self.callbacks.id_fn)(self.context.get()) } - } -} - -impl ShmClient for DynamicShmClient { - fn attach(&self, segment: SegmentID) -> Result> { - let mut segment_data = MaybeUninit::uninit(); - unsafe { - match (self.callbacks.attach_fn)(&mut segment_data, segment, self.context.get()) { - true => Ok(Arc::new(DynamicShmSegment::new(segment_data.assume_init()))), - false => bail!("C Callback returned error"), - } - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Creates a new SHM Client. -#[no_mangle] -pub extern "C" fn z_shm_client_new( - this: &mut MaybeUninit, - context: zc_threadsafe_context_t, - callbacks: zc_shm_client_callbacks_t, -) { - let client = Arc::new(DynamicShmClient::new(context.into(), callbacks)) as Arc; - this.as_rust_type_mut_uninit().write(Some(client)); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs SHM client in its gravestone value. -#[no_mangle] -pub extern "C" fn z_internal_shm_client_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @return Returns ``true`` if `this` is valid. -#[no_mangle] -pub extern "C" fn z_internal_shm_client_check(this_: &z_owned_shm_client_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Deletes SHM Client. -#[no_mangle] -pub extern "C" fn z_shm_client_drop(this_: &mut z_moved_shm_client_t) { - let _ = this_.take_rust_type(); -} diff --git a/src/shm/client/shm_segment.rs b/src/shm/client/shm_segment.rs deleted file mode 100644 index 2da9cfc4c..000000000 --- a/src/shm/client/shm_segment.rs +++ /dev/null @@ -1,70 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use libc::c_void; -use zenoh::{ - shm::{ChunkID, ShmSegment}, - Result, -}; - -use crate::{ - context::{zc_threadsafe_context_t, DroppableContext, ThreadsafeContext}, - shm::common::types::z_chunk_id_t, -}; - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Callbacks for ShmSegment. -#[derive(Debug)] -#[repr(C)] -pub struct zc_shm_segment_callbacks_t { - /// Obtain the actual region of memory identified by it's id. - map_fn: unsafe extern "C" fn(chunk_id: z_chunk_id_t, context: *mut c_void) -> *mut u8, -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An ShmSegment. -#[derive(Debug)] -#[repr(C)] -pub struct z_shm_segment_t { - context: zc_threadsafe_context_t, - callbacks: zc_shm_segment_callbacks_t, -} - -#[derive(Debug)] -pub struct DynamicShmSegment { - context: ThreadsafeContext, - callbacks: zc_shm_segment_callbacks_t, -} - -impl DynamicShmSegment { - pub fn new(data: z_shm_segment_t) -> Self { - Self { - context: data.context.into(), - callbacks: data.callbacks, - } - } -} - -impl ShmSegment for DynamicShmSegment { - fn map(&self, chunk: ChunkID) -> Result<*mut u8> { - unsafe { - let cb_result = (self.callbacks.map_fn)(chunk, self.context.get()); - if cb_result.is_null() { - Err("C callback returned null pointer!".into()) - } else { - Ok(cb_result) - } - } - } -} diff --git a/src/shm/client_storage/mod.rs b/src/shm/client_storage/mod.rs deleted file mode 100644 index 6e90cf22f..000000000 --- a/src/shm/client_storage/mod.rs +++ /dev/null @@ -1,201 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use std::{mem::MaybeUninit, sync::Arc}; - -use zenoh::shm::{ShmClient, ShmClientStorage, GLOBAL_CLIENT_STORAGE}; - -use crate::{ - result::{z_result_t, Z_EINVAL, Z_OK}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_loaned_shm_client_storage_t, z_moved_shm_client_storage_t, z_moved_shm_client_t, - z_owned_shm_client_storage_t, zc_loaned_shm_client_list_t, zc_moved_shm_client_list_t, - zc_owned_shm_client_list_t, -}; - -decl_c_type!( - owned(zc_owned_shm_client_list_t, option Vec>), - loaned(zc_loaned_shm_client_list_t), -); - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Creates a new empty list of SHM Clients. -#[no_mangle] -pub extern "C" fn zc_shm_client_list_new(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(Some(Vec::default())); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs SHM client list in its gravestone value. -#[no_mangle] -pub extern "C" fn zc_internal_shm_client_list_null( - this_: &mut MaybeUninit, -) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns ``true`` if `this` is valid. -#[no_mangle] -pub extern "C" fn zc_internal_shm_client_list_check(this_: &zc_owned_shm_client_list_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Deletes list of SHM Clients. -#[no_mangle] -pub extern "C" fn zc_shm_client_list_drop(this_: &mut zc_moved_shm_client_list_t) { - let _ = this_.take_rust_type(); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Borrows list of SHM Clients. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn zc_shm_client_list_loan( - this: &zc_owned_shm_client_list_t, -) -> &zc_loaned_shm_client_list_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Mutably borrows list of SHM Clients. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn zc_shm_client_list_loan_mut( - this: &mut zc_owned_shm_client_list_t, -) -> &mut zc_loaned_shm_client_list_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Add client to the list. -#[no_mangle] -pub extern "C" fn zc_shm_client_list_add_client( - this: &mut zc_loaned_shm_client_list_t, - client: &mut z_moved_shm_client_t, -) -> z_result_t { - let Some(client) = client.take_rust_type() else { - return Z_EINVAL; - }; - this.as_rust_type_mut().push(client); - Z_OK -} - -decl_c_type!( - owned(z_owned_shm_client_storage_t, option Arc ), - loaned(z_loaned_shm_client_storage_t), -); - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Reference the global client storage. -#[no_mangle] -pub extern "C" fn z_ref_shm_client_storage_global( - this: &mut MaybeUninit, -) { - this.as_rust_type_mut_uninit() - .write(Some(Arc::clone(&GLOBAL_CLIENT_STORAGE.read()))); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Construct client storage with default client set. -#[no_mangle] -pub extern "C" fn z_shm_client_storage_new_default( - this: &mut MaybeUninit, -) { - this.as_rust_type_mut_uninit().write(Some(Arc::new( - ShmClientStorage::builder() - .with_default_client_set() - .build(), - ))); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Create a new client storage object. -#[no_mangle] -pub extern "C" fn z_shm_client_storage_new( - this: &mut MaybeUninit, - clients: &zc_loaned_shm_client_list_t, - add_default_client_set: bool, -) -> z_result_t { - let clients = clients.as_rust_type_ref(); - if clients.is_empty() { - return Z_EINVAL; - } - - let builder = match add_default_client_set { - true => ShmClientStorage::builder() - .with_default_client_set() - .with_clients(clients), - false => ShmClientStorage::builder().with_clients(clients), - }; - this.as_rust_type_mut_uninit() - .write(Some(Arc::new(builder.build()))); - Z_OK -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Performs a shallow copy of SHM Client Storage. -#[no_mangle] -pub extern "C" fn z_shm_client_storage_clone( - this: &mut MaybeUninit, - from: &z_loaned_shm_client_storage_t, -) { - this.as_rust_type_mut_uninit() - .write(Some(from.as_rust_type_ref().clone())); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Constructs SHM Client Storage in its gravestone value. -#[no_mangle] -pub extern "C" fn z_internal_shm_client_storage_null( - this_: &mut MaybeUninit, -) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @return ``true`` if `this` is valid. -#[no_mangle] -pub extern "C" fn z_internal_shm_client_storage_check( - this_: &z_owned_shm_client_storage_t, -) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Derefs SHM Client Storage. -#[no_mangle] -pub extern "C" fn z_shm_client_storage_drop(this_: &mut z_moved_shm_client_storage_t) { - let _ = this_.take_rust_type(); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Borrows SHM Client Storage. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_client_storage_loan( - this: &z_owned_shm_client_storage_t, -) -> &z_loaned_shm_client_storage_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} diff --git a/src/shm/common/mod.rs b/src/shm/common/mod.rs deleted file mode 100644 index 222c7286b..000000000 --- a/src/shm/common/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -pub mod types; diff --git a/src/shm/common/types.rs b/src/shm/common/types.rs deleted file mode 100644 index 4b5573480..000000000 --- a/src/shm/common/types.rs +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Unique protocol identifier. -/// Here is a contract: it is up to user to make sure that incompatible ShmClient -/// and ShmProviderBackend implementations will never use the same ProtocolID. -#[allow(non_camel_case_types)] -pub type z_protocol_id_t = u32; - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Unique segment identifier. -#[allow(non_camel_case_types)] -pub type z_segment_id_t = u32; - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Chunk id within it's segment. -#[allow(non_camel_case_types)] -pub type z_chunk_id_t = u32; diff --git a/src/shm/mod.rs b/src/shm/mod.rs deleted file mode 100644 index 8802b1eb5..000000000 --- a/src/shm/mod.rs +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -pub mod buffer; -pub mod cleanup; -pub mod client; -pub mod client_storage; -pub mod common; -pub mod protocol_implementations; -pub mod provider; diff --git a/src/shm/protocol_implementations/mod.rs b/src/shm/protocol_implementations/mod.rs deleted file mode 100644 index df92f6353..000000000 --- a/src/shm/protocol_implementations/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -pub mod posix; diff --git a/src/shm/protocol_implementations/posix/mod.rs b/src/shm/protocol_implementations/posix/mod.rs deleted file mode 100644 index 2cd44fbe4..000000000 --- a/src/shm/protocol_implementations/posix/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -pub mod posix_shm_client; -pub mod posix_shm_provider; diff --git a/src/shm/protocol_implementations/posix/posix_shm_client.rs b/src/shm/protocol_implementations/posix/posix_shm_client.rs deleted file mode 100644 index b9eae945b..000000000 --- a/src/shm/protocol_implementations/posix/posix_shm_client.rs +++ /dev/null @@ -1,27 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use std::{mem::MaybeUninit, sync::Arc}; - -use zenoh::shm::{PosixShmClient, ShmClient}; - -use crate::{transmute::RustTypeRefUninit, z_owned_shm_client_t}; - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Creates a new POSIX SHM Client. -#[no_mangle] -pub extern "C" fn z_posix_shm_client_new(this_: &mut MaybeUninit) { - let client = Arc::new(PosixShmClient) as Arc; - this_.as_rust_type_mut_uninit().write(Some(client)); -} diff --git a/src/shm/protocol_implementations/posix/posix_shm_provider.rs b/src/shm/protocol_implementations/posix/posix_shm_provider.rs deleted file mode 100644 index 89161d20d..000000000 --- a/src/shm/protocol_implementations/posix/posix_shm_provider.rs +++ /dev/null @@ -1,78 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use std::mem::MaybeUninit; - -use zenoh::{ - shm::{AllocLayout, PosixShmProviderBackend, ShmProvider, ShmProviderBuilder}, - Wait, -}; - -use crate::{ - result::{z_result_t, Z_EINVAL, Z_OK}, - shm::provider::shm_provider::CSHMProvider, - transmute::{RustTypeRef, RustTypeRefUninit}, - z_loaned_memory_layout_t, z_owned_shm_provider_t, -}; - -pub type PosixShmProvider = ShmProvider; - -pub type PosixAllocLayout = AllocLayout<'static, PosixShmProviderBackend>; - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Creates a new POSIX SHM Provider. -#[no_mangle] -pub extern "C" fn z_posix_shm_provider_new( - this: &mut MaybeUninit, - size: usize, -) -> z_result_t { - let this = this.as_rust_type_mut_uninit(); - match PosixShmProviderBackend::builder().with_size(size).wait() { - Ok(backend) => { - let provider = ShmProviderBuilder::backend(backend).wait(); - this.write(Some(CSHMProvider::Posix(provider))); - Z_OK - } - Err(e) => { - this.write(None); - crate::report_error!("{}", e); - Z_EINVAL - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Creates a new POSIX SHM Provider. -#[no_mangle] -pub extern "C" fn z_posix_shm_provider_with_layout_new( - this: &mut MaybeUninit, - layout: &z_loaned_memory_layout_t, -) -> z_result_t { - let this = this.as_rust_type_mut_uninit(); - match PosixShmProviderBackend::builder() - .with_layout(layout.as_rust_type_ref()) - .wait() - { - Ok(backend) => { - let provider = ShmProviderBuilder::backend(backend).wait(); - this.write(Some(CSHMProvider::Posix(provider))); - Z_OK - } - Err(e) => { - this.write(None); - crate::report_error!("{}", e); - Z_EINVAL - } - } -} diff --git a/src/shm/provider/alloc_layout.rs b/src/shm/provider/alloc_layout.rs deleted file mode 100644 index f0d2359ec..000000000 --- a/src/shm/provider/alloc_layout.rs +++ /dev/null @@ -1,173 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use std::mem::MaybeUninit; - -use libc::c_void; -use zenoh::shm::{AllocLayout, BlockOn, Deallocate, Defragment, GarbageCollect, JustAlloc}; - -use super::{ - alloc_layout_impl::{alloc, alloc_async, alloc_layout_new, alloc_layout_with_alignment_new}, - shm_provider_backend::DynamicShmProviderBackend, - types::{z_alloc_alignment_t, z_buf_alloc_result_t}, -}; -use crate::{ - context::{zc_threadsafe_context_t, Context, ThreadsafeContext}, - result::z_result_t, - shm::protocol_implementations::posix::posix_shm_provider::PosixAllocLayout, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_loaned_alloc_layout_t, z_loaned_shm_provider_t, z_moved_alloc_layout_t, - z_owned_alloc_layout_t, -}; - -pub type DynamicAllocLayout = AllocLayout<'static, DynamicShmProviderBackend>; - -pub type DynamicAllocLayoutThreadsafe = - AllocLayout<'static, DynamicShmProviderBackend>; - -pub enum CSHMLayout { - Posix(PosixAllocLayout), - Dynamic(DynamicAllocLayout), - DynamicThreadsafe(DynamicAllocLayoutThreadsafe), -} - -decl_c_type!( - owned(z_owned_alloc_layout_t, option CSHMLayout), - loaned(z_loaned_alloc_layout_t), -); - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Creates a new Alloc Layout for SHM Provider. -#[no_mangle] -pub extern "C" fn z_alloc_layout_new( - this: &mut MaybeUninit, - provider: &'static z_loaned_shm_provider_t, - size: usize, -) -> z_result_t { - alloc_layout_new(this, provider, size) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Creates a new Alloc Layout for SHM Provider specifying the exact alignment. -#[no_mangle] -pub extern "C" fn z_alloc_layout_with_alignment_new( - this: &mut MaybeUninit, - provider: &'static z_loaned_shm_provider_t, - size: usize, - alignment: z_alloc_alignment_t, -) -> z_result_t { - alloc_layout_with_alignment_new(this, provider, size, alignment) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs Alloc Layout in its gravestone value. -#[no_mangle] -pub extern "C" fn z_internal_alloc_layout_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns ``true`` if `this` is valid. -#[no_mangle] -pub extern "C" fn z_internal_alloc_layout_check(this_: &z_owned_alloc_layout_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Borrows Alloc Layout. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_alloc_layout_loan( - this: &z_owned_alloc_layout_t, -) -> &z_loaned_alloc_layout_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Deletes Alloc Layout. -#[no_mangle] -pub extern "C" fn z_alloc_layout_drop(this_: &mut z_moved_alloc_layout_t) { - let _ = this_.take_rust_type(); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make allocation without any additional actions. -#[no_mangle] -pub extern "C" fn z_alloc_layout_alloc( - out_result: &mut MaybeUninit, - layout: &z_loaned_alloc_layout_t, -) { - alloc::(out_result, layout); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make allocation performing garbage collection if needed. -#[no_mangle] -pub extern "C" fn z_alloc_layout_alloc_gc( - out_result: &mut MaybeUninit, - layout: &z_loaned_alloc_layout_t, -) { - alloc::(out_result, layout); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make allocation performing garbage collection and/or defragmentation if needed. -#[no_mangle] -pub extern "C" fn z_alloc_layout_alloc_gc_defrag( - out_result: &mut MaybeUninit, - layout: &z_loaned_alloc_layout_t, -) { - alloc::>(out_result, layout); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make allocation performing garbage collection and/or defragmentation and/or forced deallocation if needed. -#[no_mangle] -pub extern "C" fn z_alloc_layout_alloc_gc_defrag_dealloc( - out_result: &mut MaybeUninit, - layout: &z_loaned_alloc_layout_t, -) { - alloc::>>(out_result, layout); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make allocation performing garbage collection and/or defragmentation and/or blocking if needed. -#[no_mangle] -pub extern "C" fn z_alloc_layout_alloc_gc_defrag_blocking( - out_result: &mut MaybeUninit, - layout: &z_loaned_alloc_layout_t, -) { - alloc::>>(out_result, layout); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make allocation performing garbage collection and/or defragmentation in async manner. Will return Z_EINVAL -/// if used with non-threadsafe SHM Provider. -#[no_mangle] -pub extern "C" fn z_alloc_layout_threadsafe_alloc_gc_defrag_async( - out_result: &'static mut MaybeUninit, - layout: &'static z_loaned_alloc_layout_t, - result_context: zc_threadsafe_context_t, - result_callback: unsafe extern "C" fn(*mut c_void, &mut MaybeUninit), -) -> z_result_t { - alloc_async::>>( - out_result, - layout, - result_context, - result_callback, - ) -} diff --git a/src/shm/provider/alloc_layout_impl.rs b/src/shm/provider/alloc_layout_impl.rs deleted file mode 100644 index 6353032b9..000000000 --- a/src/shm/provider/alloc_layout_impl.rs +++ /dev/null @@ -1,185 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use std::mem::MaybeUninit; - -use libc::c_void; -use zenoh::{ - shm::{ - AllocLayout, AllocPolicy, AsyncAllocPolicy, PosixShmProviderBackend, ShmProviderBackend, - }, - Wait, -}; - -use super::{ - alloc_layout::CSHMLayout, shm_provider_backend::DynamicShmProviderBackend, - types::z_alloc_alignment_t, -}; -use crate::{ - context::{zc_threadsafe_context_t, DroppableContext, ThreadsafeContext}, - result::{z_result_t, Z_EINVAL, Z_OK}, - shm::provider::types::z_buf_alloc_result_t, - transmute::{IntoRustType, RustTypeRef, RustTypeRefUninit}, - z_loaned_alloc_layout_t, z_loaned_shm_provider_t, z_owned_alloc_layout_t, -}; - -pub(crate) fn alloc_layout_new( - this: &mut MaybeUninit, - provider: &'static z_loaned_shm_provider_t, - size: usize, -) -> z_result_t { - let layout = match provider.as_rust_type_ref() { - super::shm_provider::CSHMProvider::Posix(provider) => { - match provider.alloc(size).into_layout() { - Ok(layout) => CSHMLayout::Posix(layout), - Err(e) => { - crate::report_error!("{:?}", e); - return Z_EINVAL; - } - } - } - super::shm_provider::CSHMProvider::Dynamic(provider) => { - match provider.alloc(size).into_layout() { - Ok(layout) => CSHMLayout::Dynamic(layout), - Err(e) => { - crate::report_error!("{:?}", e); - return Z_EINVAL; - } - } - } - super::shm_provider::CSHMProvider::DynamicThreadsafe(provider) => { - match provider.alloc(size).into_layout() { - Ok(layout) => CSHMLayout::DynamicThreadsafe(layout), - Err(e) => { - crate::report_error!("{:?}", e); - return Z_EINVAL; - } - } - } - }; - this.as_rust_type_mut_uninit().write(Some(layout)); - Z_OK -} - -pub(crate) fn alloc_layout_with_alignment_new( - this: &mut MaybeUninit, - provider: &'static z_loaned_shm_provider_t, - size: usize, - alignment: z_alloc_alignment_t, -) -> z_result_t { - let layout = match provider.as_rust_type_ref() { - super::shm_provider::CSHMProvider::Posix(provider) => { - match provider - .alloc(size) - .with_alignment(alignment.into_rust_type()) - .into_layout() - { - Ok(layout) => CSHMLayout::Posix(layout), - Err(e) => { - crate::report_error!("{:?}", e); - return Z_EINVAL; - } - } - } - super::shm_provider::CSHMProvider::Dynamic(provider) => { - match provider - .alloc(size) - .with_alignment(alignment.into_rust_type()) - .into_layout() - { - Ok(layout) => CSHMLayout::Dynamic(layout), - Err(e) => { - crate::report_error!("{:?}", e); - return Z_EINVAL; - } - } - } - super::shm_provider::CSHMProvider::DynamicThreadsafe(provider) => { - match provider - .alloc(size) - .with_alignment(alignment.into_rust_type()) - .into_layout() - { - Ok(layout) => CSHMLayout::DynamicThreadsafe(layout), - Err(e) => { - crate::report_error!("{:?}", e); - return Z_EINVAL; - } - } - } - }; - this.as_rust_type_mut_uninit().write(Some(layout)); - Z_OK -} - -pub(crate) fn alloc( - out_result: &mut MaybeUninit, - layout: &z_loaned_alloc_layout_t, -) { - let result = match layout.as_rust_type_ref() { - super::alloc_layout::CSHMLayout::Posix(layout) => { - layout.alloc().with_policy::().wait() - } - super::alloc_layout::CSHMLayout::Dynamic(layout) => { - layout.alloc().with_policy::().wait() - } - super::alloc_layout::CSHMLayout::DynamicThreadsafe(layout) => { - layout.alloc().with_policy::().wait() - } - }; - out_result.write(result.into()); -} - -pub(crate) fn alloc_async( - out_result: &'static mut MaybeUninit, - layout: &'static z_loaned_alloc_layout_t, - result_context: zc_threadsafe_context_t, - result_callback: unsafe extern "C" fn(*mut c_void, &mut MaybeUninit), -) -> z_result_t { - match layout.as_rust_type_ref() { - super::alloc_layout::CSHMLayout::Posix(layout) => { - alloc_async_impl::( - out_result, - layout, - result_context, - result_callback, - ); - Z_OK - } - super::alloc_layout::CSHMLayout::Dynamic(_) => Z_EINVAL, - super::alloc_layout::CSHMLayout::DynamicThreadsafe(layout) => { - alloc_async_impl::>( - out_result, - layout, - result_context, - result_callback, - ); - Z_OK - } - } -} - -pub fn alloc_async_impl( - out_result: &'static mut MaybeUninit, - layout: &'static AllocLayout<'static, Backend>, - result_context: zc_threadsafe_context_t, - result_callback: unsafe extern "C" fn(*mut c_void, &mut MaybeUninit), -) { - let result_context: ThreadsafeContext = result_context.into(); - zenoh_runtime::ZRuntime::Application.spawn(async move { - let result = layout.alloc().with_policy::().await; - out_result.write(result.into()); - unsafe { (result_callback)(result_context.get(), out_result) }; - }); -} diff --git a/src/shm/provider/chunk.rs b/src/shm/provider/chunk.rs deleted file mode 100644 index bd921c93c..000000000 --- a/src/shm/provider/chunk.rs +++ /dev/null @@ -1,131 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// -use std::{mem::MaybeUninit, num::TryFromIntError, sync::Arc}; - -use zenoh::shm::{AllocatedChunk, ChunkDescriptor, PtrInSegment}; - -use crate::{ - context::{zc_threadsafe_context_t, ThreadsafeContext}, - opaque_types::{z_loaned_ptr_in_segment_t, z_moved_ptr_in_segment_t, z_owned_ptr_in_segment_t}, - shm::common::types::{z_chunk_id_t, z_segment_id_t}, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, -}; - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A ChunkDescriptor. -#[repr(C)] -pub struct z_chunk_descriptor_t { - segment: z_segment_id_t, - chunk: z_chunk_id_t, - len: usize, -} - -impl TryFrom for ChunkDescriptor { - type Error = TryFromIntError; - fn try_from(value: z_chunk_descriptor_t) -> Result { - Ok(Self::new(value.segment, value.chunk, value.len.try_into()?)) - } -} - -impl From<&ChunkDescriptor> for z_chunk_descriptor_t { - fn from(value: &ChunkDescriptor) -> Self { - Self { - segment: value.segment, - chunk: value.chunk, - len: value.len.get(), - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An AllocatedChunk. -#[repr(C)] -pub struct z_allocated_chunk_t { - descriptpr: z_chunk_descriptor_t, - ptr: &'static mut z_moved_ptr_in_segment_t, -} - -impl TryFrom for AllocatedChunk { - type Error = zenoh::Error; - fn try_from(value: z_allocated_chunk_t) -> Result { - let ptr = value.ptr.take_rust_type().ok_or("Ptr is not initialized")?; - Ok(Self::new(value.descriptpr.try_into()?, ptr)) - } -} - -decl_c_type!( - owned(z_owned_ptr_in_segment_t, option PtrInSegment), - loaned(z_loaned_ptr_in_segment_t), -); - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Creates a new data pointer in SHM Segment. -#[no_mangle] -pub extern "C" fn z_ptr_in_segment_new( - this: &mut MaybeUninit, - ptr: *mut u8, - segment: zc_threadsafe_context_t, -) { - let segment: ThreadsafeContext = segment.into(); - this.as_rust_type_mut_uninit() - .write(Some(PtrInSegment::new(ptr, Arc::new(segment)))); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs data pointer in SHM Segment in its gravestone value. -#[no_mangle] -pub extern "C" fn z_internal_ptr_in_segment_null( - this_: &mut MaybeUninit, -) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns ``true`` if `this` is valid. -#[no_mangle] -pub extern "C" fn z_internal_ptr_in_segment_check(this_: &z_owned_ptr_in_segment_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Borrows data pointer in SHM Segment. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_ptr_in_segment_loan( - this: &z_owned_ptr_in_segment_t, -) -> &z_loaned_ptr_in_segment_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Deletes data pointer in SHM Segment. -#[no_mangle] -pub extern "C" fn z_ptr_in_segment_drop(this_: &mut z_moved_ptr_in_segment_t) { - let _ = this_.take_rust_type(); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Makes a shallow data pointer in SHM Segment copy. -#[no_mangle] -pub extern "C" fn z_ptr_in_segment_clone( - out: &mut MaybeUninit, - this_: &z_loaned_ptr_in_segment_t, -) { - let this = this_.as_rust_type_ref(); - let copy = this.to_owned(); - out.as_rust_type_mut_uninit().write(Some(copy)); -} diff --git a/src/shm/provider/mod.rs b/src/shm/provider/mod.rs deleted file mode 100644 index 866596735..000000000 --- a/src/shm/provider/mod.rs +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -pub mod alloc_layout; -pub(crate) mod alloc_layout_impl; -pub mod chunk; -pub mod shm_provider; -pub mod shm_provider_backend; -pub(crate) mod shm_provider_impl; -pub mod types; diff --git a/src/shm/provider/shm_provider.rs b/src/shm/provider/shm_provider.rs deleted file mode 100644 index f60f0451c..000000000 --- a/src/shm/provider/shm_provider.rs +++ /dev/null @@ -1,347 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use std::mem::MaybeUninit; - -use libc::c_void; -use zenoh::{ - shm::{ - BlockOn, Deallocate, Defragment, GarbageCollect, JustAlloc, ShmProvider, ShmProviderBuilder, - }, - Wait, -}; - -use super::{ - chunk::z_allocated_chunk_t, - shm_provider_backend::{zc_shm_provider_backend_callbacks_t, DynamicShmProviderBackend}, - shm_provider_impl::{alloc, alloc_async, available, defragment, garbage_collect, map}, - types::z_alloc_alignment_t, -}; -use crate::{ - context::{zc_context_t, zc_threadsafe_context_t, Context, ThreadsafeContext}, - result::{z_result_t, Z_EINVAL, Z_OK}, - shm::{ - protocol_implementations::posix::posix_shm_provider::PosixShmProvider, - provider::types::z_buf_layout_alloc_result_t, - }, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_loaned_shm_provider_t, z_moved_shm_provider_t, z_owned_shm_mut_t, z_owned_shm_provider_t, -}; - -pub type DynamicShmProvider = ShmProvider>; - -pub type DynamicShmProviderThreadsafe = ShmProvider>; - -pub enum CSHMProvider { - Posix(PosixShmProvider), - Dynamic(DynamicShmProvider), - DynamicThreadsafe(DynamicShmProviderThreadsafe), -} - -decl_c_type!( - owned(z_owned_shm_provider_t, option CSHMProvider), - loaned(z_loaned_shm_provider_t), -); - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Creates a new SHM Provider ith default backend. -#[no_mangle] -pub extern "C" fn z_shm_provider_default_new( - this: &mut MaybeUninit, - size: usize, -) -> z_result_t { - match ShmProviderBuilder::default_backend(size).wait() { - Ok(provider) => { - this.as_rust_type_mut_uninit() - .write(Some(CSHMProvider::Posix(provider))); - Z_OK - } - Err(e) => { - crate::report_error!("{:?}", e); - Z_EINVAL - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Creates a new SHM Provider. -#[no_mangle] -pub extern "C" fn z_shm_provider_new( - this: &mut MaybeUninit, - context: zc_context_t, - callbacks: zc_shm_provider_backend_callbacks_t, -) { - let backend = DynamicShmProviderBackend::new(context.into(), callbacks); - let provider = ShmProviderBuilder::backend(backend).wait(); - - this.as_rust_type_mut_uninit() - .write(Some(CSHMProvider::Dynamic(provider))); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Creates a new threadsafe SHM Provider. -#[no_mangle] -pub extern "C" fn z_shm_provider_threadsafe_new( - this: &mut MaybeUninit, - context: zc_threadsafe_context_t, - callbacks: zc_shm_provider_backend_callbacks_t, -) { - let backend = DynamicShmProviderBackend::new(context.into(), callbacks); - let provider = ShmProviderBuilder::backend(backend).wait(); - - this.as_rust_type_mut_uninit() - .write(Some(CSHMProvider::DynamicThreadsafe(provider))); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs SHM Provider in its gravestone value. -#[no_mangle] -pub extern "C" fn z_internal_shm_provider_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns ``true`` if `this` is valid. -#[no_mangle] -pub extern "C" fn z_internal_shm_provider_check(this_: &z_owned_shm_provider_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Borrows SHM Provider. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_shm_provider_loan( - this: &z_owned_shm_provider_t, -) -> &z_loaned_shm_provider_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Deletes SHM Provider. -#[no_mangle] -pub extern "C" fn z_shm_provider_drop(this_: &mut z_moved_shm_provider_t) { - let _ = this_.take_rust_type(); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make allocation without any additional actions. -#[no_mangle] -pub extern "C" fn z_shm_provider_alloc( - out_result: &mut MaybeUninit, - provider: &z_loaned_shm_provider_t, - size: usize, -) { - alloc::(out_result, provider, size, z_alloc_alignment_t { pow: 0 }) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make allocation performing garbage collection if needed. -#[no_mangle] -pub extern "C" fn z_shm_provider_alloc_gc( - out_result: &mut MaybeUninit, - provider: &z_loaned_shm_provider_t, - size: usize, -) { - alloc::(out_result, provider, size, z_alloc_alignment_t { pow: 0 }) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make allocation performing garbage collection and/or defragmentation if needed. -#[no_mangle] -pub extern "C" fn z_shm_provider_alloc_gc_defrag( - out_result: &mut MaybeUninit, - provider: &z_loaned_shm_provider_t, - size: usize, -) { - alloc::>(out_result, provider, size, z_alloc_alignment_t { pow: 0 }) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make allocation performing garbage collection and/or defragmentation and/or forced deallocation if needed. -#[no_mangle] -pub extern "C" fn z_shm_provider_alloc_gc_defrag_dealloc( - out_result: &mut MaybeUninit, - provider: &z_loaned_shm_provider_t, - size: usize, -) { - alloc::>>( - out_result, - provider, - size, - z_alloc_alignment_t { pow: 0 }, - ) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make allocation performing garbage collection and/or defragmentation and/or blocking if needed. -#[no_mangle] -pub extern "C" fn z_shm_provider_alloc_gc_defrag_blocking( - out_result: &mut MaybeUninit, - provider: &z_loaned_shm_provider_t, - size: usize, -) { - alloc::>>( - out_result, - provider, - size, - z_alloc_alignment_t { pow: 0 }, - ) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make allocation performing garbage collection and/or defragmentation in async manner. Will return Z_EINVAL -/// if used with non-threadsafe SHM Provider. -#[no_mangle] -pub extern "C" fn z_shm_provider_alloc_gc_defrag_async( - out_result: &'static mut MaybeUninit, - provider: &'static z_loaned_shm_provider_t, - size: usize, - result_context: zc_threadsafe_context_t, - result_callback: unsafe extern "C" fn( - *mut c_void, - &mut MaybeUninit, - ), -) -> z_result_t { - alloc_async::>>( - out_result, - provider, - size, - z_alloc_alignment_t { pow: 0 }, - result_context.into(), - result_callback, - ) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make aligned allocation without any additional actions. -#[no_mangle] -pub extern "C" fn z_shm_provider_alloc_aligned( - out_result: &mut MaybeUninit, - provider: &z_loaned_shm_provider_t, - size: usize, - alignment: z_alloc_alignment_t, -) { - alloc::(out_result, provider, size, alignment) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make aligned allocation performing garbage collection if needed. -#[no_mangle] -pub extern "C" fn z_shm_provider_alloc_gc_aligned( - out_result: &mut MaybeUninit, - provider: &z_loaned_shm_provider_t, - size: usize, - alignment: z_alloc_alignment_t, -) { - alloc::(out_result, provider, size, alignment) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make aligned allocation performing garbage collection and/or defragmentation if needed. -#[no_mangle] -pub extern "C" fn z_shm_provider_alloc_gc_defrag_aligned( - out_result: &mut MaybeUninit, - provider: &z_loaned_shm_provider_t, - size: usize, - alignment: z_alloc_alignment_t, -) { - alloc::>(out_result, provider, size, alignment) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make aligned allocation performing garbage collection and/or defragmentation and/or forced deallocation if needed. -#[no_mangle] -pub extern "C" fn z_shm_provider_alloc_gc_defrag_dealloc_aligned( - out_result: &mut MaybeUninit, - provider: &z_loaned_shm_provider_t, - size: usize, - alignment: z_alloc_alignment_t, -) { - alloc::>>(out_result, provider, size, alignment) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make aligned allocation performing garbage collection and/or defragmentation and/or blocking if needed. -#[no_mangle] -pub extern "C" fn z_shm_provider_alloc_gc_defrag_blocking_aligned( - out_result: &mut MaybeUninit, - provider: &z_loaned_shm_provider_t, - size: usize, - alignment: z_alloc_alignment_t, -) { - alloc::>>(out_result, provider, size, alignment) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Make aligned allocation performing garbage collection and/or defragmentation in async manner. Will return Z_EINVAL -/// if used with non-threadsafe SHM Provider. -#[no_mangle] -pub extern "C" fn z_shm_provider_alloc_gc_defrag_aligned_async( - out_result: &'static mut MaybeUninit, - provider: &'static z_loaned_shm_provider_t, - size: usize, - alignment: z_alloc_alignment_t, - result_context: zc_threadsafe_context_t, - result_callback: unsafe extern "C" fn( - *mut c_void, - &mut MaybeUninit, - ), -) -> z_result_t { - alloc_async::>>( - out_result, - provider, - size, - alignment, - result_context.into(), - result_callback, - ) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Perform memory defragmentation. The real operations taken depend on the provider's backend allocator -/// implementation. -#[no_mangle] -pub extern "C" fn z_shm_provider_defragment(provider: &z_loaned_shm_provider_t) -> usize { - defragment(provider) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Perform memory garbage collection and reclaim all dereferenced SHM buffers. -#[no_mangle] -pub extern "C" fn z_shm_provider_garbage_collect(provider: &z_loaned_shm_provider_t) -> usize { - garbage_collect(provider) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Return the memory size available in the provider. -#[no_mangle] -pub extern "C" fn z_shm_provider_available(provider: &z_loaned_shm_provider_t) -> usize { - available(provider) -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Map the preallocated data chunk into SHM buffer. -#[no_mangle] -pub extern "C" fn z_shm_provider_map( - out_result: &mut MaybeUninit, - provider: &z_loaned_shm_provider_t, - allocated_chunk: z_allocated_chunk_t, - len: usize, -) -> z_result_t { - map(out_result, provider, allocated_chunk, len) -} diff --git a/src/shm/provider/shm_provider_backend.rs b/src/shm/provider/shm_provider_backend.rs deleted file mode 100644 index b44d098e5..000000000 --- a/src/shm/provider/shm_provider_backend.rs +++ /dev/null @@ -1,113 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use std::fmt::Debug; - -use libc::c_void; -use zenoh::shm::{ - ChunkAllocResult, ChunkDescriptor, MemoryLayout, ProtocolID, ShmProviderBackend, - WithProtocolID, ZLayoutError, -}; - -use super::chunk::z_chunk_descriptor_t; -use crate::{ - context::DroppableContext, - shm::common::types::z_protocol_id_t, - transmute::{LoanedCTypeRef, OwnedCTypeRef, RustTypeRef}, - z_loaned_memory_layout_t, z_owned_chunk_alloc_result_t, z_owned_memory_layout_t, -}; - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Callbacks for ShmProviderBackend. -#[derive(Debug)] -#[repr(C)] -pub struct zc_shm_provider_backend_callbacks_t { - alloc_fn: unsafe extern "C" fn( - out_result: *mut z_owned_chunk_alloc_result_t, - layout: &z_loaned_memory_layout_t, - context: *mut c_void, - ), - free_fn: unsafe extern "C" fn(chunk: *const z_chunk_descriptor_t, context: *mut c_void), - defragment_fn: unsafe extern "C" fn(context: *mut c_void) -> usize, - available_fn: unsafe extern "C" fn(context: *mut c_void) -> usize, - layout_for_fn: unsafe extern "C" fn(layout: *mut z_owned_memory_layout_t, context: *mut c_void), - id_fn: unsafe extern "C" fn(context: *mut c_void) -> z_protocol_id_t, -} - -#[derive(Debug)] -pub struct DynamicShmProviderBackend -where - TContext: DroppableContext, -{ - context: TContext, - callbacks: zc_shm_provider_backend_callbacks_t, -} - -impl DynamicShmProviderBackend -where - TContext: DroppableContext, -{ - pub fn new(context: TContext, callbacks: zc_shm_provider_backend_callbacks_t) -> Self { - Self { context, callbacks } - } -} - -impl WithProtocolID for DynamicShmProviderBackend -where - TContext: DroppableContext, -{ - fn id(&self) -> ProtocolID { - unsafe { (self.callbacks.id_fn)(self.context.get()) } - } -} - -impl ShmProviderBackend for DynamicShmProviderBackend -where - TContext: DroppableContext, -{ - fn alloc(&self, layout: &MemoryLayout) -> ChunkAllocResult { - let mut result = std::mem::MaybeUninit::uninit(); - unsafe { - (self.callbacks.alloc_fn)( - result.as_mut_ptr(), - layout.as_loaned_c_type_ref(), - self.context.get(), - ); - match result.assume_init().as_rust_type_mut().take() { - Some(val) => val, - None => Err(zenoh::shm::ZAllocError::Other), - } - } - } - - fn free(&self, chunk: &ChunkDescriptor) { - unsafe { (self.callbacks.free_fn)(&chunk.into(), self.context.get()) }; - } - - fn defragment(&self) -> usize { - unsafe { (self.callbacks.defragment_fn)(self.context.get()) } - } - - fn available(&self) -> usize { - unsafe { (self.callbacks.available_fn)(self.context.get()) } - } - - fn layout_for(&self, layout: MemoryLayout) -> Result { - let mut layout = Some(layout); - unsafe { - (self.callbacks.layout_for_fn)(layout.as_owned_c_type_mut(), self.context.get()); - } - layout.ok_or(ZLayoutError::ProviderIncompatibleLayout) - } -} diff --git a/src/shm/provider/shm_provider_impl.rs b/src/shm/provider/shm_provider_impl.rs deleted file mode 100644 index 7e61f83e7..000000000 --- a/src/shm/provider/shm_provider_impl.rs +++ /dev/null @@ -1,194 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use std::mem::MaybeUninit; - -use libc::c_void; -use zenoh::{ - shm::{ - AllocPolicy, AsyncAllocPolicy, PosixShmProviderBackend, ShmProvider, ShmProviderBackend, - }, - Wait, -}; - -use super::{ - chunk::z_allocated_chunk_t, shm_provider_backend::DynamicShmProviderBackend, - types::z_alloc_alignment_t, -}; -use crate::{ - context::{Context, DroppableContext, ThreadsafeContext}, - result::{z_result_t, Z_EINVAL, Z_OK}, - shm::provider::types::z_buf_layout_alloc_result_t, - transmute::{IntoRustType, RustTypeRef, RustTypeRefUninit}, - z_loaned_shm_provider_t, z_owned_shm_mut_t, -}; - -pub(crate) fn alloc( - out_result: &mut MaybeUninit, - provider: &z_loaned_shm_provider_t, - size: usize, - alignment: z_alloc_alignment_t, -) { - match provider.as_rust_type_ref() { - super::shm_provider::CSHMProvider::Posix(provider) => { - alloc_impl::(out_result, provider, size, alignment) - } - super::shm_provider::CSHMProvider::Dynamic(provider) => { - alloc_impl::>( - out_result, provider, size, alignment, - ) - } - super::shm_provider::CSHMProvider::DynamicThreadsafe(provider) => { - alloc_impl::>( - out_result, provider, size, alignment, - ) - } - } -} - -pub(crate) fn alloc_async( - out_result: &'static mut MaybeUninit, - provider: &'static z_loaned_shm_provider_t, - size: usize, - alignment: z_alloc_alignment_t, - result_context: ThreadsafeContext, - result_callback: unsafe extern "C" fn( - *mut c_void, - &mut MaybeUninit, - ), -) -> z_result_t { - match provider.as_rust_type_ref() { - super::shm_provider::CSHMProvider::Posix(provider) => { - alloc_async_impl::( - out_result, - provider, - size, - alignment, - result_context, - result_callback, - ); - Z_OK - } - super::shm_provider::CSHMProvider::Dynamic(_) => Z_EINVAL, - super::shm_provider::CSHMProvider::DynamicThreadsafe(provider) => { - alloc_async_impl::>( - out_result, - provider, - size, - alignment, - result_context, - result_callback, - ); - Z_OK - } - } -} - -pub(crate) fn defragment(provider: &z_loaned_shm_provider_t) -> usize { - match provider.as_rust_type_ref() { - super::shm_provider::CSHMProvider::Posix(provider) => provider.defragment(), - super::shm_provider::CSHMProvider::Dynamic(provider) => provider.defragment(), - super::shm_provider::CSHMProvider::DynamicThreadsafe(provider) => provider.defragment(), - } -} - -pub(crate) fn garbage_collect(provider: &z_loaned_shm_provider_t) -> usize { - match provider.as_rust_type_ref() { - super::shm_provider::CSHMProvider::Posix(provider) => provider.garbage_collect(), - super::shm_provider::CSHMProvider::Dynamic(provider) => provider.garbage_collect(), - super::shm_provider::CSHMProvider::DynamicThreadsafe(provider) => { - provider.garbage_collect() - } - } -} - -pub(crate) fn available(provider: &z_loaned_shm_provider_t) -> usize { - match provider.as_rust_type_ref() { - super::shm_provider::CSHMProvider::Posix(provider) => provider.available(), - super::shm_provider::CSHMProvider::Dynamic(provider) => provider.available(), - super::shm_provider::CSHMProvider::DynamicThreadsafe(provider) => provider.available(), - } -} - -#[no_mangle] -pub(crate) fn map( - out_result: &mut MaybeUninit, - provider: &z_loaned_shm_provider_t, - allocated_chunk: z_allocated_chunk_t, - len: usize, -) -> z_result_t { - let chunk = match allocated_chunk.try_into() { - Ok(val) => val, - Err(_) => return Z_EINVAL, - }; - - let mapping = match provider.as_rust_type_ref() { - super::shm_provider::CSHMProvider::Posix(provider) => provider.map(chunk, len), - super::shm_provider::CSHMProvider::Dynamic(provider) => provider.map(chunk, len), - super::shm_provider::CSHMProvider::DynamicThreadsafe(provider) => provider.map(chunk, len), - }; - - match mapping { - Ok(buffer) => { - out_result.as_rust_type_mut_uninit().write(Some(buffer)); - Z_OK - } - Err(e) => { - crate::report_error!("{:?}", e); - Z_EINVAL - } - } -} - -fn alloc_impl( - out_result: &mut MaybeUninit, - provider: &ShmProvider, - size: usize, - alignment: z_alloc_alignment_t, -) { - let result = provider - .alloc(size) - .with_alignment(alignment.into_rust_type()) - .with_policy::() - .wait(); - - out_result.write(result.into()); -} - -pub(crate) fn alloc_async_impl< - Policy: AsyncAllocPolicy, - TBackend: ShmProviderBackend + Send + Sync, ->( - out_result: &'static mut MaybeUninit, - provider: &'static ShmProvider, - size: usize, - alignment: z_alloc_alignment_t, - result_context: ThreadsafeContext, - result_callback: unsafe extern "C" fn( - *mut c_void, - &mut MaybeUninit, - ), -) { - zenoh_runtime::ZRuntime::Application.spawn(async move { - let result = provider - .alloc(size) - .with_alignment(alignment.into_rust_type()) - .with_policy::() - .await; - out_result.write(result.into()); - unsafe { - (result_callback)(result_context.get(), out_result); - } - }); -} diff --git a/src/shm/provider/types.rs b/src/shm/provider/types.rs deleted file mode 100644 index e0cb1d048..000000000 --- a/src/shm/provider/types.rs +++ /dev/null @@ -1,355 +0,0 @@ -// -// Copyright (c) 2023 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use std::mem::MaybeUninit; - -use zenoh::shm::{ - AllocAlignment, BufAllocResult, BufLayoutAllocResult, ChunkAllocResult, MemoryLayout, - ZAllocError, ZLayoutError, -}; - -use super::chunk::z_allocated_chunk_t; -use crate::{ - result::{z_result_t, Z_EINVAL, Z_OK}, - shm::buffer::zshmmut::z_internal_shm_mut_null, - transmute::{IntoCType, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_loaned_memory_layout_t, z_moved_chunk_alloc_result_t, z_moved_memory_layout_t, - z_owned_chunk_alloc_result_t, z_owned_memory_layout_t, z_owned_shm_mut_t, -}; - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Allocation errors -#[repr(C)] -#[derive(Clone, Copy)] -pub enum z_alloc_error_t { - /// Defragmentation needed. - NEED_DEFRAGMENT, - /// The provider is out of memory. - OUT_OF_MEMORY, - /// Other error. - OTHER, -} - -impl From for z_alloc_error_t { - #[inline] - fn from(value: ZAllocError) -> Self { - match value { - ZAllocError::NeedDefragment => z_alloc_error_t::NEED_DEFRAGMENT, - ZAllocError::OutOfMemory => z_alloc_error_t::OUT_OF_MEMORY, - ZAllocError::Other => z_alloc_error_t::OTHER, - } - } -} - -impl From for ZAllocError { - #[inline] - fn from(value: z_alloc_error_t) -> Self { - match value { - z_alloc_error_t::NEED_DEFRAGMENT => ZAllocError::NeedDefragment, - z_alloc_error_t::OUT_OF_MEMORY => ZAllocError::OutOfMemory, - z_alloc_error_t::OTHER => ZAllocError::Other, - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Layouting errors -#[repr(C)] -#[derive(Clone, Copy)] -pub enum z_layout_error_t { - /// Layout arguments are incorrect. - INCORRECT_LAYOUT_ARGS, - /// Layout incompatible with provider. - PROVIDER_INCOMPATIBLE_LAYOUT, -} - -impl From for z_layout_error_t { - #[inline] - fn from(value: ZLayoutError) -> Self { - match value { - ZLayoutError::IncorrectLayoutArgs => z_layout_error_t::INCORRECT_LAYOUT_ARGS, - ZLayoutError::ProviderIncompatibleLayout => { - z_layout_error_t::PROVIDER_INCOMPATIBLE_LAYOUT - } - } - } -} - -impl From for ZLayoutError { - #[inline] - fn from(value: z_layout_error_t) -> Self { - match value { - z_layout_error_t::INCORRECT_LAYOUT_ARGS => ZLayoutError::IncorrectLayoutArgs, - z_layout_error_t::PROVIDER_INCOMPATIBLE_LAYOUT => { - ZLayoutError::ProviderIncompatibleLayout - } - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief An AllocAlignment. -#[repr(C)] -#[derive(Clone, Copy)] -pub struct z_alloc_alignment_t { - pub pow: u8, -} - -decl_c_type!(copy(z_alloc_alignment_t, AllocAlignment),); - -decl_c_type_inequal!( - owned(z_owned_memory_layout_t, option MemoryLayout), - loaned(z_loaned_memory_layout_t), -); - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Creates a new Memory Layout. -#[no_mangle] -pub extern "C" fn z_memory_layout_new( - this: &mut MaybeUninit, - size: usize, - alignment: z_alloc_alignment_t, -) -> z_result_t { - fn create_memory_layout( - size: usize, - alignment: z_alloc_alignment_t, - ) -> Result { - let alignment = AllocAlignment::new(alignment.pow)?; - MemoryLayout::new(size, alignment) - } - - match create_memory_layout(size, alignment) { - Ok(layout) => { - this.as_rust_type_mut_uninit().write(Some(layout)); - Z_OK - } - Err(e) => { - crate::report_error!("{:?}", e); - Z_EINVAL - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs Memory Layout in its gravestone value. -#[no_mangle] -pub extern "C" fn z_internal_memory_layout_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns ``true`` if `this` is valid. -#[no_mangle] -pub extern "C" fn z_internal_memory_layout_check(this_: &z_owned_memory_layout_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Borrows Memory Layout. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_memory_layout_loan( - this: &z_owned_memory_layout_t, -) -> &z_loaned_memory_layout_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Deletes Memory Layout. -#[no_mangle] -pub extern "C" fn z_memory_layout_drop(this_: &mut z_moved_memory_layout_t) { - let _ = this_.take_rust_type(); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Extract data from Memory Layout. -#[no_mangle] -pub extern "C" fn z_memory_layout_get_data( - this: &z_loaned_memory_layout_t, - out_size: &mut MaybeUninit, - out_alignment: &mut MaybeUninit, -) { - let layout = this.as_rust_type_ref(); - out_size.write(layout.size().into()); - out_alignment.write(layout.alignment().into_c_type()); -} - -decl_c_type!( - owned(z_owned_chunk_alloc_result_t, option ChunkAllocResult), -); - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Creates a new Chunk Alloc Result with Ok value. -#[no_mangle] -pub extern "C" fn z_chunk_alloc_result_new_ok( - this: &mut MaybeUninit, - allocated_chunk: z_allocated_chunk_t, -) -> z_result_t { - match allocated_chunk.try_into() { - Ok(chunk) => { - this.as_rust_type_mut_uninit().write(Some(Ok(chunk))); - Z_OK - } - Err(_) => Z_EINVAL, - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Creates a new Chunk Alloc Result with Error value. -#[no_mangle] -pub extern "C" fn z_chunk_alloc_result_new_error( - this: &mut MaybeUninit, - alloc_error: z_alloc_error_t, -) { - this.as_rust_type_mut_uninit() - .write(Some(Err(alloc_error.into()))); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Constructs Chunk Alloc Result in its gravestone value. -#[no_mangle] -pub extern "C" fn z_internal_chunk_alloc_result_null( - this_: &mut MaybeUninit, -) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @return ``true`` if `this` is valid. -#[no_mangle] -pub extern "C" fn z_internal_chunk_alloc_result_check( - this_: &z_owned_chunk_alloc_result_t, -) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Deletes Chunk Alloc Result. -#[no_mangle] -pub extern "C" fn z_chunk_alloc_result_drop(this_: &mut z_moved_chunk_alloc_result_t) { - let _ = this_.take_rust_type(); -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Status of SHM buffer allocation operation. -#[repr(C)] -#[derive(Clone, Copy, Debug)] -pub enum zc_buf_alloc_status_t { - /// Allocation ok - OK = 0, - /// Allocation error - ALLOC_ERROR = 1, -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A result of SHM buffer allocation operation. -#[repr(C)] -pub struct z_buf_alloc_result_t { - status: zc_buf_alloc_status_t, - buf: z_owned_shm_mut_t, - error: z_alloc_error_t, -} - -impl From for z_buf_alloc_result_t { - fn from(value: BufAllocResult) -> Self { - let mut buf: MaybeUninit = MaybeUninit::uninit(); - match value { - Ok(val) => { - buf.as_rust_type_mut_uninit().write(Some(val)); - Self { - status: zc_buf_alloc_status_t::OK, - // SAFETY: this is safe because buf is gravestone-initialized above - buf: unsafe { buf.assume_init() }, - error: z_alloc_error_t::OTHER, - } - } - Err(error) => { - z_internal_shm_mut_null(&mut buf); - Self { - status: zc_buf_alloc_status_t::ALLOC_ERROR, - // SAFETY: this is safe because buf is gravestone-initialized above - buf: unsafe { buf.assume_init() }, - error: error.into(), - } - } - } - } -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Status of SHM buffer layouting + allocation operation. -#[repr(C)] -#[derive(Clone, Copy, Debug)] -pub enum zc_buf_layout_alloc_status_t { - /// Allocation ok - OK = 0, - /// Allocation error - ALLOC_ERROR = 1, - /// Layouting error - LAYOUT_ERROR = 2, -} - -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief A result of SHM buffer layouting + allocation operation. -#[repr(C)] -pub struct z_buf_layout_alloc_result_t { - status: zc_buf_layout_alloc_status_t, - buf: z_owned_shm_mut_t, - alloc_error: z_alloc_error_t, - layout_error: z_layout_error_t, -} - -impl From for z_buf_layout_alloc_result_t { - fn from(value: BufLayoutAllocResult) -> Self { - let mut buf: MaybeUninit = MaybeUninit::uninit(); - match value { - Ok(val) => { - buf.as_rust_type_mut_uninit().write(Some(val)); - Self { - status: zc_buf_layout_alloc_status_t::OK, - // SAFETY: this is safe because buf is initialized above - buf: unsafe { buf.assume_init() }, - alloc_error: z_alloc_error_t::OTHER, - layout_error: z_layout_error_t::PROVIDER_INCOMPATIBLE_LAYOUT, - } - } - Err(error) => { - z_internal_shm_mut_null(&mut buf); - match error { - zenoh::shm::ZLayoutAllocError::Alloc(alloc) => { - Self { - status: zc_buf_layout_alloc_status_t::ALLOC_ERROR, - // SAFETY: this is safe because buf is gravestone-initialized above - buf: unsafe { buf.assume_init() }, - alloc_error: alloc.into(), - layout_error: z_layout_error_t::PROVIDER_INCOMPATIBLE_LAYOUT, - } - } - zenoh::shm::ZLayoutAllocError::Layout(layout) => { - Self { - status: zc_buf_layout_alloc_status_t::LAYOUT_ERROR, - // SAFETY: this is safe because buf is gravestone-initialized above - buf: unsafe { buf.assume_init() }, - alloc_error: z_alloc_error_t::OTHER, - layout_error: layout.into(), - } - } - } - } - } - } -} diff --git a/src/subscriber.rs b/src/subscriber.rs deleted file mode 100644 index 173f3f016..000000000 --- a/src/subscriber.rs +++ /dev/null @@ -1,208 +0,0 @@ -// -// Copyright (c) 2017, 2022 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::mem::MaybeUninit; - -use zenoh::{ - handlers::Callback, - pubsub::{Subscriber, SubscriberBuilder}, - sample::Sample, - Wait, -}; - -pub use crate::opaque_types::{z_loaned_subscriber_t, z_moved_subscriber_t, z_owned_subscriber_t}; -use crate::{ - keyexpr::*, - result, - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_closure_sample_call, z_closure_sample_loan, z_loaned_session_t, z_moved_closure_sample_t, - zc_locality_default, zc_locality_t, -}; -#[cfg(feature = "unstable")] -use crate::{transmute::IntoCType, z_entity_global_id_t}; - -decl_c_type!( - owned(z_owned_subscriber_t, option Subscriber<()>), - loaned(z_loaned_subscriber_t), -); - -/// Constructs a subscriber in a gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_subscriber_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// Borrows subscriber. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_subscriber_loan(this_: &z_owned_subscriber_t) -> &z_loaned_subscriber_t { - this_ - .as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// Options passed to the `z_declare_subscriber()` function. -#[allow(non_camel_case_types)] -#[repr(C)] -pub struct z_subscriber_options_t { - /// Restricts the matching publications that will be received by this Subscriber to the ones - /// that have the compatible allowed_destination. - pub allowed_origin: zc_locality_t, -} - -impl Default for z_subscriber_options_t { - fn default() -> Self { - Self { - allowed_origin: zc_locality_default(), - } - } -} - -/// Constructs the default value for `z_subscriber_options_t`. -#[no_mangle] -pub extern "C" fn z_subscriber_options_default(this_: &mut MaybeUninit) { - this_.write(z_subscriber_options_t::default()); -} - -#[allow(unused_variables, unused_mut)] -pub(crate) fn _declare_subscriber_inner<'a, 'b>( - session: &'a z_loaned_session_t, - key_expr: &'b z_loaned_keyexpr_t, - callback: &mut z_moved_closure_sample_t, - options: Option<&mut z_subscriber_options_t>, -) -> SubscriberBuilder<'a, 'b, Callback> { - let session = session.as_rust_type_ref(); - let key_expr = key_expr.as_rust_type_ref(); - let callback = callback.take_rust_type(); - let mut subscriber = session - .declare_subscriber(key_expr) - .callback(move |sample| { - let mut owned_sample = Some(sample); - z_closure_sample_call(z_closure_sample_loan(&callback), unsafe { - owned_sample - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() - }) - }); - if let Some(options) = options { - subscriber = subscriber.allowed_origin(options.allowed_origin.into()); - } - subscriber -} - -/// Constructs and declares a subscriber for a given key expression. Dropping subscriber undeclares its callback. -/// -/// @param session: The zenoh session. -/// @param subscriber: An uninitialized location in memory, where subscriber will be constructed. -/// @param key_expr: The key expression to subscribe. -/// @param callback: The callback function that will be called each time a data matching the subscribed expression is received. -/// @param options: The options to be passed to the subscriber declaration. -/// -/// @return 0 in case of success, negative error code otherwise (in this case subscriber will be in its gravestone state). -#[no_mangle] -pub extern "C" fn z_declare_subscriber( - session: &z_loaned_session_t, - subscriber: &mut MaybeUninit, - key_expr: &z_loaned_keyexpr_t, - callback: &mut z_moved_closure_sample_t, - options: Option<&mut z_subscriber_options_t>, -) -> result::z_result_t { - let this = subscriber.as_rust_type_mut_uninit(); - let s = _declare_subscriber_inner(session, key_expr, callback, options); - match s.wait() { - Ok(sub) => { - this.write(Some(sub)); - result::Z_OK - } - Err(e) => { - crate::report_error!("{}", e); - this.write(None); - result::Z_EGENERIC - } - } -} - -/// Constructs and declares a background subscriber. Subscriber callback will be called to process the messages, -/// until the corresponding session is closed or dropped. -/// -/// @param session: The zenoh session. -/// @param key_expr: The key expression to subscribe. -/// @param callback: The callback function that will be called each time a data matching the subscribed expression is received. -/// @param options: The options to be passed to the subscriber declaration. -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn z_declare_background_subscriber( - session: &z_loaned_session_t, - key_expr: &z_loaned_keyexpr_t, - callback: &mut z_moved_closure_sample_t, - options: Option<&mut z_subscriber_options_t>, -) -> result::z_result_t { - let subscriber = _declare_subscriber_inner(session, key_expr, callback, options); - match subscriber.background().wait() { - Ok(_) => result::Z_OK, - Err(e) => { - crate::report_error!("{}", e); - result::Z_EGENERIC - } - } -} - -/// Returns the key expression of the subscriber. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_subscriber_keyexpr(subscriber: &z_loaned_subscriber_t) -> &z_loaned_keyexpr_t { - subscriber - .as_rust_type_ref() - .key_expr() - .as_loaned_c_type_ref() -} - -/// Undeclares subscriber callback and resets it to its gravestone state. -/// This is equivalent to calling `z_undeclare_subscriber()` and discarding its return value. -#[no_mangle] -pub extern "C" fn z_subscriber_drop(this_: &mut z_moved_subscriber_t) { - std::mem::drop(this_.take_rust_type()) -} - -/// Returns ``true`` if subscriber is valid, ``false`` otherwise. -#[no_mangle] -pub extern "C" fn z_internal_subscriber_check(this_: &z_owned_subscriber_t) -> bool { - this_.as_rust_type_ref().is_some() -} - -/// Undeclares the subscriber. -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn z_undeclare_subscriber(this_: &mut z_moved_subscriber_t) -> result::z_result_t { - if let Some(s) = this_.take_rust_type() { - if let Err(e) = s.undeclare().wait() { - crate::report_error!("{}", e); - return result::Z_EGENERIC; - } - } - result::Z_OK -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Returns the ID of the subscriber. -#[no_mangle] -pub extern "C" fn z_subscriber_id(subscriber: &z_loaned_subscriber_t) -> z_entity_global_id_t { - subscriber.as_rust_type_ref().id().into_c_type() -} diff --git a/src/transmute.rs b/src/transmute.rs deleted file mode 100644 index 65b0d0f32..000000000 --- a/src/transmute.rs +++ /dev/null @@ -1,539 +0,0 @@ -// -// Copyright (c) 2017, 2024 ZettaScale Technology. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh team, -// - -use std::mem::MaybeUninit; - -// -// The `Gravestone` trait is used to create valid instance of an object -// which is safe to be forgotten without calling drop() method on it. -// -// The result of this metod is placed to zenoh-c object representation -// after dropping the original object. -// -pub(crate) trait Gravestone { - // Create a gravestone object: an object which is safe to be forgotten - // without calling drop() method on it. - fn gravestone() -> Self; - // Check if the object is in a gravestone state - fn is_gravestone(&self) -> bool; -} - -impl Gravestone for Option { - fn gravestone() -> Self { - None - } - fn is_gravestone(&self) -> bool { - self.is_none() - } -} - -#[allow(dead_code)] -pub(crate) trait CTypeRef: Sized { - type CType; - fn as_ctype_ref(&self) -> &Self::CType; - fn as_ctype_mut(&mut self) -> &mut Self::CType; -} -#[allow(dead_code)] -pub(crate) trait OwnedCTypeRef: Sized { - type OwnedCType; - fn as_owned_c_type_ref(&self) -> &Self::OwnedCType; - fn as_owned_c_type_mut(&mut self) -> &mut Self::OwnedCType; -} -#[allow(dead_code)] -pub(crate) trait LoanedCTypeRef: Sized { - type LoanedCType; - fn as_loaned_c_type_ref(&self) -> &Self::LoanedCType; - fn as_loaned_c_type_mut(&mut self) -> &mut Self::LoanedCType; -} -#[allow(dead_code)] -pub(crate) trait ViewCTypeRef: Sized { - type ViewCType; - fn as_view_c_type_ref(&self) -> &Self::ViewCType; - fn as_view_c_type_mut(&mut self) -> &mut Self::ViewCType; -} -#[allow(dead_code)] -pub(crate) trait RustTypeRef: Sized { - type RustType; - fn as_rust_type_ref(&self) -> &Self::RustType; - fn as_rust_type_mut(&mut self) -> &mut Self::RustType; -} -#[allow(dead_code)] -pub(crate) trait RustTypeRefUninit: Sized { - type RustType; - fn as_rust_type_mut_uninit(&mut self) -> &mut MaybeUninit; -} -#[allow(dead_code)] -pub(crate) trait IntoRustType: Sized { - type RustType; - fn into_rust_type(self) -> Self::RustType; -} -#[allow(dead_code)] -pub(crate) trait IntoCType: Sized { - type CType; - fn into_c_type(self) -> Self::CType; -} -#[allow(dead_code)] -pub(crate) trait TakeRustType: Sized { - type RustType; - fn take_rust_type(&mut self) -> Self::RustType; -} -#[allow(dead_code)] -pub(crate) trait TakeCType: Sized { - type CType; - fn take_c_type(&mut self) -> Self::CType; -} - -impl TakeRustType for P -where - P: TakeCType, - Q: IntoRustType, -{ - type RustType = Q::RustType; - fn take_rust_type(&mut self) -> Self::RustType { - self.take_c_type().into_rust_type() - } -} - -macro_rules! validate_equivalence { - ($type_a:ty, $type_b:ty) => { - const _: () = { - use const_format::concatcp; - const TYPE_NAME_A: &str = stringify!($type_a); - const TYPE_NAME_B: &str = stringify!($type_b); - const ALIGN_A: usize = std::mem::align_of::<$type_a>(); - const ALIGN_B: usize = std::mem::align_of::<$type_b>(); - if ALIGN_A != ALIGN_B { - const ERR_MESSAGE: &str = concatcp!( - "Alingment mismatch: type ", - TYPE_NAME_A, - " has alignment ", - ALIGN_A, - " while type ", - TYPE_NAME_B, - " has alignment ", - ALIGN_B - ); - panic!("{}", ERR_MESSAGE); - } - const SIZE_A: usize = std::mem::size_of::<$type_a>(); - const SIZE_B: usize = std::mem::size_of::<$type_b>(); - if SIZE_A != SIZE_B { - const ERR_MESSAGE: &str = concatcp!( - "Size mismatch: type ", - TYPE_NAME_A, - " has size ", - SIZE_A, - " while type ", - TYPE_NAME_B, - " has size ", - SIZE_B - ); - panic!("{}", ERR_MESSAGE); - } - }; - }; -} - -#[macro_export] -macro_rules! impl_transmute { - (as_c ($rust_type:ty, $c_type:ty)) => { - impl $crate::transmute::CTypeRef for $rust_type { - type CType = $c_type; - fn as_ctype_ref(&self) -> &Self::CType { - unsafe { &*(self as *const Self as *const Self::CType) } - } - fn as_ctype_mut(&mut self) -> &mut Self::CType { - unsafe { &mut *(self as *mut Self as *mut Self::CType) } - } - } - }; - (as_c_owned ($rust_type:ty, $c_type:ty)) => { - impl $crate::transmute::OwnedCTypeRef for $rust_type { - type OwnedCType = $c_type; - fn as_owned_c_type_ref(&self) -> &Self::OwnedCType { - unsafe { &*(self as *const Self as *const Self::OwnedCType) } - } - fn as_owned_c_type_mut(&mut self) -> &mut Self::OwnedCType { - unsafe { &mut *(self as *mut Self as *mut Self::OwnedCType) } - } - } - }; - - (as_c_loaned ($rust_type:ty, $c_type:ty)) => { - impl $crate::transmute::LoanedCTypeRef for $rust_type { - type LoanedCType = $c_type; - fn as_loaned_c_type_ref(&self) -> &Self::LoanedCType { - unsafe { &*(self as *const Self as *const Self::LoanedCType) } - } - fn as_loaned_c_type_mut(&mut self) -> &mut Self::LoanedCType { - unsafe { &mut *(self as *mut Self as *mut Self::LoanedCType) } - } - } - }; - (as_c_view ($rust_type:ty, $c_type:ty)) => { - impl $crate::transmute::ViewCTypeRef for $rust_type { - type ViewCType = $c_type; - fn as_view_c_type_ref(&self) -> &Self::ViewCType { - unsafe { &*(self as *const Self as *const Self::ViewCType) } - } - fn as_view_c_type_mut(&mut self) -> &mut Self::ViewCType { - unsafe { &mut *(self as *mut Self as *mut Self::ViewCType) } - } - } - }; - (as_rust ($c_type:ty, $rust_type:ty)) => { - impl $crate::transmute::RustTypeRef for $c_type { - type RustType = $rust_type; - fn as_rust_type_ref(&self) -> &Self::RustType { - unsafe { &*(self as *const Self as *const Self::RustType) } - } - fn as_rust_type_mut(&mut self) -> &mut Self::RustType { - unsafe { &mut *(self as *mut Self as *mut Self::RustType) } - } - } - impl $crate::transmute::RustTypeRefUninit for std::mem::MaybeUninit<$c_type> { - type RustType = $rust_type; - fn as_rust_type_mut_uninit(&mut self) -> &mut std::mem::MaybeUninit { - unsafe { - let this = self as *mut std::mem::MaybeUninit<$c_type>; - &mut *(this as *mut std::mem::MaybeUninit) - } - } - } - }; - (into_rust ($c_type:ty, $rust_type:ty)) => { - impl $crate::transmute::IntoRustType for $c_type { - type RustType = $rust_type; - fn into_rust_type(self) -> Self::RustType { - unsafe { std::mem::transmute::<$c_type, $rust_type>(self) } - } - } - }; - (into_rust (itself $rust_type:ty)) => { - impl $crate::transmute::IntoRustType for $rust_type { - type RustType = $rust_type; - fn into_rust_type(self) -> Self::RustType { - self - } - } - }; - (take_rust ($c_type:ty, $rust_type:ty)) => { - impl $crate::transmute::Gravestone for $c_type { - fn gravestone() -> Self { - unsafe { std::mem::transmute::<$rust_type, $c_type>(<$rust_type>::gravestone()) } - } - fn is_gravestone(&self) -> bool { - self.as_rust_type_ref().is_gravestone() - } - } - }; - (into_c ($rust_type:ty, $c_type:ty)) => { - impl $crate::transmute::IntoCType for $rust_type { - type CType = $c_type; - fn into_c_type(self) -> Self::CType { - unsafe { std::mem::transmute::<$rust_type, $c_type>(self) } - } - } - }; -} - -macro_rules! impl_owned { - (owned $c_owned_type:ty, inner rust option $rust_inner_type:ty) => { - impl_transmute!(as_c_owned(Option<$rust_inner_type>, $c_owned_type)); - impl_transmute!(as_rust($c_owned_type, Option<$rust_inner_type>)); - impl_transmute!(into_rust($c_owned_type, Option<$rust_inner_type>)); - impl_transmute!(into_c(Option<$rust_inner_type>, $c_owned_type)); - impl_transmute!(take_rust($c_owned_type, Option<$rust_inner_type>)); - }; - (owned $c_owned_type:ty, inner rust option $rust_inner_type:ty) => { - impl_transmute!(as_c_owned(Option<$rust_inner_type>, $c_owned_type)); - impl_transmute!(as_rust($c_owned_type, Option<$rust_inner_type>)); - impl_transmute!(into_rust($c_owned_type, Option<$rust_inner_type>)); - impl_transmute!(take_rust($c_owned_type, Option<$rust_inner_type>)); - }; - (owned $c_owned_type:ty, inner rust $rust_owned_type:ty) => { - impl_transmute!(as_c_owned($rust_owned_type, $c_owned_type)); - impl_transmute!(as_rust($c_owned_type, $rust_owned_type)); - impl_transmute!(into_rust($c_owned_type, $rust_owned_type)); - impl_transmute!(take_rust($c_owned_type, $rust_owned_type)); - }; - (owned rust $c_owned_type:ty, loaned $c_loaned_type:ty) => { - impl_transmute!(as_c_owned($c_loaned_type, $c_owned_type)); - impl_transmute!(as_c_loaned($c_owned_type, $c_loaned_type)); - impl_transmute!(into_rust(itself $c_owned_type)); - }; -} - -// There are several possible variants how owned/loaned types are implememnted -// Here is the relation between them: -// -// - "Owned" type is a type with "empty" state. -// - It's guaranteed that in the "empty" state object doesn't hold any external resources (memory, socket, file, etc) and can be safely forgotten without explicit destruction. -// - The "empty" state itself may be valid or not valid state of an object. E.g. it can be "None" value of an Option type or just default value of a struct. -// - The "empty" statis a always a "default()" value of an owned type. -// -// - "Inner" type is a type which is contained in the "Owned" type and whcih is necessarily valid. E.g. if the owned type is Option then inner type is T. -// If the owned type is just T with default value then inner type is T itself. It's ususally the same as "Loaned" type but not always -// -// - "Loaned: type is a type which is used to access the owned type. Usually it's the same as wrapped type, but sometimes (e.g. for type `ZShm`) it's an wrapper type over -// the inside type of loaned type. E.g. owned type is `Option`, inner type is then `Zshm``, but loaned type is `zshm` -// (which is just wrapper over `ZShm`` restricting write access) -// -// - "Moved" type - repr "C" structure which wraps the owned type. It's used to explictly transfer ownership in C code. -// When pointer to moved type is passed to C code, the only way to access the wrapped owned type -// is to call "take_rust_type()" or "take_c_type()" methods which empties the passed owned type, -// leaving rust code responsible to drop it. -// Note: C functions purposedly accepts **pointer** to moved type, not the moved type itself. -// Passing moved type by value could be better from Rust point of view, but provokes error on C side. -// -// - "View" type - the type which holds references to external data but doesn't own it. Therefore it's always safe to copy/forget it without explicit destructor. -// The view type correspods to owned type. E.g. there may be "onwned string" and "view string". View type can be converted to loaned type, same as loaned type of -// corresponding owned type. This allows to accept either owned data or external data in the same function. -// -// Typically all these types are the same size and alignment and can be converted to each other just with `reinterpret_cast` in C++. -// But this is necessary for C++ only, if type is not used by C++ binding, this restriction can be relaxed. -// - -// These macros declares conversions between Rust and C types. -// Typically the "owned" and "loaned" types have the same size and alignment. -// This is necessary for C++ wrapper library to work correctly. -// But for some types which are not covered by C++ this restriction can be relaxed. -// In this case the "inequal" variant should be used. - -#[macro_export] -macro_rules! decl_c_type_inequal { - // - // Owned with with explicit rust loaned type - rarely used - // - (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?), - loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?) - $(,)?) => { - decl_c_type!( - owned($c_owned_type, option $rust_inner_type), - ); - validate_equivalence!($c_loaned_type, $rust_loaned_type); - impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); - impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); - }; - (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), - loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?) - $(,)?) => { - decl_c_type!( - owned($c_owned_type, $rust_owned_type), - ); - validate_equivalence!($c_loaned_type, $rust_loaned_type); - impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); - impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); - }; - - // - // Owned with loaned type same as inner type - typical case - // - (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?), - loaned ($c_loaned_type:ty $(,)?) - $(,)?) => { - decl_c_type_inequal!( - owned($c_owned_type, option $rust_inner_type), - loaned($c_loaned_type, $rust_inner_type), - ); - }; - (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), - loaned ($c_loaned_type:ty $(,)?) - $(,)?) => { - decl_c_type_inequal!( - owned($c_owned_type, $rust_owned_type), - loaned($c_loaned_type, $rust_owned_type), - ); - }; - // - // With view type - // - (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?), - loaned ($c_loaned_type:ty $(,)?), - view ($c_view_type:ty, $rust_view_type:ty $(,)?) - $(,)?) => { - decl_c_type_inequal!( - owned($c_owned_type, option $rust_inner_type), - loaned($c_loaned_type), - ); - validate_equivalence!($c_view_type, $rust_view_type); - impl_transmute!(as_c_view($rust_view_type, $c_view_type)); - impl_transmute!(as_rust($c_view_type, $rust_view_type)); - }; - (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), - loaned ($c_loaned_type:ty $(,)?), - view ($c_view_type:ty, $rust_view_type:ty $(,)?) - $(,)?) => { - decl_c_type_inequal!( - owned($c_owned_type, $rust_owned_type), - loaned($c_loaned_type), - ); - validate_equivalence!($c_view_type, $rust_view_type); - impl_transmute!(as_c_view($rust_view_type, $c_view_type)); - impl_transmute!(as_rust($c_view_type, $rust_view_type)); - }; - (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), - loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?), - view ($c_view_type:ty, $rust_view_type:ty $(,)?) - $(,)?) => { - decl_c_type_inequal!( - owned($c_owned_type, $rust_owned_type), - loaned($c_loaned_type, $rust_loaned_type), - ); - validate_equivalence!($c_view_type, $rust_view_type); - impl_transmute!(as_c_view($rust_view_type, $c_view_type)); - impl_transmute!(as_rust($c_view_type, $rust_view_type)); - }; -} - -#[macro_export] -macro_rules! decl_c_type { - // - // Owned type only - // - (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?) - $(,)?) => { - validate_equivalence!($c_owned_type, Option<$rust_inner_type>); - impl_owned!(owned $c_owned_type, inner rust option $rust_inner_type); - }; - (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?) - $(,)?) => { - validate_equivalence!($c_owned_type, Option<$rust_inner_type>); - impl_owned!(owned $c_owned_type, inner rust option $rust_inner_type); - }; - - (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?) - $(,)?) => { - validate_equivalence!($c_owned_type, $rust_owned_type); - impl_owned!(owned $c_owned_type, inner rust $rust_owned_type); - }; - // - // Owned with with explicit rust loaned type - rarely used - // - (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?), - loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?) - $(,)?) => { - decl_c_type_inequal!( - owned($c_owned_type, option $rust_inner_type), - loaned($c_loaned_type, $rust_loaned_type), - ); - validate_equivalence!($c_loaned_type, $c_owned_type); - }; - (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), - loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?) - $(,)?) => { - decl_c_type_inequal!( - owned($c_owned_type, $rust_owned_type), - loaned($c_loaned_type, $rust_loaned_type), - ); - validate_equivalence!($c_loaned_type, $c_owned_type); - }; - // - // Owned with loaned type same as inner type - typical case - // - (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?), - loaned ($c_loaned_type:ty $(,)?) - $(,)?) => { - decl_c_type!( - owned($c_owned_type, option $rust_inner_type), - loaned($c_loaned_type, $rust_inner_type), - ); - }; - (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), - loaned ($c_loaned_type:ty $(,)?) - $(,)?) => { - decl_c_type!( - owned($c_owned_type, $rust_owned_type), - loaned($c_loaned_type, $rust_owned_type), - ); - }; - // - // With view type - // - (owned ($c_owned_type:ty, option $rust_inner_type:ty $(,)?), - loaned ($c_loaned_type:ty $(,)?), - view ($c_view_type:ty, $rust_view_type:ty $(,)?) - $(,)?) => { - decl_c_type_inequal!( - owned($c_owned_type, option $rust_inner_type), - loaned($c_loaned_type), - view($c_view_type, $rust_view_type), - ); - validate_equivalence!($c_owned_type, $c_loaned_type); - validate_equivalence!($c_view_type, $c_loaned_type); - }; - (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), - loaned ($c_loaned_type:ty $(,)?), - view ($c_view_type:ty, $rust_view_type:ty $(,)?) - $(,)?) => { - decl_c_type_inequal!( - owned($c_owned_type, $rust_owned_type), - loaned($c_loaned_type, $rust_owned_type), - view($c_view_type, $rust_view_type), - ); - validate_equivalence!($c_owned_type, $c_loaned_type); - validate_equivalence!($c_view_type, $c_loaned_type); - }; - (owned ($c_owned_type:ty, $rust_owned_type:ty $(,)?), - loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?), - view ($c_view_type:ty, $rust_view_type:ty $(,)?) - $(,)?) => { - decl_c_type_inequal!( - owned($c_owned_type, $rust_owned_type), - loaned($c_loaned_type, $rust_loaned_type), - view($c_view_type, $rust_view_type), - ); - validate_equivalence!($c_owned_type, $c_loaned_type); - validate_equivalence!($c_view_type, $c_loaned_type); - }; - - // - // Specific case for closures: c owned type and rust owned type is the same thing: c-repr structure - // Moved type for closures is not autogenerated, so defining Derefs for - // it here to make "into_rust_type" on "&mut z_moved_xxx_t" - // - (owned ($c_owned_type:ty $(,)?), - loaned ($c_loaned_type:ty $(,)?), - moved ($c_moved_type:ty $(,)?) - $(,)?) => { - validate_equivalence!($c_owned_type, $c_loaned_type); - impl_owned!(owned rust $c_owned_type, loaned $c_loaned_type); - impl $crate::transmute::TakeCType for $c_moved_type { - type CType = $c_owned_type; - fn take_c_type(&mut self) -> Self::CType { - std::mem::take(&mut self._this) - } - } - }; - - // - // Rust type is copyable plain data type, just allow to convert references or copy whole structure - // - (copy ($c_type:ty, $rust_type:ty $(,)?) $(,)?) => { - validate_equivalence!($c_type, $rust_type); - impl_transmute!(as_c($rust_type, $c_type)); - impl_transmute!(as_rust($c_type, $rust_type)); - impl_transmute!(into_c($rust_type, $c_type)); - impl_transmute!(into_rust($c_type, $rust_type)); - }; - - // - // Specific case: no owned type exists - // - (loaned ($c_loaned_type:ty, $rust_loaned_type:ty $(,)?) $(,)?) => { - validate_equivalence!($c_loaned_type, $rust_loaned_type); - impl_transmute!(as_c_loaned($rust_loaned_type, $c_loaned_type)); - impl_transmute!(as_rust($c_loaned_type, $rust_loaned_type)); - }; -} diff --git a/src/zbytes.rs b/src/zbytes.rs deleted file mode 100644 index 214b9f64b..000000000 --- a/src/zbytes.rs +++ /dev/null @@ -1,732 +0,0 @@ -// -// Copyright (c) 2024 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, -// - -use core::fmt; -use std::{ - any::Any, - io::{Read, Seek, SeekFrom, Write}, - mem::MaybeUninit, - os::raw::c_void, - ptr::null_mut, - slice::{from_raw_parts, from_raw_parts_mut}, -}; - -use zenoh::{ - bytes::{ZBytes, ZBytesReader, ZBytesSliceIterator, ZBytesWriter}, - internal::buffers::{ZBuf, ZSliceBuffer}, -}; - -pub use crate::opaque_types::{z_loaned_bytes_t, z_owned_bytes_t}; -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -use crate::result::Z_ENULL; -use crate::{ - result::{self, z_result_t, Z_EINVAL, Z_EIO, Z_OK}, - strlen_or_zero, - transmute::{Gravestone, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit, TakeRustType}, - z_loaned_slice_t, z_loaned_string_t, z_moved_bytes_t, z_moved_slice_t, z_moved_string_t, - z_owned_slice_t, z_owned_string_t, z_view_slice_t, CSlice, CSliceOwned, CSliceView, - CStringInner, CStringOwned, -}; -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -use crate::{z_loaned_shm_t, z_moved_shm_mut_t, z_moved_shm_t, z_owned_shm_t}; -decl_c_type! { - owned(z_owned_bytes_t, ZBytes), - loaned(z_loaned_bytes_t), -} - -impl Gravestone for ZBytes { - fn gravestone() -> Self { - ZBytes::default() - } - fn is_gravestone(&self) -> bool { - self.is_empty() - } -} - -/// The gravestone value for `z_owned_bytes_t`. -#[no_mangle] -extern "C" fn z_internal_bytes_null(this: &mut MaybeUninit) { - this.as_rust_type_mut_uninit().write(ZBytes::default()); -} - -/// Constructs an empty instance of `z_owned_bytes_t`. -#[no_mangle] -extern "C" fn z_bytes_empty(this: &mut MaybeUninit) { - this.as_rust_type_mut_uninit().write(ZBytes::default()); -} - -/// Drops `this_`, resetting it to gravestone value. If there are any shallow copies -/// created by `z_bytes_clone()`, they would still stay valid. -#[no_mangle] -extern "C" fn z_bytes_drop(this_: &mut z_moved_bytes_t) { - let _ = this_.take_rust_type(); -} - -/// Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. -#[no_mangle] -extern "C" fn z_internal_bytes_check(this: &z_owned_bytes_t) -> bool { - !this.as_rust_type_ref().is_empty() -} - -/// Borrows data. -#[no_mangle] -unsafe extern "C" fn z_bytes_loan(this: &z_owned_bytes_t) -> &z_loaned_bytes_t { - this.as_rust_type_ref().as_loaned_c_type_ref() -} - -/// Muatably borrows data. -#[no_mangle] -extern "C" fn z_bytes_loan_mut(this: &mut z_owned_bytes_t) -> &mut z_loaned_bytes_t { - this.as_rust_type_mut().as_loaned_c_type_mut() -} - -/// Returns ``true`` if `this_` is empty, ``false`` otherwise. -#[no_mangle] -extern "C" fn z_bytes_is_empty(this: &z_loaned_bytes_t) -> bool { - this.as_rust_type_ref().is_empty() -} - -/// Constructs an owned shallow copy of data in provided uninitialized memory location. -#[no_mangle] -extern "C" fn z_bytes_clone(dst: &mut MaybeUninit, this: &z_loaned_bytes_t) { - dst.as_rust_type_mut_uninit() - .write(this.as_rust_type_ref().clone()); -} - -/// Returns total number of bytes in the payload. -#[no_mangle] -extern "C" fn z_bytes_len(this: &z_loaned_bytes_t) -> usize { - this.as_rust_type_ref().len() -} - -/// Converts data into an owned non-null-terminated string. -/// -/// @param this_: Data to convert. -/// @param dst: An uninitialized memory location where to construct a string. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_to_string( - this: &z_loaned_bytes_t, - dst: &mut MaybeUninit, -) -> z_result_t { - let payload = this.as_rust_type_ref(); - match payload.try_to_string() { - Ok(s) => { - dst.as_rust_type_mut_uninit().write(s.into_owned().into()); - result::Z_OK - } - Err(e) => { - crate::report_error!("Failed to convert the payload: {}", e); - dst.as_rust_type_mut_uninit() - .write(CStringOwned::gravestone()); - result::Z_EINVAL - } - } -} - -/// Converts data into an owned slice. -/// -/// @param this_: Data to convert. -/// @param dst: An uninitialized memory location where to construct a slice. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_to_slice( - this: &z_loaned_bytes_t, - dst: &mut MaybeUninit, -) -> z_result_t { - let payload = this.as_rust_type_ref(); - dst.as_rust_type_mut_uninit() - .write(payload.to_bytes().into_owned().into()); - result::Z_OK -} - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Converts data into an owned SHM buffer by copying it's shared reference. -/// -/// @param this_: Data to convert. -/// @param dst: An uninitialized memory location where to construct an SHM buffer. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_to_owned_shm( - this: &z_loaned_bytes_t, - dst: &mut MaybeUninit, -) -> z_result_t { - let payload = this.as_rust_type_ref(); - match payload.as_shm() { - Some(s) => { - dst.as_rust_type_mut_uninit().write(Some(s.to_owned())); - result::Z_OK - } - None => { - crate::report_error!("Failed to convert the payload"); - dst.as_rust_type_mut_uninit().write(None); - result::Z_EINVAL - } - } -} - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Converts data into a loaned SHM buffer. -/// -/// @param this_: Data to convert. -/// @param dst: An uninitialized memory location where to construct an SHM buffer. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_as_loaned_shm( - this: &'static z_loaned_bytes_t, - dst: &'static mut MaybeUninit<*const z_loaned_shm_t>, -) -> z_result_t { - let payload = this.as_rust_type_ref(); - match payload.as_shm() { - Some(s) => { - dst.write(s.as_loaned_c_type_ref()); - result::Z_OK - } - None => { - crate::report_error!("Failed to convert the payload"); - result::Z_EINVAL - } - } -} - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Converts data into a mutably loaned SHM buffer. -/// -/// @param this_: Data to convert. -/// @param dst: An uninitialized memory location where to construct an SHM buffer. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_as_mut_loaned_shm( - this: &'static mut z_loaned_bytes_t, - dst: &'static mut MaybeUninit<*mut z_loaned_shm_t>, -) -> z_result_t { - let payload = this.as_rust_type_mut(); - match payload.as_shm_mut() { - Some(s) => { - dst.write(s.as_loaned_c_type_mut() as *mut z_loaned_shm_t); - result::Z_OK - } - None => { - crate::report_error!("Failed to convert the payload"); - result::Z_EINVAL - } - } -} - -unsafe impl Send for CSlice {} -unsafe impl Sync for CSlice {} - -impl fmt::Debug for CSlice { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("CSLice").field("_0", &self.slice()).finish() - } -} - -impl ZSliceBuffer for CSlice { - fn as_slice(&self) -> &[u8] { - self.slice() - } - fn as_any(&self) -> &dyn Any { - self - } - - fn as_any_mut(&mut self) -> &mut dyn Any { - self - } -} - -impl From for ZBytes { - fn from(value: CSlice) -> Self { - ZBytes::from(ZBuf::from(value)) - } -} - -impl From for ZBytes { - fn from(value: CSliceOwned) -> Self { - let value: CSlice = value.into(); - ZBytes::from(value) - } -} -impl From for ZBytes { - fn from(value: CStringInner) -> Self { - let value: CSlice = value.into(); - ZBytes::from(value) - } -} - -impl From for ZBytes { - fn from(value: CStringOwned) -> Self { - let value: CSlice = value.into(); - ZBytes::from(value) - } -} - -/// Converts a slice into `z_owned_bytes_t`. -/// The slice is consumed upon function return. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_from_slice( - this: &mut MaybeUninit, - slice: &mut z_moved_slice_t, -) { - let slice = slice.take_rust_type(); - let payload = ZBytes::from(slice); - this.as_rust_type_mut_uninit().write(payload); -} - -/// Converts a slice into `z_owned_bytes_t` by copying. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_copy_from_slice( - this: &mut MaybeUninit, - slice: &z_loaned_slice_t, -) { - let slice = slice.as_rust_type_ref(); - let payload = ZBytes::from(slice.clone_to_owned()); - this.as_rust_type_mut_uninit().write(payload); -} - -/// Converts buffer into `z_owned_bytes_t`. -/// @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. -/// @param data: A pointer to the buffer containing data. `this_` will take ownership of the buffer. -/// @param len: Length of the buffer. -/// @param deleter: A thread-safe function, that will be called on `data` when `this_` is dropped. Can be `NULL` if `data` is located in static memory and does not require a drop. -/// @param context: An optional context to be passed to `deleter`. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_from_buf( - this: &mut MaybeUninit, - data: *mut u8, - len: usize, - deleter: Option, - context: *mut c_void, -) -> z_result_t { - if let Ok(s) = CSliceOwned::wrap(data, len, deleter, context) { - this.as_rust_type_mut_uninit().write(ZBytes::from(s)); - Z_OK - } else { - this.as_rust_type_mut_uninit().write(ZBytes::default()); - Z_EINVAL - } -} - -/// Converts a statically allocated constant buffer into `z_owned_bytes_t`. -/// @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. -/// @param data: A pointer to the statically allocated constant data. -/// @param len: A length of the buffer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_from_static_buf( - this: &mut MaybeUninit, - data: *mut u8, - len: usize, -) -> z_result_t { - if let Ok(s) = CSliceOwned::wrap(data as _, len, None, null_mut()) { - this.as_rust_type_mut_uninit().write(ZBytes::from(s)); - Z_OK - } else { - this.as_rust_type_mut_uninit().write(ZBytes::default()); - Z_EINVAL - } -} - -/// Converts a data from buffer into `z_owned_bytes_t` by copying. -/// @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. -/// @param data: A pointer to the buffer containing data. -/// @param len: Length of the buffer. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_copy_from_buf( - this: &mut MaybeUninit, - data: *const u8, - len: usize, -) -> z_result_t { - if let Ok(s) = CSliceOwned::new(data, len) { - this.as_rust_type_mut_uninit().write(ZBytes::from(s)); - Z_OK - } else { - this.as_rust_type_mut_uninit().write(ZBytes::default()); - Z_EINVAL - } -} - -/// Converts a string into `z_owned_bytes_t`. -/// The string is consumed upon function return. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_from_string( - this: &mut MaybeUninit, - s: &mut z_moved_string_t, -) { - // TODO: verify that string is a valid utf-8 string ? - let cs = s.take_rust_type(); - let payload = ZBytes::from(cs); - this.as_rust_type_mut_uninit().write(payload); -} - -/// Converts a string into `z_owned_bytes_t` by copying. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_copy_from_string( - this: &mut MaybeUninit, - str: &z_loaned_string_t, -) { - let s = str.as_rust_type_ref(); - let payload = ZBytes::from(s.clone_to_owned()); - this.as_rust_type_mut_uninit().write(payload); -} - -/// Converts a null-terminated string into `z_owned_bytes_t`. -/// @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. -/// @param str: a pointer to the string. `this_` will take ownership of the string. -/// @param deleter: A thread-safe function, that will be called on `str` when `this_` is dropped. Can be `NULL` if `str` is located in static memory and does not require a drop. -/// @param context: An optional context to be passed to `deleter`. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_from_str( - this: &mut MaybeUninit, - str: *mut libc::c_char, - deleter: Option, - context: *mut c_void, -) -> z_result_t { - if let Ok(s) = CStringOwned::wrap(str, strlen_or_zero(str), deleter, context) { - this.as_rust_type_mut_uninit().write(ZBytes::from(s)); - Z_OK - } else { - this.as_rust_type_mut_uninit().write(ZBytes::default()); - Z_EINVAL - } -} - -/// Converts a statically allocated constant null-terminated string into `z_owned_bytes_t` by aliasing. -/// @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. -/// @param str: a pointer to the statically allocated constant string. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_from_static_str( - this: &mut MaybeUninit, - str: *const libc::c_char, -) -> z_result_t { - if let Ok(s) = CStringOwned::wrap(str as _, strlen_or_zero(str), None, null_mut()) { - this.as_rust_type_mut_uninit().write(ZBytes::from(s)); - Z_OK - } else { - this.as_rust_type_mut_uninit().write(ZBytes::default()); - Z_EINVAL - } -} - -/// Converts a null-terminated string into `z_owned_bytes_t` by copying. -/// @param this_: An uninitialized location in memory where `z_owned_bytes_t` is to be constructed. -/// @param str: a pointer to the null-terminated string. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_copy_from_str( - this: &mut MaybeUninit, - str: *const libc::c_char, -) -> z_result_t { - if let Ok(s) = CStringOwned::new(str, strlen_or_zero(str)) { - this.as_rust_type_mut_uninit().write(ZBytes::from(s)); - Z_OK - } else { - this.as_rust_type_mut_uninit().write(ZBytes::default()); - Z_EINVAL - } -} - -pub use crate::z_bytes_slice_iterator_t; -decl_c_type!(loaned(z_bytes_slice_iterator_t, ZBytesSliceIterator<'static>)); - -/// Returns an iterator on raw bytes slices contained in the `z_loaned_bytes_t`. -/// -/// Zenoh may store data in non-contiguous regions of memory, this iterator -/// then allows to access raw data directly without any attempt of deserializing it. -/// Please note that no guarantee is provided on the internal memory layout. -/// The only provided guarantee is on the bytes order that is preserved. -#[no_mangle] -pub extern "C" fn z_bytes_get_slice_iterator( - this: &'static z_loaned_bytes_t, -) -> z_bytes_slice_iterator_t { - *this.as_rust_type_ref().slices().as_loaned_c_type_ref() -} - -/// Gets next slice. -/// @param this_: Slice iterator. -/// @param slice: An unitialized memory location where the view for the next slice will be constructed. -/// @return `false` if there are no more slices (in this case slice will stay unchanged), `true` otherwise. -#[no_mangle] -pub extern "C" fn z_bytes_slice_iterator_next( - this: &mut z_bytes_slice_iterator_t, - slice: &mut MaybeUninit, -) -> bool { - match this.as_rust_type_mut().next() { - Some(s) => { - slice - .as_rust_type_mut_uninit() - .write(CSliceView::from_slice(s)); - true - } - None => false, - } -} - -#[cfg(feature = "unstable")] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// Attempts to get a contiguous view to the underlying bytes. -/// This is only possible if data is not fragmented, otherwise the function will fail. -/// In case of fragmented data, consider using `z_bytes_get_slice_iterator()`. -/// -/// @param this_: An instance of Zenoh data. -/// @param view: An uninitialized memory location where a contiguous view on data will be constructed. -/// @return ​0​ upon success, negative error code otherwise. -#[no_mangle] -pub extern "C" fn z_bytes_get_contiguous_view( - this: &'static z_loaned_bytes_t, - view: &mut MaybeUninit, -) -> result::z_result_t { - let payload = this.as_rust_type_ref(); - match payload.to_bytes() { - std::borrow::Cow::Borrowed(s) => { - view.as_rust_type_mut_uninit() - .write(CSliceView::from_slice(s)); - result::Z_OK - } - std::borrow::Cow::Owned(_) => result::Z_EINVAL, - } -} - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Converts from an immutable SHM buffer consuming it. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_from_shm( - this: &mut MaybeUninit, - shm: &mut z_moved_shm_t, -) -> z_result_t { - let Some(shm) = shm.take_rust_type() else { - this.as_rust_type_mut_uninit().write(ZBytes::default()); - return Z_ENULL; - }; - this.as_rust_type_mut_uninit().write(shm.into()); - Z_OK -} - -#[cfg(all(feature = "shared-memory", feature = "unstable"))] -/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. -/// @brief Converts a mutable SHM buffer consuming it. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_from_shm_mut( - this: &mut MaybeUninit, - shm: &mut z_moved_shm_mut_t, -) -> z_result_t { - let Some(shm) = shm.take_rust_type() else { - this.as_rust_type_mut_uninit().write(ZBytes::default()); - return Z_ENULL; - }; - this.as_rust_type_mut_uninit().write(shm.into()); - Z_OK -} - -pub use crate::z_bytes_reader_t; -decl_c_type!(loaned(z_bytes_reader_t, ZBytesReader<'static>)); - -/// Returns a reader for the data. -/// -/// The `data` should outlive the reader. -#[no_mangle] -pub extern "C" fn z_bytes_get_reader(data: &'static z_loaned_bytes_t) -> z_bytes_reader_t { - *data.as_rust_type_ref().reader().as_loaned_c_type_ref() -} - -/// Reads data into specified destination. -/// -/// @param this_: Data reader to read from. -/// @param dst: Buffer where the read data is written. -/// @param len: Maximum number of bytes to read. -/// @return number of bytes read. If return value is smaller than `len`, it means that theend of the data was reached. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_reader_read( - this: &mut z_bytes_reader_t, - dst: *mut u8, - len: usize, -) -> usize { - let reader = this.as_rust_type_mut(); - let buf = unsafe { from_raw_parts_mut(dst, len) }; - reader.read(buf).unwrap_or(0) -} - -/// Sets the `reader` position indicator for the payload to the value pointed to by offset. -/// The new position is exactly `offset` bytes measured from the beginning of the payload if origin is `SEEK_SET`, -/// from the current reader position if origin is `SEEK_CUR`, and from the end of the payload if origin is `SEEK_END`. -/// @return ​0​ upon success, negative error code otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_reader_seek( - this: &mut z_bytes_reader_t, - offset: i64, - origin: libc::c_int, -) -> z_result_t { - let reader = this.as_rust_type_mut(); - let pos = match origin { - libc::SEEK_SET => match offset.try_into() { - Ok(o) => SeekFrom::Start(o), - Err(_) => { - return result::Z_EINVAL; - } - }, - libc::SEEK_CUR => SeekFrom::Current(offset), - libc::SEEK_END => SeekFrom::End(offset), - _ => { - return result::Z_EINVAL; - } - }; - - match reader.seek(pos) { - Ok(_) => result::Z_OK, - Err(_) => result::Z_EINVAL, - } -} - -/// Gets the read position indicator. -/// @return read position indicator on success or -1L if failure occurs. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_reader_tell(this_: &mut z_bytes_reader_t) -> i64 { - let reader = this_.as_rust_type_mut(); - reader.stream_position().map(|p| p as i64).unwrap_or(-1) -} - -/// Gets the number of bytes that can still be read. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_reader_remaining(this_: &z_bytes_reader_t) -> usize { - let reader = this_.as_rust_type_ref(); - reader.remaining() -} - -pub use crate::opaque_types::{ - z_loaned_bytes_writer_t, z_moved_bytes_writer_t, z_owned_bytes_writer_t, -}; - -decl_c_type! { - owned(z_owned_bytes_writer_t, option ZBytesWriter), - loaned(z_loaned_bytes_writer_t), -} - -/// @brief Constructs a data writer with empty payload. -/// @param this_: An uninitialized memory location where writer is to be constructed. -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -extern "C" fn z_bytes_writer_empty(this: &mut MaybeUninit) -> z_result_t { - this.as_rust_type_mut_uninit().write(Some(ZBytes::writer())); - result::Z_OK -} - -/// Drops `this_`, resetting it to gravestone value. -#[no_mangle] -extern "C" fn z_bytes_writer_drop(this_: &mut z_moved_bytes_writer_t) { - let _ = this_.take_rust_type(); -} - -/// Returns ``true`` if `this_` is in a valid state, ``false`` if it is in a gravestone state. -#[no_mangle] -extern "C" fn z_internal_bytes_writer_check(this: &z_owned_bytes_writer_t) -> bool { - this.as_rust_type_ref().is_some() -} - -/// Borrows writer. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_writer_loan( - this: &z_owned_bytes_writer_t, -) -> &z_loaned_bytes_writer_t { - this.as_rust_type_ref() - .as_ref() - .unwrap_unchecked() - .as_loaned_c_type_ref() -} - -/// Muatably borrows writer. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_bytes_writer_loan_mut( - this: &mut z_owned_bytes_writer_t, -) -> &mut z_loaned_bytes_writer_t { - this.as_rust_type_mut() - .as_mut() - .unwrap_unchecked() - .as_loaned_c_type_mut() -} - -/// Constructs a writer in a gravestone state. -#[no_mangle] -pub extern "C" fn z_internal_bytes_writer_null(this_: &mut MaybeUninit) { - this_.as_rust_type_mut_uninit().write(None); -} - -/// @brief Drop writer and extract underlying `bytes` object it was writing to. -/// @param this_: A writer instance. -/// @param bytes: An uninitialized memory location where `bytes` object` will be written to. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -pub unsafe extern "C" fn z_bytes_writer_finish( - this: &mut z_moved_bytes_writer_t, - bytes: &mut MaybeUninit, -) { - bytes - .as_rust_type_mut_uninit() - .write(this.take_rust_type().unwrap_unchecked().finish()); -} - -/// Writes `len` bytes from `src` into underlying data. -/// -/// @return 0 in case of success, negative error code otherwise. -#[allow(clippy::missing_safety_doc)] -#[no_mangle] -unsafe extern "C" fn z_bytes_writer_write_all( - this: &mut z_loaned_bytes_writer_t, - src: *const u8, - len: usize, -) -> z_result_t { - match this.as_rust_type_mut().write_all(from_raw_parts(src, len)) { - Ok(_) => Z_OK, - Err(_) => Z_EIO, - } -} - -/// Appends bytes. -/// This allows to compose a serialized data out of multiple `z_owned_bytes_t` that may point to different memory regions. -/// Said in other terms, it allows to create a linear view on different memory regions without copy. -/// -/// @return 0 in case of success, negative error code otherwise. -#[no_mangle] -extern "C" fn z_bytes_writer_append( - this: &mut z_loaned_bytes_writer_t, - bytes: &mut z_moved_bytes_t, -) -> z_result_t { - this.as_rust_type_mut().append(bytes.take_rust_type()); - result::Z_OK -}