Function rust_multicodec::codec_prefix::remove [] [src]

pub fn remove<'a>(data: &'a [u8]) -> &'a [u8]

Removes the codec prefix and returns the raw data.

Arguments

  • data - the data with prefix

Example

extern crate rust_multicodec;
extern crate hex_slice;

use rust_multicodec::codec_prefix;
use rust_multicodec::codec::CodecType;
use hex_slice::AsHex;
use std::process;

fn main(){
    let data="Live long and prosper";

    let prefixed=codec_prefix::add(CodecType::JSON,data.as_bytes()).unwrap();
    let raw_data=codec_prefix::remove(prefixed.as_slice());
    println!("Original data was {:?}", String::from_utf8(raw_data.to_vec()).unwrap())
    // it will print return "Original data was Live long and prosper"
}