Type Alias rust_ipfs::Block

source ·
pub type Block = Block<DefaultParams>;

Aliased Type§

struct Block { /* private fields */ }

Methods from Deref<Target = Cid<64>>§

pub fn version(&self) -> Version

Returns the cid version.

pub fn codec(&self) -> u64

Returns the cid codec.

pub fn hash(&self) -> &Multihash<S>

Returns the cid multihash.

pub fn write_bytes<W>(&self, w: W) -> Result<usize, Error>where W: Write,

Writes the bytes to a byte stream, returns the number of bytes written.

pub fn encoded_len(&self) -> usize

Returns the length in bytes needed to encode this cid into bytes.

pub fn to_bytes(&self) -> Vec<u8, Global>

Returns the encoded bytes of the Cid.

pub fn to_string_of_base(&self, base: Base) -> Result<String, Error>

Convert CID into a multibase encoded string

Example
use cid::Cid;
use multibase::Base;
use multihash::{Code, MultihashDigest};

const RAW: u64 = 0x55;

let cid = Cid::new_v1(RAW, Code::Sha2_256.digest(b"foo"));
let encoded = cid.to_string_of_base(Base::Base64).unwrap();
assert_eq!(encoded, "mAVUSICwmtGto/8aP+ZtFPB0wQTQTQi1wZIO/oPmKXohiZueu");

Trait Implementations§

source§

impl<S> Deref for Block<S>

§

type Target = Cid<64>

The resulting type after dereferencing.
source§

fn deref(&self) -> &<Block<S> as Deref>::Target

Dereferences the value.