Skip to main content

to_encoded_byte_len

Function to_encoded_byte_len 

Source
pub fn to_encoded_byte_len<T: TraceData, S: AsRef<[Span<T>]>>(
    traces: &[S],
) -> u32
Expand description

Computes the number of bytes required to encode the given traces.

This does not allocate any actual buffer, but simulates writing in order to measure the encoded size of the traces.

§Arguments

  • traces - A reference to a slice of spans.

§Returns

  • u32 - The number of bytes that would be written by the encoder.

§Examples

use libdd_trace_utils::msgpack_encoder::v04::to_encoded_byte_len;
use libdd_trace_utils::span::v04::SpanSlice;

let span = SpanSlice {
    name: "test-span".into(),
    ..Default::default()
};
let traces = vec![vec![span]];
let encoded_len = to_encoded_byte_len(&traces);

assert!(encoded_len > 0);