diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 885ef18..191a249 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -2,9 +2,9 @@ name: Rust on: push: - branches: ["main"] + branches: ["master"] pull_request: - branches: ["main"] + branches: ["master"] env: CARGO_TERM_COLOR: always @@ -33,9 +33,6 @@ jobs: - name: Run tests run: cargo test --verbose --all-features - - name: Documentation - run: cargo doc --all-features - msrv: name: Verify MSRV (1.85) runs-on: ubuntu-latest @@ -47,4 +44,60 @@ jobs: uses: dtolnay/rust-toolchain@1.85.0 - name: Check - run: cargo check --all-features \ No newline at end of file + run: cargo check --all-features + + ensure_no_std: + name: Ensure no_std + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install Rust Toolchain (nightly) + uses: dtolnay/rust-toolchain@nightly + with: + targets: thumbv6m-none-eabi + + - name: Build (no_std) + run: cargo build --no-default-features --target thumbv6m-none-eabi + shell: bash + + coverage: + name: Coverage + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install Rust Toolchain (stable) + uses: dtolnay/rust-toolchain@stable + with: + components: llvm-tools-preview + + - name: Install cargo-llvm-cov + run: cargo install cargo-llvm-cov + + - name: Run coverage + run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + files: lcov.info + fail_ci_if_error: false + + audit: + name: Security Audit + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install Rust Toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Install cargo-audit + run: cargo install cargo-audit + + - name: Run cargo audit + run: cargo audit diff --git a/Cargo.toml b/Cargo.toml index f75a9d1..a80dec5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,16 +17,16 @@ dag_cbor = ["dep:multi-cbor", "multi-cbor/tags"] [dependencies] multi-base = { version = "1.0", default-features = false } -multi-codec = "1.1" -multi-hash = "1.0" -multi-trait = { version = "1.0.5", default-features = false } +multi-cbor = { version = "0.1", optional = true } +multi-codec = "1.2" +multi-hash = "1.1" +multi-trait = { version = "1.0", default-features = false } multi-util = "1.1" thiserror = "2.0" serde = { version = "1.0", default-features = false, features = [ "alloc", "derive", ], optional = true } -multi-cbor = { version = "0.1", optional = true } [dev-dependencies] criterion = "0.8" diff --git a/src/cid.rs b/src/cid.rs index 7216887..66186b2 100644 --- a/src/cid.rs +++ b/src/cid.rs @@ -4,7 +4,7 @@ use core::fmt; use multi_base::Base; use multi_codec::Codec; use multi_hash::Multihash; -use multi_trait::{EncodeInto, Null, TryDecodeFrom}; +use multi_trait::{EncodeInto, EncodeIntoBuffer, Null, TryDecodeFrom}; use multi_util::{ Base58Encoder, BaseEncoded, BaseEncoder, CodecInfo, DetectedEncoder, EncodingInfo, }; @@ -135,6 +135,12 @@ impl EncodeInto for Cid { } } +impl EncodeIntoBuffer for Cid { + fn encode_into_buffer(&self, buffer: &mut Vec) { + buffer.extend_from_slice(&self.clone().encode_into()); + } +} + impl<'a> TryFrom<&'a [u8]> for Cid { type Error = Error;