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
impl RecordHeaders
Sourcepub fn new() -> Self
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.
Sourcepub fn with_header_slice(headers: &[RecordHeader]) -> Self
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.
Sourcepub fn with_header_iter(headers: impl IntoIterator<Item = RecordHeader>) -> Self
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.
Sourcepub fn with_record_headers(other: &RecordHeaders) -> Self
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.
Sourcepub fn set_read_only(&mut self)
pub fn set_read_only(&mut self)
Set the headers to read-only mode.
After calling this, all mutating operations will return an error.
Sourcepub fn is_read_only(&self) -> bool
pub fn is_read_only(&self) -> bool
Returns whether the headers are in read-only mode.
Trait Implementations§
Source§impl Clone for RecordHeaders
impl Clone for RecordHeaders
Source§fn clone(&self) -> RecordHeaders
fn clone(&self) -> RecordHeaders
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RecordHeaders
impl Debug for RecordHeaders
Source§impl Default for RecordHeaders
impl Default for RecordHeaders
Source§impl Display for RecordHeaders
impl Display for RecordHeaders
Source§impl FromIterator<RecordHeader> for RecordHeaders
impl FromIterator<RecordHeader> for RecordHeaders
Source§fn from_iter<I: IntoIterator<Item = RecordHeader>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = RecordHeader>>(iter: I) -> Self
Source§impl Hash for RecordHeaders
impl Hash for RecordHeaders
Source§impl Headers for RecordHeaders
impl Headers for RecordHeaders
Source§fn add_header(
&mut self,
header: RecordHeader,
) -> Result<(), LocalIllegalStateError>
fn add_header( &mut self, header: RecordHeader, ) -> Result<(), LocalIllegalStateError>
Source§fn add_key_value(
&mut self,
key: &str,
value: Option<&[u8]>,
) -> Result<(), LocalIllegalStateError>
fn add_key_value( &mut self, key: &str, value: Option<&[u8]>, ) -> Result<(), LocalIllegalStateError>
Source§fn remove(&mut self, key: &str) -> Result<(), LocalIllegalStateError>
fn remove(&mut self, key: &str) -> Result<(), LocalIllegalStateError>
Source§fn last_header(&self, key: &str) -> Option<&RecordHeader>
fn last_header(&self, key: &str) -> Option<&RecordHeader>
Source§fn headers(&self, key: &str) -> Vec<&RecordHeader>
fn headers(&self, key: &str) -> Vec<&RecordHeader>
Source§fn to_array(&self) -> &[RecordHeader]
fn to_array(&self) -> &[RecordHeader]
Source§fn iter(&self) -> Iter<'_, RecordHeader>
fn iter(&self) -> Iter<'_, RecordHeader>
Source§impl<'a> IntoIterator for &'a RecordHeaders
impl<'a> IntoIterator for &'a RecordHeaders
Source§impl PartialEq for RecordHeaders
impl PartialEq for RecordHeaders
impl Eq for RecordHeaders
Auto Trait Implementations§
impl Freeze for RecordHeaders
impl RefUnwindSafe for RecordHeaders
impl Send for RecordHeaders
impl Sync for RecordHeaders
impl Unpin for RecordHeaders
impl UnsafeUnpin for RecordHeaders
impl UnwindSafe for RecordHeaders
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.