Function bread_cli::convert

source ·
pub fn convert(
    istream: Box<dyn Iterator<Item = Result<u8, InError>> + '_>,
    ostream: Box<dyn ByteWriter + '_>
) -> Result<(), Error>
Expand description

Converts byte input stream format to byte output stream format

Iterates on bytes in istream and writes them to ostream.

Errors

see ErrorType for error details.

Examples

binary to hexadecimal conversion

use bread_cli::*;
const _0: u8 = '0' as u8;
const _1: u8 = '1' as u8;
const _4: u8 = '4' as u8;
const _5: u8 = '5' as u8;
const _A: u8 = 'a' as u8;
const _F: u8 = 'f' as u8;

let input = [ _0, _1, _0, _0, _1, _0, _1, _0, _0, _1, _0, _1, _1, _1, _1, _1, ];
let mut output = [0u8; 4];
let reader = Box::new(binary::Reader::new(input.as_slice()));
let writer = Box::new(hexadecimal::Writer::new(output.as_mut_slice()));
convert(reader, writer).unwrap();
assert_eq!([_4, _A, _5, _F], output);