Skip to main content

RecordHeaders

Struct RecordHeaders 

Source
pub struct RecordHeaders { /* private fields */ }
Expand description

A mutable ordered collection of RecordHeader objects.

Note that multiple headers may have the same key. The order of headers is preserved in the order they were added.

Once set_read_only() is called, all mutating operations will return an error.

Corresponds to Java’s org.apache.kafka.common.header.internals.RecordHeaders.

Implementations§

Source§

impl RecordHeaders

Source

pub fn new() -> Self

Create an empty RecordHeaders.

Translates Java’s no-arg RecordHeaders() (RecordHeaders.java:35). The three Java constructors have no parameter in common, and the no-arg one matches that empty intersection, so it keeps the plain name under CLAUDE.md §2 — its two siblings are suffixed below.

Source

pub fn with_header_slice(headers: &[RecordHeader]) -> Self

Create RecordHeaders from a slice of headers.

Translates Java’s RecordHeaders(Header[] headers) (RecordHeaders.java:39). Java’s other parameterised constructor names its parameter headers too, so the parameter name cannot tell them apart; per CLAUDE.md §2 the Rust parameter type discriminates, spelled as the caller writes it (&[RecordHeader] → _header_slice).

§Panics

This corresponds to the Java behavior where null entries in the array cause a NullPointerException. In Rust, the Option type prevents null headers so this is safe by construction.

Source

pub fn with_header_iter(headers: impl IntoIterator<Item = RecordHeader>) -> Self

Create RecordHeaders from headers.

Translates Java’s RecordHeaders(Iterable<Header> headers) (RecordHeaders.java:43) — see with_header_slice for why the type, not the parameter name, supplies the suffix.

Source

pub fn with_record_headers(other: &RecordHeaders) -> Self

Create RecordHeaders by copying from another RecordHeaders.

Java reaches this through RecordHeaders(Iterable<Header> headers) (RecordHeaders.java:43), since RecordHeaders is itself an Iterable<Header>. Rust needs a distinct overload because &RecordHeaders iterates as &RecordHeader, not RecordHeader, so it does not satisfy with_header_iter’s bound. The suffix follows the type, as the sibling overloads do.

The new instance is writable regardless of the source’s read-only state.

Source

pub fn set_read_only(&mut self)

Set the headers to read-only mode.

After calling this, all mutating operations will return an error.

Source

pub fn is_read_only(&self) -> bool

Returns whether the headers are in read-only mode.

Trait Implementations§

Source§

impl Clone for RecordHeaders

Source§

fn clone(&self) -> RecordHeaders

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RecordHeaders

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RecordHeaders

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for RecordHeaders

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromIterator<RecordHeader> for RecordHeaders

Source§

fn from_iter<I: IntoIterator<Item = RecordHeader>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl Hash for RecordHeaders

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Headers for RecordHeaders

Source§

fn add_header( &mut self, header: RecordHeader, ) -> Result<(), LocalIllegalStateError>

Adds a header (key inside), to the end, returning if the operation succeeded. Read more
Source§

fn add_key_value( &mut self, key: &str, value: Option<&[u8]>, ) -> Result<(), LocalIllegalStateError>

Creates and adds a header, to the end, returning if the operation succeeded. Read more
Source§

fn remove(&mut self, key: &str) -> Result<(), LocalIllegalStateError>

Removes all headers for the given key returning if the operation succeeded, while preserving the insertion order of the remaining headers. Read more
Source§

fn last_header(&self, key: &str) -> Option<&RecordHeader>

Returns just one (the very last) header for the given key, if present.
Source§

fn headers(&self, key: &str) -> Vec<&RecordHeader>

Returns all headers for the given key, in the order they were added in. Read more
Source§

fn to_array(&self) -> &[RecordHeader]

Returns all headers as a slice. Read more
Source§

fn iter(&self) -> Iter<'_, RecordHeader>

Returns an iterator over the headers.
Source§

impl<'a> IntoIterator for &'a RecordHeaders

Source§

type Item = &'a RecordHeader

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, RecordHeader>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for RecordHeaders

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for RecordHeaders

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V