madsim_rdkafka::message

Trait 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§