Skip to main content

MessageId

Struct MessageId 

Source
pub struct MessageId {
    pub ledger_id: u64,
    pub entry_id: u64,
    pub partition: i32,
    pub batch_index: i32,
    pub batch_size: i32,
}
Expand description

A logical message identifier (ledger / entry / batch / partition).

Mirrors the Java MessageId interface. partition defaults to -1 for non-partitioned topics; batch_index defaults to -1 for non-batched messages.

§Structural equality (PIP-180)

Two MessageIds compare equal iff every structural field matches — (ledger_id, entry_id, partition, batch_index, batch_size). On a shadow topic (PIP-180, ADR-0033) the broker presents messages with the source MessageId (same ledger/entry pointers as the original write), so a shadow-side reader observes ids that compare equal to the source-side reader’s ids — “same message” is structurally evident and needs no out-of-band correlation key.

§PIP-460 scalable-topic segment (experimental)

Under feature = "scalable-topics" the id carries an optional segment_id field. The derived PartialEq / Ord / Hash give exactly the cross-mode contract ADR-0093 specifies: two v4 ids both carry None, so the segment field is a tie and the v4 invariant is preserved bit-for-bit; a scalable id (Some(_)) never compares equal to a v4 id (None) — so callers can’t accidentally deduplicate across the scalable / partitioned mode boundary.

Fields§

§ledger_id: u64

Bookkeeper ledger id where the entry lives.

§entry_id: u64

Entry id within the ledger.

§partition: i32

Partition index, -1 if non-partitioned.

§batch_index: i32

Index within a batched entry, -1 if not batched.

§batch_size: i32

Size of the batch the message came from, -1 if not batched.

Implementations§

Source§

impl MessageId

Source

pub const EARLIEST: MessageId

A sentinel “earliest” position. Mirrors MessageId.earliest.

Source

pub const LATEST: MessageId

A sentinel “latest” position. Mirrors MessageId.latest.

Source

pub fn from_pb(pb: &MessageIdData) -> MessageId

Construct a message id from the wire protobuf representation.

Source

pub fn to_pb(self) -> MessageIdData

Encode this message id back into its protobuf form.

Source

pub fn to_bytes(self) -> Vec<u8>

Serialise this message id to a portable byte string. Mirrors Java MessageId#toByteArray — encodes a MessageIdData protobuf message. Callers can stash the result anywhere (Kafka header, DB column, log line) and reconstruct via Self::from_bytes later.

Source

pub fn from_bytes(bytes: &[u8]) -> Option<MessageId>

Reconstruct a message id from the byte string produced by Self::to_bytes. Mirrors Java MessageId#fromByteArray. Returns None if bytes is not a valid protobuf MessageIdData.

Trait Implementations§

Source§

impl Clone for MessageId

Source§

fn clone(&self) -> MessageId

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 Copy for MessageId

Source§

impl Debug for MessageId

Source§

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

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

impl Display for MessageId

Source§

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

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

impl Eq for MessageId

Source§

impl Hash for MessageId

Source§

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

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 Ord for MessageId

Source§

fn cmp(&self, other: &MessageId) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for MessageId

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for MessageId

Source§

fn partial_cmp(&self, other: &MessageId) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for MessageId

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
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more