Skip to main content

RecordsPayload

Enum RecordsPayload 

Source
pub enum RecordsPayload {
    V2(Vec<RecordBatch>),
    Raw(Bytes),
    Legacy(Bytes),
}
Expand description

Owned form of a records-field payload.

Variants§

§

V2(Vec<RecordBatch>)

Zero or more parsed v2 batches (the records field is a sequence).

§

Raw(Bytes)

Verbatim, already-wire-format v2 bytes (one or more batches), forwarded without parsing. Produced by the fetch pass-through path.

§

Legacy(Bytes)

Opaque pre-v2 bytes (v0/v1 MessageSet). Decode with crabka_records_legacy::decode_message_set.

Implementations§

Source§

impl RecordsPayload

Source

pub fn from_bytes(bytes: Bytes) -> Result<Self, RecordsError>

Construct from raw records-field bytes. When the bytes look like v2, decode every batch in the field; otherwise keep as opaque legacy.

Source

pub fn payload_len(&self) -> usize

Wire size of the records-field bytes (no outer length prefix).

Source

pub fn encode_to<B: BufMut>(&self, buf: &mut B) -> Result<(), RecordsError>

Write the payload bytes into buf (caller owns the outer framing).

Source

pub fn as_v2(&self) -> Option<&[RecordBatch]>

Borrow the parsed v2 batches, if this is a parsed V2 payload. Returns None for Raw (intentionally unparsed) and Legacy.

Source

pub fn as_legacy(&self) -> Option<&Bytes>

Borrow as raw legacy bytes, if that’s what this payload is.

Source

pub fn from_fetch_bytes(bytes: Bytes) -> Result<Self, RecordsError>

Decode a response-side records field, tolerating a truncated trailing batch. Kafka returns a partial final RecordBatch when a partition’s fetch byte budget is hit mid-batch; the JVM consumer stops at the first incomplete batch and re-fetches it from the next offset. We mirror that: decode every complete batch, and on the first HeaderTooShort / BodyTooShort stop and drop the remainder. A corrupt complete batch (bad CRC/magic/content) still errors — leniency forgives truncation only. Strict from_bytes is retained for Produce-request validation.

Only HeaderTooShort/BodyTooShort are treated as truncation; a genuinely invalid batch_length (RecordParse) is corruption and still errors — legitimate Kafka truncation always preserves a valid batch_length prefix, so it can only manifest as the too-short variants.

Source

pub fn decode_lenient<B: Buf>( buf: &mut B, _version: i16, ) -> Result<Self, ProtocolError>

Decode-shaped lenient entry point the generated codec calls for records fields in response messages. Consumes the whole sliced field buffer (the caller has already framed it) and parses leniently via from_fetch_bytes.

Trait Implementations§

Source§

impl Clone for RecordsPayload

Source§

fn clone(&self) -> RecordsPayload

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RecordsPayload

Source§

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

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

impl Decode<'_> for RecordsPayload

Source§

fn decode<B: Buf>(buf: &mut B, _version: i16) -> Result<Self, ProtocolError>

Source§

impl Default for RecordsPayload

Source§

fn default() -> Self

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

impl Encode for RecordsPayload

Source§

fn encode<B: BufMut>( &self, buf: &mut B, _version: i16, ) -> Result<(), ProtocolError>

Source§

fn encoded_len(&self, _version: i16) -> usize

Size in bytes that encode will write. Must equal the actual count.
Source§

impl Eq for RecordsPayload

Source§

impl From<RecordBatch> for RecordsPayload

Source§

fn from(rb: RecordBatch) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<RecordBatch>> for RecordsPayload

Source§

fn from(v: Vec<RecordBatch>) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for RecordsPayload

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for RecordsPayload

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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