28 releases

0.11.1 Mar 1, 2024
0.11.0 Nov 15, 2023
0.10.1 Jan 9, 2023
0.10.0 Dec 22, 2022
0.2.1 Feb 20, 2017

#57 in Network programming

Download history 16663/week @ 2023-12-23 24279/week @ 2023-12-30 36123/week @ 2024-01-06 43718/week @ 2024-01-13 44558/week @ 2024-01-20 43514/week @ 2024-01-27 45899/week @ 2024-02-03 46532/week @ 2024-02-10 52533/week @ 2024-02-17 47632/week @ 2024-02-24 43928/week @ 2024-03-02 44076/week @ 2024-03-09 45604/week @ 2024-03-16 44429/week @ 2024-03-23 54976/week @ 2024-03-30 62562/week @ 2024-04-06

214,337 downloads per month
Used in 420 crates (157 directly)

MIT license

33KB
618 lines

rust-cid

Build Status Crates.io License Documentation Dependency Status Coverage Status

CID implementation in Rust.

Table of Contents

Usage

use multihash_codetable::{Code, MultihashDigest};
use cid::Cid;
use std::convert::TryFrom;

const RAW: u64 = 0x55;

fn main() {
    let h = Code::Sha2_256.digest(b"beep boop");

    let cid = Cid::new_v1(RAW, h);

    let data = cid.to_bytes();
    let out = Cid::try_from(data).unwrap();

    assert_eq!(cid, out);

    let cid_string = cid.to_string();
    assert_eq!(
        cid_string,
        "bafkreieq5jui4j25lacwomsqgjeswwl3y5zcdrresptwgmfylxo2depppq"
    );
    println!("{}", cid_string);
}

Your Cargo.toml needs these dependencies:

[dependencies]
cid = "0.7.0"

You can also run this example from this checkout with cargo run --example readme.

Testing

You can run the tests using this command: cargo test --all-features

You can run the tests for no_std using this command: cargo test --no-default-features

Maintainers

Captain: @dignifiedquire.

Contribute

Contributions welcome. Please check out the issues.

Check out our contributing document for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS Code of Conduct.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © 2017 Friedel Ziegelmayer

Dependencies

~0.4–1.4MB
~25K SLoC