pub struct RecordBatch {
pub base_offset: i64,
pub partition_leader_epoch: i32,
pub attributes: Attributes,
pub last_offset_delta: i32,
pub base_timestamp: i64,
pub max_timestamp: i64,
pub producer_id: i64,
pub producer_epoch: i16,
pub base_sequence: i32,
pub records: Vec<Record>,
}Fields§
§base_offset: i64§partition_leader_epoch: i32§attributes: Attributes§last_offset_delta: i32§base_timestamp: i64§max_timestamp: i64§producer_id: i64§producer_epoch: i16§base_sequence: i32§records: Vec<Record>Implementations§
Source§impl RecordBatch
impl RecordBatch
Sourcepub fn delete_horizon_ms(&self) -> Option<i64>
pub fn delete_horizon_ms(&self) -> Option<i64>
KIP-534 delete horizon, if the delete-horizon attribute bit is set.
base_timestamp carries the horizon. There is no separate wire field.
Sourcepub fn with_delete_horizon(self, horizon_ms: i64) -> Self
pub fn with_delete_horizon(self, horizon_ms: i64) -> Self
Stamp the delete horizon onto this batch.
This method sets bit 6 and moves the horizon into base_timestamp. It
then rewrites every record’s timestamp_delta, so the reconstructed
absolute timestamps base_timestamp + delta do not change.
Sourcepub fn decode<B: Buf>(buf: &mut B) -> Result<Self, RecordsError>
pub fn decode<B: Buf>(buf: &mut B) -> Result<Self, RecordsError>
Decode a complete v2 record batch from buf.
This method reads from the start of the header.
§Errors
Returns the underlying protocol error when input is truncated, contains an invalid length or tag, or cannot be encoded for the selected version.
§Panics
Panics if a value previously validated by the protocol type no longer satisfies its encoded-length or field-range invariant.
Sourcepub fn decode_with_policy<B: Buf>(
buf: &mut B,
policy: RecordDecompressionPolicy,
) -> Result<Self, RecordsError>
pub fn decode_with_policy<B: Buf>( buf: &mut B, policy: RecordDecompressionPolicy, ) -> Result<Self, RecordsError>
Sourcepub fn encode<B: BufMut>(&self, buf: &mut B) -> Result<(), RecordsError>
pub fn encode<B: BufMut>(&self, buf: &mut B) -> Result<(), RecordsError>
Encode this batch into buf.
§Errors
Returns the underlying protocol error when input is truncated, contains an invalid length or tag, or cannot be encoded for the selected version.
Sourcepub fn encode_to_bytes(&self) -> Result<Bytes, RecordsError>
pub fn encode_to_bytes(&self) -> Result<Bytes, RecordsError>
Encode this batch into an owned wire buffer.
Uncompressed records are written directly behind the header, avoiding a temporary body buffer and its copy into the output.
§Errors
Returns the same encoding errors as Self::encode.
Sourcepub fn encode_with_compression_level<B: BufMut>(
&self,
buf: &mut B,
level: Option<i32>,
) -> Result<(), RecordsError>
pub fn encode_with_compression_level<B: BufMut>( &self, buf: &mut B, level: Option<i32>, ) -> Result<(), RecordsError>
Encode this batch into buf, and compress the records at level.
None uses the default level of the codec, as Self::encode does.
A producer passes its compression.<codec>.level setting (KIP-390).
See krabka_compression::compress_with_level for how each codec
applies the level.
§Errors
Returns RecordsError::Compression when level is not a level that
Kafka accepts for the codec of the batch attributes, including any
level for a batch with no compression. Returns the other errors of
Self::encode.
Sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Predicted total bytes that encode will write, for an uncompressed batch.
For a compressed batch, the actual size will differ.
Trait Implementations§
Source§impl Clone for RecordBatch
impl Clone for RecordBatch
Source§impl Debug for RecordBatch
impl Debug for RecordBatch
Source§impl Decode<'_> for RecordBatch
impl Decode<'_> for RecordBatch
Source§impl Default for RecordBatch
impl Default for RecordBatch
Source§impl Encode for RecordBatch
impl Encode for RecordBatch
impl Eq for RecordBatch
Source§impl From<RecordBatch> for RecordsPayload
impl From<RecordBatch> for RecordsPayload
Source§fn from(rb: RecordBatch) -> Self
fn from(rb: RecordBatch) -> Self
Source§impl PartialEq for RecordBatch
impl PartialEq for RecordBatch
impl StructuralPartialEq for RecordBatch
Auto Trait Implementations§
impl Freeze for RecordBatch
impl RefUnwindSafe for RecordBatch
impl Send for RecordBatch
impl Sync for RecordBatch
impl Unpin for RecordBatch
impl UnsafeUnpin for RecordBatch
impl UnwindSafe for RecordBatch
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
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<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);