Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 59 additions & 6 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Rust

on:
push:
branches: ["main"]
branches: ["master"]
pull_request:
branches: ["main"]
branches: ["master"]

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -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
Expand All @@ -47,4 +44,60 @@ jobs:
uses: dtolnay/rust-toolchain@1.85.0

- name: Check
run: cargo check --all-features
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
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion src/cid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -135,6 +135,12 @@ impl EncodeInto for Cid {
}
}

impl EncodeIntoBuffer for Cid {
fn encode_into_buffer(&self, buffer: &mut Vec<u8>) {
buffer.extend_from_slice(&self.clone().encode_into());
}
}

impl<'a> TryFrom<&'a [u8]> for Cid {
type Error = Error;

Expand Down
Loading