Function rust_multicodec::get_codec
[−]
[src]
pub fn get_codec(data: &[u8]) -> Result<Option<&'static str>, &'static str>
Returns the codec's code the data was prefixed with.
Arguments
data
- the data with prefix
Example
extern crate rust_multicodec; extern crate hex_slice; use hex_slice::AsHex; use std::process; fn main(){ let data="Live long and prosper"; let prefixed=rust_multicodec::add_prefix("base1",data.as_bytes()).unwrap(); println!("{}",rust_multicodec::get_codec(prefixed.as_slice()).unwrap().unwrap()); // it will print "base1" }