diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 11c06aae..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,135 +0,0 @@ -name: CI Status - -on: - push: - branches: - - main - pull_request: - branches: - - main - -env: - CARGO_TERM_COLOR: always - RUST_TEST_TIME_UNIT: 60,120 - RUST_TEST_TIME_INTEGRATION: 60,120 - RUST_TEST_TIME_DOCTEST: 60,120 - -jobs: - test: - name: test - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - crate: [ libcoap-sys, libcoap-rs ] - dtls_backend: [ openssl, gnutls, tinydtls, mbedtls ] - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: dtolnay/rust-toolchain@stable - with: - components: rust-src - toolchain: stable - - if: matrix.dtls_backend == 'gnutls' - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: libgnutls28-dev libgnutls30 - version: 1.0 - - if: matrix.crate == 'libcoap-rs' && matrix.dtls_backend == 'tinydtls' - run: cargo test -p ${{ matrix.crate }} --no-default-features --features tcp,vendored,dtls-psk,dtls-rpk --features dtls_${{ matrix.dtls_backend }} --features dtls_${{ matrix.dtls_backend }}_vendored --no-fail-fast - - if: matrix.crate == 'libcoap-rs' && matrix.dtls_backend == 'mbedtls' - run: cargo test -p ${{ matrix.crate }} --no-default-features --features tcp,vendored,dtls-psk,dtls-pki --features dtls_${{ matrix.dtls_backend }} --features dtls_${{ matrix.dtls_backend }}_vendored --no-fail-fast - - if: matrix.crate == 'libcoap-rs' && matrix.dtls_backend == 'openssl' - run: cargo test -p ${{ matrix.crate }} --no-default-features --features tcp,vendored,dtls-psk,dtls-pki --features dtls_${{ matrix.dtls_backend }} --features dtls_${{ matrix.dtls_backend }}_vendored --no-fail-fast - - if: matrix.crate == 'libcoap-rs' && matrix.dtls_backend == 'gnutls' - run: cargo test -p ${{ matrix.crate }} --no-default-features --features tcp,vendored,dtls-psk,dtls-pki,dtls-rpk --features dtls_${{ matrix.dtls_backend }} --no-fail-fast - - if: matrix.crate == 'libcoap-sys' && matrix.dtls_backend != 'gnutls' - run: cargo test -p ${{ matrix.crate }} --features dtls,dtls_backend_${{ matrix.dtls_backend }},dtls_backend_${{ matrix.dtls_backend }}_vendored --no-fail-fast - - if: matrix.crate == 'libcoap-sys' && matrix.dtls_backend == 'gnutls' - run: cargo test -p ${{ matrix.crate }} --features dtls,dtls_backend_${{ matrix.dtls_backend }} --no-fail-fast - - lint: - name: lint - runs-on: ubuntu-latest - strategy: - matrix: - crate: [ libcoap-sys, libcoap-rs ] - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: dtolnay/rust-toolchain@stable - with: - components: clippy, rustfmt - - uses: giraffate/clippy-action@main - with: - reporter: 'github-check' - clippy_flags: -p ${{ matrix.crate }} --no-deps --all-features - level: warning - fail_on_error: true - tool_name: clippy (${{ matrix.crate }}) - - coverage: - name: coverage - runs-on: ubuntu-latest - outputs: - report: ${{ steps.cov-report.outputs.summary }} - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: dtolnay/rust-toolchain@stable - with: - components: clippy, rustfmt - - uses: baptiste0928/cargo-install@v3 - with: - crate: cargo-tarpaulin - - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: libgnutls28-dev libgnutls30 - version: 1.0 - - run: cargo tarpaulin --no-fail-fast --workspace --verbose --features tcp,vendored,dtls_gnutls,dtls-psk,dtls-rpk,dtls-pki --exclude-files libcoap-sys/tests,libcoap/tests --timeout 120 --out Xml - - id: cov-report - name: Produce the coverage report - uses: pulsastrix/coverage-action@always_generate_comment_body - with: - path: ./cobertura.xml - threshold: 80.0 - fail: false - publish: false - diff: true - togglable-report: true - coverage-summary-title: "Code Coverage Report" - - pr-comment: - name: pr-comment - runs-on: ubuntu-latest - if: ${{ always() && github.event_name == 'pull_request' }} - needs: [ lint, coverage ] - env: - LINT_OUTPUT: ${{ needs.lint.result }} - COV_OUTPUT: ${{ needs.coverage.outputs.report }} - steps: - - name: "Generate Markdown Report" - run: | - # Snippet taken from https://github.com/marocchino/sticky-pull-request-comment#append-after-comment-every-time-it-runs - EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) - echo "report<<$EOF" >> "$GITHUB_ENV" - echo "# Workflow Status Report" >> "$GITHUB_ENV" - echo "Generated for commit ${{ github.sha }} on `date -u`." >> "$GITHUB_ENV" - echo "" >> "$GITHUB_ENV" - echo "[![CI Status](https://github.com/namib-project/libcoap-rs/actions/workflows/ci.yml/badge.svg?branch=${GITHUB_HEAD_REF})](https://github.com/namib-project/libcoap-rs/actions/workflows/ci.yml?query=branch%3A${GITHUB_HEAD_REF})" >> "$GITHUB_ENV" - echo "" >> "$GITHUB_ENV" - echo "## Linting Report" >> "$GITHUB_ENV" - echo "" >> "$GITHUB_OUTPUT" - echo "Clippy check result: $LINT_OUTPUT" >> "$GITHUB_ENV" - echo "" >> "$GITHUB_ENV" - echo "Refer to [the \"Files Changed\" tab](./${{ github.event.number }}/files/) for identified issues." >> "$GITHUB_ENV" - echo "" >> "$GITHUB_ENV" - echo "$COV_OUTPUT" >> "$GITHUB_ENV" - echo "$EOF" >> "$GITHUB_ENV" - - if: github.event_name == 'pull_request' - uses: marocchino/sticky-pull-request-comment@v2 - with: - message: ${{ env.report }} diff --git a/.github/workflows/report.yml b/.github/workflows/report.yml new file mode 100644 index 00000000..bbc31e00 --- /dev/null +++ b/.github/workflows/report.yml @@ -0,0 +1,224 @@ +name: Docs, Coverage Report and PR updates + +# WARNING: This Workflow is executed with the workflow_run trigger, which means that +# it is run in the context of the target/upstream repository and granted *write access* +# to the target/upstream repository. +# It *should only* be used for actions that require write access (e.g., to generate/deploy +# the documentation/coverage report to GitHub Pages or to create a PR comment) and *must +# never* execute code contained in the repository. + +on: + workflow_run: + workflows: ["Test and Analyze"] + types: + - completed + + +env: + CARGO_TERM_COLOR: always + RUST_TEST_TIME_UNIT: 60,120 + RUST_TEST_TIME_INTEGRATION: 60,120 + RUST_TEST_TIME_DOCTEST: 60,120 + BRANCH: |- + ${{ + (github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login) + && format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch) + || github.event.workflow_run.head_branch + }} + HEAD_REF: ${{ github.event.workflow_run.head_sha }} + REPO_URL: "${{ github.server_url }}/${{ github.repository }}" + +concurrency: + # env context is not available here, so i just copied the code for env.BRANCH. + group: ${{ github.workflow }}-${{ + (github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login) + && format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch) + || github.event.workflow_run.head_branch + }} + cancel-in-progress: true + +jobs: + + docs: + runs-on: ubuntu-latest + outputs: + docs_dl: ${{ format('{0}/actions/runs/{1}/artifacts/{2}', env.REPO_URL, github.run_id, steps.upload-docs.outputs.artifact-id) }} + docs_url: |- + ${{ + (github.event.workflow_run.head_repository.owner.login == github.event.workflow_run.repository.owner.login) + && format('{0}/docs/{1}/libcoap_rs/', vars.DOCS_AND_COV_URL, env.BRANCH) + || '' + }} + steps: + - uses: actions/checkout@v4 + with: + submodules: true + ref: ${{ env.HEAD_REF }} + # --all-features uses GNUTLS as backend, must provide it. + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: libgnutls28-dev libgnutls30 + version: 1.0 + - uses: dtolnay/rust-toolchain@nightly + with: + components: rustc + - name: Build documentation + run: cargo doc --all-features --no-deps --workspace + - uses: actions/upload-artifact@v4 + id: upload-docs + with: + name: docs + path: | + ./target/doc + # Deploy to GitHub Pages only if the PR is not from a forked repository. + # For security reasons, we don't want PRs from forks to upload coverage data to our GitHub Pages. + - if: ${{ github.event.workflow_run.head_repository.owner.login == github.event.workflow_run.repository.owner.login }} + uses: peaceiris/actions-gh-pages@v4 + with: + publish_dir: ./target/doc + publish_branch: main + external_repository: ${{ vars.DOCS_AND_COV_REPO }} + personal_token: ${{ secrets.DOCS_AND_COV_REPO_TOKEN }} + destination_dir: docs/${{ env.BRANCH }} + + coverage-report: + name: coverage-report + runs-on: ubuntu-latest + env: + LLVM_PROFILE_FILE: './coverage-data/coverage/libcoap-rs-%p-%m.profraw' + outputs: + report: ${{ steps.cov-report.outputs.summary }} + report_dl: ${{ format('{0}/actions/runs/{1}/artifacts/{2}', env.REPO_URL, github.run_id, steps.upload-cov-report.outputs.artifact-id) }} + report_url: |- + ${{ + (github.event.workflow_run.head_repository.owner.login == github.event.workflow_run.repository.owner.login) + && format('{0}/coverage/{1}', vars.DOCS_AND_COV_URL, env.BRANCH) + || '' + }} + badge_url: ${{ format('{0}/coverage/{1}/badges/flat.svg', vars.DOCS_AND_COV_URL, env.BRANCH) }} + permissions: + actions: write + contents: write + steps: + - uses: actions/checkout@v4 + with: + submodules: true + ref: ${{ env.HEAD_REF }} + - uses: actions/download-artifact@v4 + with: + pattern: test-coverage-data-* + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + merge-multiple: true + path: coverage-data + - uses: dtolnay/rust-toolchain@nightly + with: + components: llvm-tools, llvm-tools-preview + - uses: baptiste0928/cargo-install@v3 + with: + crate: grcov + - run: mkdir -p ./coverage + - run: grcov coverage-data/coverage/ -s . --binary-path ./coverage-data/test-binaries --commit-sha ${GITHUB_SHA} --ignore-not-existing --ignore "/*" -t markdown,html --branch --log-level TRACE -o ./coverage/ + - id: cov-report + name: "Set coverage report as job output" + run: | + EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) + { + echo "summary<<$EOF" + cat ./coverage/markdown.md + echo "$EOF" + } >> "$GITHUB_OUTPUT" + - uses: actions/upload-artifact@v4 + id: upload-cov-report + with: + name: coverage-report + path: | + ./coverage + # Deploy to GitHub Pages only if the PR is not from a forked repository. + # For security reasons, we don't want PRs from forks to upload coverage data to our GitHub Pages. + - if: ${{ github.event.workflow_run.head_repository.owner.login == github.event.workflow_run.repository.owner.login }} + uses: peaceiris/actions-gh-pages@v4 + with: + publish_dir: ./coverage/html + publish_branch: main + external_repository: ${{ vars.DOCS_AND_COV_REPO }} + personal_token: ${{ secrets.DOCS_AND_COV_REPO_TOKEN }} + destination_dir: coverage/${{ env.BRANCH }} + # For PRs from forks, only upload the generated badge. + - if: ${{ github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login }} + uses: peaceiris/actions-gh-pages@v4 + with: + publish_dir: ./coverage/html/badges + publish_branch: main + external_repository: ${{ vars.DOCS_AND_COV_REPO }} + personal_token: ${{ secrets.DOCS_AND_COV_REPO_TOKEN }} + destination_dir: coverage/${{ env.BRANCH }}/badges + + pr-comment: + name: pr-comment + runs-on: ubuntu-latest + # All other jobs here should also run on a push to main. This one is specific to pull requests, however. + if: ${{ always() && github.event.workflow_run.event == 'pull_request' }} + needs: [ coverage-report, docs ] + env: + COV_OUTPUT: ${{ needs.coverage-report.outputs.report }} + COV_DL: ${{ needs.coverage-report.outputs.report_dl }} + COV_BADGE: ${{ needs.coverage-report.outputs.badge_url }} + DOCS_DL: ${{ needs.docs.outputs.docs_dl }} + COV_URL: ${{ needs.coverage-report.outputs.report_url }} + DOCS_URL: ${{ needs.docs.outputs.docs_url }} + # Token required for GH CLI: + GH_TOKEN: ${{ github.token }} + # Best practice for scripts is to reference via ENV at runtime. Avoid using the expression syntax in the script content directly: + PR_TARGET_REPO: ${{ github.repository }} + steps: + - uses: actions/checkout@v4 + with: + submodules: false + # See https://github.com/orgs/community/discussions/25220#discussioncomment-11316244 + - name: 'Get PR context' + id: pr-context + # Query the PR number by repo + branch, then assign to step output: + run: | + gh pr view --repo "${PR_TARGET_REPO}" "${BRANCH}" \ + --json 'number' --jq '"number=\(.number)"' \ + >> "${GITHUB_OUTPUT}" + - name: "Generate Markdown Report" + run: | + # Snippet taken from https://github.com/marocchino/sticky-pull-request-comment#append-after-comment-every-time-it-runs + EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) + { + echo "report<<$EOF" + echo "# Workflow Status Report" + echo "Generated for commit ${{ github.sha }} on `date -u`." + echo "" + echo "[![Test and Analyze](${REPO_URL}/actions/workflows/test.yml/badge.svg?branch=${GITHUB_HEAD_REF}&hash=${{ github.sha }})](${REPO_URL}/actions/workflows/test.yml?query=branch%3A${BRANCH})" + echo "[![Docs, Coverage Report and PR Updates](${REPO_URL}/actions/workflows/report.yml/badge.svg?branch=${GITHUB_HEAD_REF}&hash=${{ github.sha }})](${REPO_URL}/actions/workflows/report.yml?query=branch%3A${BRANCH})" + echo "" + echo "In case of failure, clippy warnings and rustfmt changes (if any) will be indicated as CI check warnings in the file comparison view." + echo "" + echo "Documentation: ${{ (env.DOCS_URL != '') && format('[Read Online]({0})', env.DOCS_URL) || '' }} [Download](${DOCS_DL})" + echo "" + echo "Coverage Report: ${{ (env.COV_URL != '') && format('[Read Online]({0})', env.COV_URL) || '' }} [Download](${COV_DL})" + echo "" + echo "Note: Online versions of documentation and coverage reports may not be available indefinitely, especially after the pull request was merged." + echo "" + echo "## Code Coverage Report" + echo "[![Coverage](${COV_BADGE}?hash=${{ github.sha }})](${{ (env.COV_URL == '') && env.COV_DL || env.COV_URL}})" + echo "" + echo "Coverage target is 80%." + echo "" + echo "Click on the coverage badge to access the full coverage report including a source code view." + echo "" + echo "
" + echo "Expand to view coverage statistics" + echo "" + echo "$COV_OUTPUT" + echo "
" + echo "$EOF" + } >> "$GITHUB_ENV" + + - uses: marocchino/sticky-pull-request-comment@v2 + with: + message: ${{ env.report }} + number: ${{ steps.pr-context.outputs.number }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..8a821aba --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,99 @@ +name: Test and Analyze + +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + CARGO_TERM_COLOR: always + RUST_TEST_TIME_UNIT: 60,120 + RUST_TEST_TIME_INTEGRATION: 60,120 + RUST_TEST_TIME_DOCTEST: 60,120 + +jobs: + test: + name: test + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + crate: [ libcoap-sys, libcoap-rs ] + dtls_backend: [ openssl, gnutls, tinydtls, mbedtls ] + rust_version: [ msrv, stable, nightly ] + env: + LLVM_PROFILE_FILE: "${{ github.workspace }}/coverage-data/coverage/libcoap-rs-%p-%m.profraw" + RUSTFLAGS: "${{ matrix.rust_version == 'nightly' && '-Cinstrument-coverage -Cpanic=abort -Zpanic_abort_tests' || ' ' }}" + RUSTDOCFLAGS: "${{ matrix.rust_version == 'nightly' && '-C instrument-coverage -Cpanic=abort -Zpanic_abort_tests -Z unstable-options --persist-doctests target/debug/doctests' || ' ' }}" + LIBRARY_FEATURES: | + ${{ (matrix.crate == 'libcoap-rs' && 'tcp,vendored,rand') + || (matrix.crate == 'libcoap-sys' && 'default') + || 'vendored' + }} + DTLS_LIBRARY_FEATURES: | + ${{ (matrix.crate == 'libcoap-rs' && matrix.dtls_backend == 'tinydtls' && 'tcp,dtls-psk,dtls-rpk,dtls_tinydtls_vendored') + || (matrix.crate == 'libcoap-rs' && matrix.dtls_backend == 'mbedtls' && 'tcp,dtls-psk,dtls-pki,dtls_mbedtls_vendored') + || (matrix.crate == 'libcoap-rs' && matrix.dtls_backend == 'openssl' && 'tcp,dtls-psk,dtls-pki,dtls_openssl_vendored') + || (matrix.crate == 'libcoap-rs' && matrix.dtls_backend == 'gnutls' && 'tcp,dtls-psk,dtls-pki,dtls-rpk,dtls_gnutls') + || (matrix.crate == 'libcoap-sys' && matrix.dtls_backend == 'tinydtls' && 'dtls,dtls_backend_tinydtls,dtls_backend_tinydtls_vendored') + || (matrix.crate == 'libcoap-sys' && matrix.dtls_backend == 'mbedtls' && 'dtls,dtls_backend_mbedtls,dtls_backend_mbedtls_vendored') + || (matrix.crate == 'libcoap-sys' && matrix.dtls_backend == 'openssl' && 'dtls,dtls_backend_openssl,dtls_backend_openssl_vendored') + || (matrix.crate == 'libcoap-sys' && matrix.dtls_backend == 'gnutls' && 'dtls,dtls_backend_gnutls') + || 'vendored' + }} + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: dtolnay/rust-toolchain@stable + with: + components: rust-src, rustc, rust-std, cargo, llvm-tools, llvm-tools-preview + toolchain: ${{ matrix.rust_version == 'msrv' && '1.81' || matrix.rust_version }} + - if: matrix.dtls_backend == 'gnutls' + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: libgnutls28-dev libgnutls30 + version: 1.0 + - run: cargo test -p ${{ matrix.crate }} --no-default-features --features "$LIBRARY_FEATURES" --features "$DTLS_LIBRARY_FEATURES" --no-fail-fast + - if: matrix.rust_version == 'nightly' + run: | + mkdir -p coverage-data/test-binaries + mkdir -p target/debug/doctests + cp $(cargo test -p ${{ matrix.crate }} --no-run --message-format=json --no-default-features --features "$LIBRARY_FEATURES" --features "$DTLS_LIBRARY_FEATURES" --no-fail-fast \ + | jq -r "select(.profile.test == true) | .filenames[]" \ + | grep -v dSYM -) coverage-data/test-binaries/ + cp -r target/debug/doctests coverage-data/test-binaries/ + - if: matrix.rust_version == 'nightly' + uses: actions/upload-artifact@v4 + with: + retention-days: 1 + name: test-coverage-data-${{ matrix.crate }}-${{ matrix.dtls_backend }} + path: | + coverage-data/ + + lint: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: reviewdog/action-setup@v1 + with: + reviewdog_version: latest + # Nightly required for rustfmt's --emit=checkstyle argument + - uses: dtolnay/rust-toolchain@nightly + with: + components: clippy, rustfmt + - uses: baptiste0928/cargo-install@v3 + with: + crate: clippy-reviewdog-filter + - name: Run Linter + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + reviewdog -reporter=github-pr-check -fail-level=any + diff --git a/.reviewdog.yml b/.reviewdog.yml new file mode 100644 index 00000000..b87a18eb --- /dev/null +++ b/.reviewdog.yml @@ -0,0 +1,7 @@ +runner: + clippy: + cmd: 'find . -type f -name \*.rs -exec touch {} \;; cargo clippy --message-format json 2>&1 | clippy-reviewdog-filter' + format: checkstyle + rustfmt: + cmd: 'find . -type f -name \*.rs -exec touch {} \;; cargo fmt -- --emit checkstyle 2>&1' + format: checkstyle diff --git a/README.md b/README.md index 158ba04d..f5d4a6c4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # libcoap-rs -[![CI Status](https://github.com/namib-project/libcoap-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/namib-project/libcoap-rs/actions/workflows/ci.yml) -![Coverage](https://raw.githubusercontent.com/namib-project/libcoap-rs/_xml_coverage_reports/data/main/badge.svg) +[![latest release on crates.io](https://img.shields.io/crates/v/libcoap_rs)](https://crates.io/crates/libcoap-rs) +[![Documentation (latest release)](https://img.shields.io/badge/docs-latest_release-blue)](https://docs.rs/libcoap_rs/) +[![Documentation (main)](https://img.shields.io/badge/docs-main-blue)](https://namib-project.github.io/libcoap-rs-docs/docs/main/libcoap_rs/) +[![Test and Analyze CI Status](https://github.com/namib-project/libcoap-rs/actions/workflows/test.yml/badge.svg)](https://github.com/namib-project/libcoap-rs/actions/workflows/test.yml) +[![Coverage (main)](https://namib-project.github.io/libcoap-rs-docs/coverage/main/badges/flat.svg)](https://namib-project.github.io/libcoap-rs-docs/coverage/main/) Raw binding and safe wrapper for the [libcoap CoAP libary](https://github.com/obgm/libcoap). diff --git a/libcoap-sys/Cargo.toml b/libcoap-sys/Cargo.toml index ae4ceaba..769576b4 100644 --- a/libcoap-sys/Cargo.toml +++ b/libcoap-sys/Cargo.toml @@ -18,6 +18,8 @@ categories = ["external-ffi-bindings", "network-programming", "embedded"] keywords = ["coap", "libcoap"] exclude = ["src/libcoap/ext/"] resolver = "2" +# Current reason for MSRV (please update when increasing MSRV): Transient dependency "home" requires Rust 1.81. +rust-version = "1.81.0" [features] # The default features match those of libcoaps configure script, except for dtls, which is disabled here because it diff --git a/libcoap-sys/README.md b/libcoap-sys/README.md index b334dfa8..37bfa91c 100644 --- a/libcoap-sys/README.md +++ b/libcoap-sys/README.md @@ -1,4 +1,9 @@ # libcoap-sys - Raw bindings for libcoap +[![latest release on crates.io](https://img.shields.io/crates/v/libcoap_sys)](https://crates.io/crates/libcoap-sys) +[![Documentation (latest release)](https://img.shields.io/badge/docs-latest_release-blue)](https://docs.rs/libcoap_sys/) +[![Documentation (main)](https://img.shields.io/badge/docs-main-blue)](https://namib-project.github.io/libcoap-rs-docs/docs/main/libcoap_sys/) +[![Test and Analyze CI Status](https://github.com/namib-project/libcoap-rs/actions/workflows/test.yml/badge.svg)](https://github.com/namib-project/libcoap-rs/actions/workflows/test.yml) +[![Coverage (main)](https://namib-project.github.io/libcoap-rs-docs/coverage/main/badges/flat.svg)](https://namib-project.github.io/libcoap-rs-docs/coverage/main/) This crate contains raw unsafe bindings for the [libcoap CoAP libary](https://github.com/obgm/libcoap), which are generated using bindgen. diff --git a/libcoap/Cargo.toml b/libcoap/Cargo.toml index 6087048c..0949d459 100644 --- a/libcoap/Cargo.toml +++ b/libcoap/Cargo.toml @@ -16,6 +16,8 @@ authors = ["Hugo Hakim Damer "] categories = ["api-bindings", "network-programming", "embedded"] keywords = ["coap", "libcoap"] resolver = "2" +# Current reason for MSRV (please update when increasing MSRV): Transient dependency "home" requires Rust 1.81. +rust-version = "1.81.0" [features] default = ["dtls-psk", "tcp", "dtls_openssl", "vendored", "libcoap-sys/default"] diff --git a/libcoap/README.md b/libcoap/README.md deleted file mode 100644 index fc458407..00000000 --- a/libcoap/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# libcoap-rs - -Idiomatic wrapper around the [libcoap CoAP libary](https://github.com/obgm/libcoap) for Rust. - -## License - -Matching the license of the libcoap C library, the libcoap crate is licensed under the -2-Clause/Simplified BSD License ([LICENSE-BSD-2-Clause](LICENSE-BSD-2-CLAUSE) -or https://opensource.org/licenses/BSD-2-Clause). - -### Note on Third-Party-Code - -Note that for the libcoap-sys binding and generated binaries, the license terms of the libcoap C library as well as -linked dependencies (e.g. TLS libraries) may apply. -See https://github.com/obgm/libcoap/blob/develop/LICENSE as well as the licenses of dependency crates for more -information and terms. - -## Contribution - -Unless you explicitly state otherwise, any contribution intentionally submitted -for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions. - -## Maintainers - -This project is currently maintained by the following developers: - -| Name | Email Address | GitHub Username | -|:----------------:|:--------------------:|:--------------------------------------------:| -| Hugo Hakim Damer | hdamer@uni-bremen.de | [@pulsastrix](https://github.com/pulsastrix) | diff --git a/libcoap/README.md b/libcoap/README.md new file mode 120000 index 00000000..32d46ee8 --- /dev/null +++ b/libcoap/README.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/libcoap/src/context.rs b/libcoap/src/context.rs index 48dcd1ec..c8be5ec1 100644 --- a/libcoap/src/context.rs +++ b/libcoap/src/context.rs @@ -395,7 +395,7 @@ impl CoapContext<'_> { // } /// Adds the given resource to the resource pool of this context. - pub fn add_resource(&mut self, res: CoapResource) { + pub fn add_resource(&mut self, res: CoapResource) { let mut inner_ref = self.inner.borrow_mut(); inner_ref.resources.push(Box::new(res)); // SAFETY: raw context is valid, raw resource is also guaranteed to be valid as long as diff --git a/rustfmt.toml b/rustfmt.toml index 15d5661b..a5f6a4a0 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -25,4 +25,4 @@ group_imports = "StdExternalCrate" reorder_impl_items = true # Determines if + or = are wrapped in spaces in the punctuation of types -type_punctuation_density = "Compressed" +type_punctuation_density = "Wide"