diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ac1d012..80c6faee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,21 +25,15 @@ jobs: name: Code checks runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install Rust toolchain run: | rustup show rustup component add rustfmt clippy - name: Code format check - uses: actions-rs/cargo@v1 - with: - command: fmt - args: -- --check + run: cargo fmt --check - name: Clippy check - uses: actions-rs/cargo@v1 - with: - command: clippy - args: -- -D warnings + run: cargo clippy -- -D warnings - name: Environment setup id: env shell: bash @@ -90,53 +84,78 @@ jobs: fail-fast: false matrix: job: - - { target: x86_64-unknown-linux-gnu, arch: amd64, os: ubuntu-20.04 } - - { target: x86_64-apple-darwin, arch: darwin, os: macos-latest } - - { target: aarch64-apple-darwin, arch: darwin, os: macos-latest } + - { + target: x86_64-unknown-linux-gnu, + arch: amd64, + os: ubuntu-20.04, + build-cmd: "cargo", + } + - { + target: x86_64-apple-darwin, + arch: darwin, + os: macos-latest, + build-cmd: "cargo", + } + - { + target: aarch64-apple-darwin, + arch: darwin, + os: macos-latest, + build-cmd: "cargo", + } - { target: x86_64-unknown-linux-musl, arch: amd64, os: ubuntu-20.04, - use-cross: true, + build-cmd: "cross", } - { target: arm-unknown-linux-gnueabi, arch: armel, os: ubuntu-20.04, - use-cross: true, + build-cmd: "cross", } - { target: arm-unknown-linux-gnueabihf, arch: armhf, os: ubuntu-20.04, - use-cross: true, + build-cmd: "cross", } - { target: armv7-unknown-linux-gnueabihf, arch: armhf, os: ubuntu-20.04, - use-cross: true, + build-cmd: "cross", } - { target: aarch64-unknown-linux-gnu, arch: arm64, os: ubuntu-20.04, - use-cross: true, + build-cmd: "cross", } - { target: aarch64-unknown-linux-musl, arch: arm64, os: ubuntu-20.04, - use-cross: true, + build-cmd: "cross", + } + - { + target: x86_64-pc-windows-msvc, + arch: win64, + os: windows-2019, + build-cmd: "cargo", } - - { target: x86_64-pc-windows-msvc, arch: win64, os: windows-2019 } ## ## NOTE: cannon build for Windows GNU as not supported by cyclors ## - # - { target: x86_64-pc-windows-gnu, arch: win64 , os: windows-2019 } + # - { + # target: x86_64-pc-windows-gnu, + # arch: win64, + # os: windows-2019, + # build-cmd: "cargo", + # } steps: - name: Checkout source code - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 500 # NOTE: get long history for git-version crate to correctly compute a version - name: Fetch Git tags # NOTE: workaround for https://github.com/actions/checkout/issues/290 @@ -164,38 +183,26 @@ jobs: ;; esac + cargo install cross --git https://github.com/cross-rs/cross + - name: Install Rust toolchain run: | rustup show rustup target add ${{ matrix.job.target }} - name: zenoh-plugin-dds > Build - uses: actions-rs/cargo@v1 - with: - use-cross: ${{ matrix.job.use-cross }} - command: build - args: --release --target=${{ matrix.job.target }} -p zenoh-plugin-dds - + run: ${{ matrix.job.build-cmd }} build --release --target=${{ matrix.job.target }} -p zenoh-plugin-dds + - name: zenoh-bridge-dds > Build - uses: actions-rs/cargo@v1 - with: - use-cross: ${{ matrix.job.use-cross }} - command: build - args: --release --target=${{ matrix.job.target }} -p zenoh-bridge-dds + run: ${{ matrix.job.build-cmd }} build --release --target=${{ matrix.job.target }} -p zenoh-bridge-dds - name: zenoh-plugin-dds > Debian package if: contains(matrix.job.target, '-linux-gnu') - uses: actions-rs/cargo@v1 - with: - command: deb - args: --no-build --target=${{ matrix.job.target }} -p zenoh-plugin-dds + run: cargo deb --no-build --target=${{ matrix.job.target }} -p zenoh-plugin-dds - name: zenoh-bridge-dds > Debian package if: contains(matrix.job.target, '-linux-gnu') - uses: actions-rs/cargo@v1 - with: - command: deb - args: --no-build --target=${{ matrix.job.target }} -p zenoh-bridge-dds + run: cargo deb --no-build --target=${{ matrix.job.target }} -p zenoh-bridge-dds - name: Packaging id: package @@ -249,7 +256,7 @@ jobs: esac - name: "Upload packages" - uses: actions/upload-artifact@master + uses: actions/upload-artifact@v3 with: name: ${{ matrix.job.target }} path: | @@ -262,14 +269,14 @@ jobs: needs: [checks, builds] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 500 # NOTE: get long history for git-version crate to correctly compute a version - name: Fetch Git tags # NOTE: workaround for https://github.com/actions/checkout/issues/290 shell: bash run: git fetch --tags --force - name: Download packages from previous job - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: path: PACKAGES - name: Unzip PACKAGES @@ -281,19 +288,19 @@ jobs: unzip PACKAGES/aarch64-unknown-linux-musl/zenoh-bridge-dds-${{ needs.checks.outputs.PKG_VERSION }}-aarch64-unknown-linux-musl.zip -d docker/linux/arm64/ tree docker - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Docker meta - set tags and labels id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@v5 with: images: eclipse/zenoh-bridge-dds - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_COM_USERNAME }} password: ${{ secrets.DOCKER_COM_PASSWORD }} - name: Build and push - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64 @@ -309,7 +316,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Download result of previous builds - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: path: ARTIFACTS - name: Publish as github release @@ -339,7 +346,7 @@ jobs: scp -o "StrictHostKeyChecking=no" -r * ${SSH_TARGET}:${DOWNLOAD_DIR}/ echo "---- cleanup identity" ssh-add -D - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install Rust toolchain run: rustup show - name: Publish to crates.io diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 1cca51be..9f26e691 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -32,7 +32,7 @@ jobs: os: [ubuntu-latest, macOS-latest, windows-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install ACL if: startsWith(matrix.os,'ubuntu') @@ -44,43 +44,22 @@ jobs: rustup component add rustfmt clippy - name: Code format check - uses: actions-rs/cargo@v1 - with: - command: fmt - args: -- --check + run: cargo fmt --check - name: Clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --all --examples -- -D warnings + run: cargo clippy --all --examples -- -D warnings - name: Build zenoh-plugin-dds - uses: actions-rs/cargo@v1 - with: - command: build - args: -p zenoh-plugin-dds --verbose --all-targets + run: cargo build -p zenoh-plugin-dds --verbose --all-targets - name: Build zenoh-plugin-dds (with dds_shm) - uses: actions-rs/cargo@v1 - with: - command: build - args: -p zenoh-plugin-dds --features dds_shm --verbose --all-targets + run: cargo build -p zenoh-plugin-dds --features dds_shm --verbose --all-targets - name: Build zenoh-bridge-dds - uses: actions-rs/cargo@v1 - with: - command: build - args: -p zenoh-bridge-dds --verbose --all-targets + run: cargo build -p zenoh-bridge-dds --verbose --all-targets - name: Build zenoh-bridge-dds (with dds_shm) - uses: actions-rs/cargo@v1 - with: - command: build - args: -p zenoh-bridge-dds --features dds_shm --verbose --all-targets + run: cargo build -p zenoh-bridge-dds --features dds_shm --verbose --all-targets - name: Run tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --verbose + run: cargo test --verbose diff --git a/Cargo.lock b/Cargo.lock index 3114a7f8..7a35eeb0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -127,9 +127,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.5.0" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ "anstyle", "anstyle-parse", @@ -160,17 +160,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "anstyle-wincon" -version = "2.1.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -214,7 +214,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", - "event-listener", + "event-listener 2.5.3", "futures-core", ] @@ -306,7 +306,7 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ - "event-listener", + "event-listener 2.5.3", ] [[package]] @@ -320,11 +320,11 @@ dependencies = [ "autocfg", "blocking", "cfg-if 1.0.0", - "event-listener", + "event-listener 2.5.3", "futures-lite", "rustix 0.37.25", "signal-hook", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -674,7 +674,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -724,9 +724,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.3" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6" +checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" dependencies = [ "clap_builder", "clap_derive", @@ -734,21 +734,21 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.2" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" +checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" dependencies = [ "anstream", "anstyle", - "clap_lex 0.5.1", + "clap_lex 0.6.0", "strsim", ] [[package]] name = "clap_derive" -version = "4.4.2" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", @@ -767,9 +767,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "cmake" @@ -1017,7 +1017,7 @@ dependencies = [ "libc", "option-ext", "redox_users", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1083,7 +1083,7 @@ checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" dependencies = [ "errno-dragonfly", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1102,6 +1102,17 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "event-listener" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite 0.2.13", +] + [[package]] name = "fancy-regex" version = "0.11.0" @@ -1490,7 +1501,7 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1676,7 +1687,7 @@ checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi 0.3.2", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1702,7 +1713,7 @@ checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi 0.3.2", "rustix 0.38.13", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1750,7 +1761,7 @@ dependencies = [ "anyhow", "base64 0.21.4", "bytecount", - "clap 4.4.3", + "clap 4.4.11", "fancy-regex", "fraction", "getrandom 0.2.10", @@ -1835,7 +1846,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d580318f95776505201b28cf98eb1fa5e4be3b689633ba6a3e6cd880ff22d8cb" dependencies = [ "cfg-if 1.0.0", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1920,7 +1931,7 @@ checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2104,18 +2115,18 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "ordered-float" -version = "3.9.1" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a54938017eacd63036332b4ae5c8a49fc8c0c1d6d629893057e4f13609edd06" +checksum = "536900a8093134cf9ccf00a27deb3532421099e958d9dd431135d0c7543ca1e8" dependencies = [ "num-traits", ] [[package]] name = "os_str_bytes" -version = "6.5.1" +version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" [[package]] name = "parking" @@ -2143,7 +2154,7 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -2391,7 +2402,7 @@ dependencies = [ "libc", "log", "pin-project-lite 0.2.13", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2461,10 +2472,10 @@ checksum = "e13f81c9a9d574310b8351f8666f5a93ac3b0069c45c28ad52c10291389a7cf9" dependencies = [ "bytes", "rand 0.8.5", - "ring", + "ring 0.16.20", "rustc-hash", "rustls", - "rustls-native-certs", + "rustls-native-certs 0.6.3", "slab", "thiserror", "tinyvec", @@ -2481,7 +2492,7 @@ dependencies = [ "libc", "socket2 0.5.4", "tracing", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2666,11 +2677,25 @@ dependencies = [ "libc", "once_cell", "spin 0.5.2", - "untrusted", + "untrusted 0.7.1", "web-sys", "winapi", ] +[[package]] +name = "ring" +version = "0.17.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "684d5e6e18f669ccebf64a92236bb7db9a34f07be010e3627368182027180866" +dependencies = [ + "cc", + "getrandom 0.2.10", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys 0.48.0", +] + [[package]] name = "ringbuffer-spsc" version = "0.1.9" @@ -2750,7 +2775,7 @@ dependencies = [ "io-lifetimes", "libc", "linux-raw-sys 0.3.8", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2763,7 +2788,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.4.7", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2773,8 +2798,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", - "ring", - "rustls-webpki", + "ring 0.16.20", + "rustls-webpki 0.101.5", "sct", ] @@ -2785,7 +2810,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pemfile 1.0.3", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +dependencies = [ + "openssl-probe", + "rustls-pemfile 2.0.0", + "rustls-pki-types", "schannel", "security-framework", ] @@ -2799,14 +2837,41 @@ dependencies = [ "base64 0.21.4", ] +[[package]] +name = "rustls-pemfile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e4980fa29e4c4b212ffb3db068a564cbf560e51d3944b7c88bd8bf5bec64f4" +dependencies = [ + "base64 0.21.4", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb0a1f9b9efec70d32e6d6aa3e58ebd88c3754ec98dfe9145c63cf54cc829b83" + [[package]] name = "rustls-webpki" version = "0.101.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45a27e3b59326c16e23d30aeb7a36a24cc0d29e71d68ff611cdfb4a01d013bed" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", +] + +[[package]] +name = "rustls-webpki" +version = "0.102.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de2635c8bc2b88d367767c5de8ea1d8db9af3f6219eba28442242d9ab81d1b89" +dependencies = [ + "ring 0.17.6", + "rustls-pki-types", + "untrusted 0.9.0", ] [[package]] @@ -2821,7 +2886,7 @@ version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2860,8 +2925,8 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -3115,7 +3180,7 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38aabbeafa6f6dead8cebf246fe9fae1f9215c8d29b3a69f93bd62a9e4a3dcd6" dependencies = [ - "event-listener", + "event-listener 2.5.3", ] [[package]] @@ -3150,7 +3215,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -3517,7 +3582,7 @@ dependencies = [ "pin-project-lite 0.2.13", "socket2 0.5.4", "tokio-macros", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -3706,6 +3771,12 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[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" @@ -3929,9 +4000,12 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.2" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" +checksum = "0de2cfda980f21be5a7ed2eadb3e6fe074d56022bea2cdeb1a62eb220fc04188" +dependencies = [ + "rustls-pki-types", +] [[package]] name = "which" @@ -3982,7 +4056,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -3991,7 +4065,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "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.0", ] [[package]] @@ -4000,13 +4083,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -4015,42 +4113,84 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winreg" version = "0.50.0" @@ -4058,7 +4198,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ "cfg-if 1.0.0", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -4072,7 +4212,7 @@ dependencies = [ "base64 0.21.4", "const_format", "env_logger", - "event-listener", + "event-listener 4.0.0", "flume", "form_urlencoded", "futures", @@ -4276,9 +4416,9 @@ dependencies = [ "log", "quinn", "rustls", - "rustls-native-certs", - "rustls-pemfile", - "rustls-webpki", + "rustls-native-certs 0.7.0", + "rustls-pemfile 2.0.0", + "rustls-webpki 0.102.0", "secrecy", "zenoh-config", "zenoh-core", @@ -4317,8 +4457,8 @@ dependencies = [ "futures", "log", "rustls", - "rustls-pemfile", - "rustls-webpki", + "rustls-pemfile 2.0.0", + "rustls-webpki 0.102.0", "secrecy", "webpki-roots", "zenoh-config", @@ -4437,7 +4577,7 @@ dependencies = [ "anyhow", "async-std", "base64 0.21.4", - "clap 3.2.25", + "clap 4.4.11", "env_logger", "flume", "futures", @@ -4503,7 +4643,7 @@ version = "0.11.0-dev" source = "git+https://github.com/eclipse-zenoh/zenoh?branch=simplified_load_plugin#51d5eb381b5954cbdec6c4bcb9e1b1d5aa3f934a" dependencies = [ "async-std", - "event-listener", + "event-listener 4.0.0", "flume", "futures", "tokio", @@ -4550,7 +4690,7 @@ source = "git+https://github.com/eclipse-zenoh/zenoh?branch=simplified_load_plug dependencies = [ "async-std", "async-trait", - "clap 3.2.25", + "clap 4.4.11", "const_format", "flume", "futures", diff --git a/README.md b/README.md index 62eadbb2..ec941ff1 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Check the website [zenoh.io](http://zenoh.io) and the [roadmap](https://github.c ## Background The Data Distribution Service (DDS) is a standard for data-centric publish subscribe. Whilst DDS has been around for quite some time and has a long history of deployments in various industries, it has recently gained quite a bit of attentions thanks to its adoption by the Robotic Operating System (ROS 2) -- where it is used for communication between ROS 2 nodes. -### :warning: On usage with ROS 2 :warning: +### ⚠️ On usage with ROS 2 ⚠️ This plugin is based on the DDS standard, and thus can work with ROS 2 to some extent. diff --git a/zenoh-plugin-dds/src/config.rs b/zenoh-plugin-dds/src/config.rs index 62b112ec..5672172d 100644 --- a/zenoh-plugin-dds/src/config.rs +++ b/zenoh-plugin-dds/src/config.rs @@ -58,10 +58,9 @@ pub struct Config { deserialize_with = "deserialize_duration" )] pub queries_timeout: Duration, - #[serde(default)] - __required__: bool, - #[serde(default, deserialize_with = "deserialize_paths")] - __path__: Vec, + __required__: Option, + #[serde(default, deserialize_with = "deserialize_path")] + __path__: Option>, } fn default_domain() -> u32 { @@ -72,38 +71,67 @@ fn default_domain() -> u32 { } } -fn deserialize_paths<'de, D>(deserializer: D) -> Result, D::Error> +fn deserialize_path<'de, D>(deserializer: D) -> Result>, D::Error> where D: Deserializer<'de>, { - struct V; - impl<'de> serde::de::Visitor<'de> for V { - type Value = Vec; - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { - write!(formatter, "a string or vector of strings") - } - fn visit_str(self, v: &str) -> Result - where - E: de::Error, - { - Ok(vec![v.into()]) - } - fn visit_seq(self, mut seq: A) -> Result - where - A: de::SeqAccess<'de>, - { - let mut v = if let Some(l) = seq.size_hint() { - Vec::with_capacity(l) - } else { - Vec::new() - }; - while let Some(s) = seq.next_element()? { - v.push(s); - } - Ok(v) + deserializer.deserialize_option(OptPathVisitor) +} + +struct OptPathVisitor; + +impl<'de> serde::de::Visitor<'de> for OptPathVisitor { + type Value = Option>; + + fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(formatter, "none or a string or an array of strings") + } + + fn visit_none(self) -> Result + where + E: de::Error, + { + Ok(None) + } + + fn visit_some(self, deserializer: D) -> Result + where + D: Deserializer<'de>, + { + deserializer.deserialize_any(PathVisitor).map(Some) + } +} + +struct PathVisitor; + +impl<'de> serde::de::Visitor<'de> for PathVisitor { + type Value = Vec; + + fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(formatter, "a string or an array of strings") + } + + fn visit_str(self, v: &str) -> Result + where + E: de::Error, + { + Ok(vec![v.into()]) + } + + fn visit_seq(self, mut seq: A) -> Result + where + A: de::SeqAccess<'de>, + { + let mut v = if let Some(l) = seq.size_hint() { + Vec::with_capacity(l) + } else { + Vec::new() + }; + while let Some(s) = seq.next_element()? { + v.push(s); } + Ok(v) } - deserializer.deserialize_any(V) } fn deserialize_regex<'de, D>(deserializer: D) -> Result, D::Error> @@ -171,6 +199,14 @@ impl<'de> Visitor<'de> for RegexVisitor { formatter.write_str(r#"either a string or a list of strings"#) } + // for `null` value + fn visit_unit(self) -> Result + where + E: de::Error, + { + Ok(None) + } + fn visit_str(self, value: &str) -> Result where E: de::Error, @@ -194,3 +230,73 @@ impl<'de> Visitor<'de> for RegexVisitor { .map_err(|e| de::Error::custom(format!("Invalid regex '{s}': {e}"))) } } + +#[cfg(test)] +mod tests { + use super::Config; + + #[test] + fn test_path_field() { + // See: https://github.com/eclipse-zenoh/zenoh-plugin-webserver/issues/19 + let config = serde_json::from_str::(r#"{"__path__": "/example/path"}"#); + + assert!(config.is_ok()); + let Config { + __required__, + __path__, + .. + } = config.unwrap(); + + assert_eq!(__path__, Some(vec![String::from("/example/path")])); + assert_eq!(__required__, None); + } + + #[test] + fn test_required_field() { + // See: https://github.com/eclipse-zenoh/zenoh-plugin-webserver/issues/19 + let config = serde_json::from_str::(r#"{"__required__": true}"#); + assert!(config.is_ok()); + let Config { + __required__, + __path__, + .. + } = config.unwrap(); + + assert_eq!(__path__, None); + assert_eq!(__required__, Some(true)); + } + + #[test] + fn test_path_field_and_required_field() { + // See: https://github.com/eclipse-zenoh/zenoh-plugin-webserver/issues/19 + let config = serde_json::from_str::( + r#"{"__path__": "/example/path", "__required__": true}"#, + ); + + assert!(config.is_ok()); + let Config { + __required__, + __path__, + .. + } = config.unwrap(); + + assert_eq!(__path__, Some(vec![String::from("/example/path")])); + assert_eq!(__required__, Some(true)); + } + + #[test] + fn test_no_path_field_and_no_required_field() { + // See: https://github.com/eclipse-zenoh/zenoh-plugin-webserver/issues/19 + let config = serde_json::from_str::("{}"); + + assert!(config.is_ok()); + let Config { + __required__, + __path__, + .. + } = config.unwrap(); + + assert_eq!(__path__, None); + assert_eq!(__required__, None); + } +} diff --git a/zenoh-plugin-dds/src/dds_mgt.rs b/zenoh-plugin-dds/src/dds_mgt.rs index 6621da94..51a9e5ad 100644 --- a/zenoh-plugin-dds/src/dds_mgt.rs +++ b/zenoh-plugin-dds/src/dds_mgt.rs @@ -653,13 +653,25 @@ pub fn create_forwarding_dds_writer( topic_name: String, type_name: String, keyless: bool, - qos: Qos, + mut qos: Qos, ) -> Result { let cton = CString::new(topic_name).unwrap().into_raw(); let ctyn = CString::new(type_name).unwrap().into_raw(); unsafe { let t = cdds_create_blob_topic(dp, cton, ctyn, keyless); + + // force RELIABLE QoS for Writers (#165) + if let Some(qos::Reliability { + kind: qos::ReliabilityKind::BEST_EFFORT, + .. + }) = &mut qos.reliability + { + // Per DDS specification, the default Reliability value for DataWriters is RELIABLE with max_blocking_time=100ms + // Thus just use default value. + qos.reliability = None; + } + let qos_native = qos.to_qos_native(); let writer: i32 = dds_create_writer(dp, t, qos_native, std::ptr::null_mut()); Qos::delete_qos_native(qos_native); diff --git a/zenoh-plugin-dds/src/lib.rs b/zenoh-plugin-dds/src/lib.rs index 71b6ed41..3a9ba4ab 100644 --- a/zenoh-plugin-dds/src/lib.rs +++ b/zenoh-plugin-dds/src/lib.rs @@ -111,7 +111,7 @@ fn log_ros2_deprecation_warning() { if !LOG_ROS2_DEPRECATION_WARNING_FLAG.swap(true, std::sync::atomic::Ordering::Relaxed) { log::warn!("------------------------------------------------------------------------------------------"); log::warn!( - "ROS 2 system detected. Did you now a new Zenoh bridge dedicated to ROS 2 exists ?" + "ROS 2 system detected. Did you know a new Zenoh bridge dedicated to ROS 2 exists ?" ); log::warn!("Check it out on https://github.com/eclipse-zenoh/zenoh-plugin-ros2dds"); log::warn!("This DDS bridge will eventually be deprecated for ROS 2 usage in favor of this new bridge.");