Skip to main content

extract_from_headers

Function extract_from_headers 

Source
pub fn extract_from_headers<'a, I, V>(headers: I) -> Option<Hlc>
where I: IntoIterator<Item = (&'a str, V)>, V: AsRef<[u8]>,
Expand description

The stamp on a record, or None when the record carries none.

Each header is a key plus a raw byte value, so this function works with any producer or consumer header type. The caller converts its own Header into a (key, value) pair at the edge.

This function returns None for an absent header, for a value of the wrong length, and for a value it cannot read. It reports no error, because a consumer that cannot read the producer’s stamp must still be able to apply the record. Use Hlc::decode where the caller wants the reason.

A record can carry the same header key more than once, and Kafka’s own Headers.lastHeader reads the last one. This function does the same.