Crates.io | cid |
lib.rs | cid |
version | 0.11.1 |
source | src |
created_at | 2017-01-29 12:59:40.447695 |
updated_at | 2024-03-01 12:21:20.669147 |
description | CID in rust |
homepage | https://github.com/multiformats/rust-cid |
repository | |
max_upload_size | |
id | 8284 |
size | 45,619 |
CID implementation in Rust.
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
.
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
Captain: @dignifiedquire.
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.
MIT © 2017 Friedel Ziegelmayer