pub fn export_from_reader<R: Read, W: Write>(
format: &str,
delimiter: &str,
pretty: bool,
reader: R,
writer: &mut W,
) -> Result<()>Expand description
Convert a stream of CBOR bytes into a stream of some other format.
Each top-level CBOR item is decoded and re-serialized to format, with
delimiter written between items. The input is streamed one item at a
time and never buffered.
§Arguments
format: one of"json","yaml","toml","cbor".delimiter: bytes written between consecutive items (e.g."\n"). An empty input produces no output and no delimiter.pretty: if true andformatis"json", use pretty-printed output.reader: the CBOR input stream. Supports CBOR sequences (RFC 8742).writer: the output sink.
§Example
use cbor_cli::export::export_from_reader;
// CBOR for the integer 42.
let cbor = [0x18, 0x2a];
let mut json = Vec::new();
export_from_reader("json", "\n", false, &cbor[..], &mut json).unwrap();
assert_eq!(json, b"42");