pub struct Record {
pub attributes: i8,
pub timestamp_delta: i64,
pub offset_delta: i32,
pub key: Option<Bytes>,
pub value: Option<Bytes>,
pub headers: Vec<RecordHeader>,
}Expand description
A Kafka record within a batch.
Fields§
§attributes: i8Record attributes (currently unused in v2).
timestamp_delta: i64Timestamp delta from batch base timestamp.
offset_delta: i32Offset delta from batch base offset.
key: Option<Bytes>Record key.
value: Option<Bytes>Record value.
headers: Vec<RecordHeader>Record headers.
Implementations§
Source§impl Record
impl Record
Sourcepub fn new(key: Option<Bytes>, value: Option<Bytes>) -> Self
pub fn new(key: Option<Bytes>, value: Option<Bytes>) -> Self
Create a new record with key and value.
Sourcepub fn with_header(self, key: impl Into<Bytes>, value: impl Into<Bytes>) -> Self
pub fn with_header(self, key: impl Into<Bytes>, value: impl Into<Bytes>) -> Self
Add a header to the record.
Sourcepub fn with_timestamp_delta(self, delta: i64) -> Self
pub fn with_timestamp_delta(self, delta: i64) -> Self
Set timestamp delta.
Sourcepub fn with_offset_delta(self, delta: i32) -> Self
pub fn with_offset_delta(self, delta: i32) -> Self
Set offset delta.
Sourcepub fn encode(&self, buf: &mut impl BufMut) -> Result<()>
pub fn encode(&self, buf: &mut impl BufMut) -> Result<()>
Encode the record to a buffer.
Pre-computes the body size analytically so no intermediate allocation is needed — the length varint is written first, then the body is encoded directly into the output buffer.
Sourcepub fn record_body_size(&self) -> Result<usize>
pub fn record_body_size(&self) -> Result<usize>
Compute the wire-encoded size of the record body (everything after the
length prefix). Used by encode to avoid a temporary
allocation.
Trait Implementations§
impl Eq for Record
impl StructuralPartialEq for Record
Auto Trait Implementations§
impl !Freeze for Record
impl RefUnwindSafe for Record
impl Send for Record
impl Sync for Record
impl Unpin for Record
impl UnsafeUnpin for Record
impl UnwindSafe for Record
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.