File: readme.rs

package info (click to toggle)
rust-cid 0.10.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 240 kB
  • sloc: makefile: 2
file content (23 lines) | stat: -rw-r--r-- 502 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use cid::Cid;
use multihash_codetable::{Code, MultihashDigest};
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);
}