Skip to main content

parse_dcbor_item_partial

Function parse_dcbor_item_partial 

Source
pub fn parse_dcbor_item_partial(src: &str) -> Result<(CBOR, usize)>
Expand description

Parses a dCBOR item from the beginning of a string and returns the parsed CBOR along with the number of bytes consumed.

Unlike parse_dcbor_item, this function succeeds even if additional characters follow the first item. The returned index points to the first unparsed character after skipping any trailing whitespace or comments.

ยงExample

let (cbor, used) = parse_dcbor_item_partial("true )").unwrap();
assert_eq!(cbor, CBOR::from(true));
assert_eq!(used, 5);