Trait rdkafka::message::Headers

source ·
pub trait Headers {
    // Required methods
    fn count(&self) -> usize;
    fn try_get(&self, idx: usize) -> Option<Header<'_, &[u8]>>;

    // Provided methods
    fn get(&self, idx: usize) -> Header<'_, &[u8]> { ... }
    fn get_as<V>(&self, idx: usize) -> Result<Header<'_, &V>, V::Error>
       where V: FromBytes + ?Sized { ... }
    fn try_get_as<V>(
        &self,
        idx: usize
    ) -> Option<Result<Header<'_, &V>, V::Error>>
       where V: FromBytes + ?Sized { ... }
    fn iter(&self) -> HeadersIter<'_, Self> 
       where Self: Sized { ... }
}
Expand description

A generic representation of Kafka message headers.

This trait represents 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§

source

fn count(&self) -> usize

Returns the number of contained headers.

source

fn try_get(&self, idx: usize) -> Option<Header<'_, &[u8]>>

Like Headers::get, but returns an option if the header is out of bounds rather than panicking.

Provided Methods§

source

fn get(&self, idx: usize) -> Header<'_, &[u8]>

Gets the specified header, where the first header corresponds to index 0.

Panics if the index is out of bounds.

source

fn get_as<V>(&self, idx: usize) -> Result<Header<'_, &V>, V::Error>
where V: FromBytes + ?Sized,

Like Headers::get, but the value of the header will be converted to the specified type.

Panics if the index is out of bounds.

source

fn try_get_as<V>(&self, idx: usize) -> Option<Result<Header<'_, &V>, V::Error>>
where V: FromBytes + ?Sized,

Like Headers::get, but returns an option if the header is out of bounds rather than panicking.

source

fn iter(&self) -> HeadersIter<'_, Self>
where Self: Sized,

Iterates over all headers in order.

Object Safety§

This trait is not object safe.

Implementors§