pub struct TraceId(/* private fields */);Expand description
128-bit unique trace identifier.
Uses UUIDv7-style layout for time-ordered generation: the high 48 bits encode a millisecond Unix timestamp, the remaining 80 bits are random.
use franken_kernel::TraceId;
let id = TraceId::from_parts(1_700_000_000_000, 0xABCD_EF01_2345_6789_AB);
let hex = id.to_string();
let parsed: TraceId = hex.parse().unwrap();
assert_eq!(id, parsed);Implementations§
Source§impl TraceId
impl TraceId
Sourcepub const fn from_parts(ts_ms: u64, random: u128) -> Self
pub const fn from_parts(ts_ms: u64, random: u128) -> Self
Create a TraceId from a millisecond timestamp and random bits.
The high 48 bits store ts_ms, the low 80 bits store random.
The random value is truncated to 80 bits.
Sourcepub const fn timestamp_ms(self) -> u64
pub const fn timestamp_ms(self) -> u64
Extract the millisecond timestamp from the high 48 bits.
Sourcepub const fn from_bytes(bytes: [u8; 16]) -> Self
pub const fn from_bytes(bytes: [u8; 16]) -> Self
Construct from big-endian bytes.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TraceId
impl<'de> Deserialize<'de> for TraceId
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for TraceId
impl Ord for TraceId
Source§impl PartialOrd for TraceId
impl PartialOrd for TraceId
impl Copy for TraceId
impl Eq for TraceId
impl StructuralPartialEq for TraceId
Auto Trait Implementations§
impl Freeze for TraceId
impl RefUnwindSafe for TraceId
impl Send for TraceId
impl Sync for TraceId
impl Unpin for TraceId
impl UnwindSafe for TraceId
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