Trait rdkafka_wrap::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 as FromBytes>::Error>
where V: FromBytes + ?Sized { ... }
fn try_get_as<V>(
&self,
idx: usize
) -> Option<Result<Header<'_, &V>, <V as FromBytes>::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§
Provided Methods§
sourcefn get(&self, idx: usize) -> Header<'_, &[u8]>
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.
sourcefn get_as<V>(
&self,
idx: usize
) -> Result<Header<'_, &V>, <V as FromBytes>::Error>where
V: FromBytes + ?Sized,
fn get_as<V>( &self, idx: usize ) -> Result<Header<'_, &V>, <V as FromBytes>::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.
sourcefn try_get_as<V>(
&self,
idx: usize
) -> Option<Result<Header<'_, &V>, <V as FromBytes>::Error>>where
V: FromBytes + ?Sized,
fn try_get_as<V>( &self, idx: usize ) -> Option<Result<Header<'_, &V>, <V as FromBytes>::Error>>where V: FromBytes + ?Sized,
Like Headers::get
, but returns an option if the header is out of
bounds rather than panicking.
sourcefn iter(&self) -> HeadersIter<'_, Self> ⓘwhere
Self: Sized,
fn iter(&self) -> HeadersIter<'_, Self> ⓘwhere Self: Sized,
Iterates over all headers in order.