#[repr(C)]pub struct SortKey {
pub hlc: HlcTimestamp,
pub node_seq: u64,
}Expand description
128-bit composite sort key for total ordering across distributed nodes.
Records are ordered by:
- HLC timestamp (causal ordering)
- Node ID (tie-breaker, lower wins)
- Sequence number (per-node ordering)
Fields§
§hlc: HlcTimestampHLC timestamp (64 bits) - provides causal ordering across nodes.
node_seq: u64Packed node_id (16 bits) + sequence (48 bits).
Layout: [node_id: 16 bits][sequence: 48 bits]
Implementations§
Source§impl SortKey
impl SortKey
Sourcepub const fn new(hlc: HlcTimestamp, node_id: u16, sequence: u64) -> Self
pub const fn new(hlc: HlcTimestamp, node_id: u16, sequence: u64) -> Self
Create a new sort key from components.
§Arguments
hlc- Hybrid Logical Clock timestampnode_id- Node identifier (lower wins in tie-breaks)sequence- Per-node monotonic sequence (only lower 48 bits used)
Sourcepub const fn from_timestamp_ns(timestamp_ns: u64, sequence: u32) -> Self
pub const fn from_timestamp_ns(timestamp_ns: u64, sequence: u32) -> Self
Create a sort key from raw timestamp (legacy compatibility).
Converts nanosecond timestamp to HLC milliseconds with zero logical counter.
Sourcepub const fn hlc(&self) -> HlcTimestamp
pub const fn hlc(&self) -> HlcTimestamp
Get the HLC timestamp component.
Sourcepub const fn timestamp_ns(&self) -> u64
pub const fn timestamp_ns(&self) -> u64
Get approximate timestamp in nanoseconds (for compatibility).
Note: This loses precision since HLC uses milliseconds internally.
Trait Implementations§
Source§impl FromBytes for SortKey
impl FromBytes for SortKey
Source§impl Ord for SortKey
impl Ord for SortKey
Source§impl PartialOrd for SortKey
impl PartialOrd for SortKey
Source§impl TryFromBytes for SortKey
impl TryFromBytes for SortKey
Source§fn try_read_from_bytes(
source: &[u8],
) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_bytes(
source: &[u8],
) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
Source§fn try_read_from_prefix(
source: &[u8],
) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_prefix(
source: &[u8],
) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
Source§fn try_read_from_suffix(
source: &[u8],
) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_suffix(
source: &[u8],
) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
impl Copy for SortKey
impl Eq for SortKey
impl StructuralPartialEq for SortKey
Auto Trait Implementations§
impl Freeze for SortKey
impl RefUnwindSafe for SortKey
impl Send for SortKey
impl Sync for SortKey
impl Unpin for SortKey
impl UnsafeUnpin for SortKey
impl UnwindSafe for SortKey
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
Mutably borrows from an owned value. Read more