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: u64Bookkeeper ledger id where the entry lives.
entry_id: u64Entry id within the ledger.
partition: i32Partition index, -1 if non-partitioned.
batch_index: i32Index within a batched entry, -1 if not batched.
batch_size: i32Size of the batch the message came from, -1 if not batched.
Implementations§
Source§impl MessageId
impl MessageId
Sourcepub fn from_pb(pb: &MessageIdData) -> MessageId
pub fn from_pb(pb: &MessageIdData) -> MessageId
Construct a message id from the wire protobuf representation.
Sourcepub fn to_pb(self) -> MessageIdData
pub fn to_pb(self) -> MessageIdData
Encode this message id back into its protobuf form.
Sourcepub fn to_bytes(self) -> Vec<u8> ⓘ
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.
Sourcepub fn from_bytes(bytes: &[u8]) -> Option<MessageId>
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.