https://github.com/multiformats/rust-cid
CID in rust
https://github.com/multiformats/rust-cid
cid crate ipld multiformats rust rust-cid
Last synced: about 1 year ago
JSON representation
CID in rust
- Host: GitHub
- URL: https://github.com/multiformats/rust-cid
- Owner: multiformats
- Created: 2017-01-18T21:03:12.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-04-28T17:03:35.000Z (about 1 year ago)
- Last Synced: 2025-04-28T17:38:12.224Z (about 1 year ago)
- Topics: cid, crate, ipld, multiformats, rust, rust-cid
- Language: Rust
- Homepage:
- Size: 913 KB
- Stars: 93
- Watchers: 17
- Forks: 52
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# rust-cid
[](http://ipn.io)
[](https://github.com/multiformats/multiformats)
[](https://webchat.freenode.net/?channels=%23ipfs)
[](https://github.com/RichardLitt/standard-readme)
[](https://github.com/multiformats/rust-cid/actions)
[](https://crates.io/crates/cid)
[](LICENSE)
[](https://docs.rs/cid)
[](https://deps.rs/repo/github/multiformats/rust-cid)
[](https://codecov.io/gh/multiformats/rust-cid)
> [CID](https://github.com/ipld/cid) implementation in Rust.
## Table of Contents
- [Usage](#usage)
- [Testing](#testing)
- [Maintainers](#maintainers)
- [Contribute](#contribute)
- [License](#license)
## Usage
```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:
```toml
[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](https://github.com/dignifiedquire).
## Contribute
Contributions welcome. Please check out [the issues](https://github.com/multiformats/rust-cid/issues).
Check out our [contributing document](https://github.com/multiformats/multiformats/blob/master/contributing.md) 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](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
## License
[MIT](LICENSE) © 2017 Friedel Ziegelmayer