[][src]Trait rdkafka::message::Headers

pub trait Headers {
    fn count(&self) -> usize;
fn get(&self, idx: usize) -> Option<(&str, &[u8])>; fn get_as<V: FromBytes + ?Sized>(
        &self,
        idx: usize
    ) -> Option<(&str, Result<&V, V::Error>)> { ... } }

Message headers trait

A trait to represent readable message headers. Headers are key-value pairs that can be sent alongside every message. Only read-only methods are provided by this trait, as the underlying storage might not allow modification.

Required methods

fn count(&self) -> usize

Return the number of defined headers.

fn get(&self, idx: usize) -> Option<(&str, &[u8])>

Get the specified header (the first header corresponds to index 0). If the index is out of bounds, None is returned.

Loading content...

Provided methods

fn get_as<V: FromBytes + ?Sized>(
    &self,
    idx: usize
) -> Option<(&str, Result<&V, V::Error>)>

Same as Headers::get, but the value of the header will be converted to the specified type. If the conversion fails, an error will be returned instead.

Loading content...

Implementors

impl Headers for BorrowedHeaders[src]

fn get_as<V: FromBytes + ?Sized>(
    &self,
    idx: usize
) -> Option<(&str, Result<&V, V::Error>)>
[src]

impl Headers for OwnedHeaders[src]

fn get_as<V: FromBytes + ?Sized>(
    &self,
    idx: usize
) -> Option<(&str, Result<&V, V::Error>)>
[src]

Loading content...