pub fn decode_to_trace_chunks(
data: Bytes,
encoding_type: TraceEncoding,
) -> Result<(TraceChunks<BytesData>, usize), Error>Expand description
This method processes the msgpack data contained within data based on
the specified encoding_type, converting it into a collection of tracer payloads.
Note: Currently only the TraceEncoding::V04 and TraceEncoding::V05 encoding types are
supported.
§Returns
A Result containing either the successfully converted TraceChunks and the length consummed
from the data or an error if the conversion fails. Possible errors include issues with
deserializing the msgpack data or if the data does not conform to the expected format.
§Examples
use libdd_tinybytes;
use libdd_trace_protobuf::pb;
use libdd_trace_utils::trace_utils::TracerHeaderTags;
use libdd_trace_utils::tracer_payload::{decode_to_trace_chunks, TraceEncoding};
use std::convert::TryInto;
// This will likely be a &[u8] slice in practice.
let data: Vec<u8> = Vec::new();
let data_as_bytes = libdd_tinybytes::Bytes::from(data);
let result = decode_to_trace_chunks(data_as_bytes, TraceEncoding::V04)
.map(|(chunks, _size)| chunks.into_tracer_payload_collection());
match result {
Ok(collection) => println!("Successfully converted to TracerPayloadCollection."),
Err(e) => println!("Failed to convert: {:?}", e),
}