Skip to main content

RecordCoordinate

Struct RecordCoordinate 

Source
pub struct RecordCoordinate { /* private fields */ }
Expand description

Re-exported: the durable address WeirClient::push_tracked returns for an accepted record. Lives in weir-core because both ends of the socket build it from the same bytes. Where one accepted record lives in the write-ahead buffer, plus the id the downstream sees for it.

§What it is

  • segment — the record’s segment address, <shard-dir>/<file-name>, e.g. shard_00/seg_00000001.wab.sealed. Treat it as an opaque, stable string, not a filesystem path: it names the segment the drain will read the record from, which is a predicted name at ack time (the segment is still open).
  • index — the record’s 1-based ordinal within that segment.
  • record_id — sha256(segment ++ index ++ payload) with length framing. Byte-identical to the Idempotency-Key the HTTP sink sends for this record, and to the id the S3 sink names objects with.

§What it is not

A coordinate is a buffer address, not a per-producer sequence number. Records from other producers interleave, so one producer’s indices have holes; (segment, index) gives a total order per shard and lets a producer recognise a record it has already sent, but it is not a gap-free sequence.

A coordinate is also not a durability upgrade. A Buffered push gets a coordinate as readily as a Durable one; the tier still decides whether the bytes survive power loss.

Implementations§

Source§

impl RecordCoordinate

Source

pub fn new( segment: String, index: u64, record_id: [u8; 32], ) -> Result<RecordCoordinate, CoordinateError>

Builds a coordinate, rejecting a segment name that could not be encoded within MAX_SEGMENT_NAME_LEN.

Fallible rather than truncating: a shortened segment name still looks like an address and would send a producer to the wrong record — silently. The daemon treats an Err here as an internal error and nacks.

Source

pub fn segment(&self) -> &str

The segment’s address in the buffer, <shard-dir>/<file-name>.

Source

pub fn index(&self) -> u64

The record’s 1-based ordinal within segment.

Source

pub fn record_id(&self) -> &[u8; 32]

The raw 32-byte record id digest.

Source

pub fn record_id_hex(&self) -> String

The record id as 64 lowercase hex characters, no prefix — the form that matches weir_sink_sdk::RecordId::to_hex and the sink’s Idempotency-Key: sha256:<hex> header.

Source

pub fn encode(&self) -> Vec<u8> ⓘ

Serialises to the AckTracked payload layout.

[0]      coordinate_version
[1..9]   index          u64 LE
[9..41]  record_id      32 bytes
[41..43] segment_len    u16 LE
[43..]   segment        UTF-8
Source

pub fn decode(buf: &[u8]) -> Result<RecordCoordinate, CoordinateError>

Parses an AckTracked payload.

The buffer must be exactly one coordinate — trailing bytes are rejected rather than ignored, matching Envelope::decode: a payload longer than it declares means the sender and receiver disagree about the layout, and quietly using the prefix is how a disagreement becomes a wrong address.

Trait Implementations§

Source§

impl Clone for RecordCoordinate

Source§

fn clone(&self) -> RecordCoordinate

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 RecordCoordinate

Source§

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

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

impl Eq for RecordCoordinate

Source§

impl Hash for RecordCoordinate

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 PartialEq for RecordCoordinate

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RecordCoordinate

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> 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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.