pub struct TraceId(/* private fields */);Expand description
A W3C Trace Id.
Implementations§
Source§impl TraceId
impl TraceId
Sourcepub fn random<R: Rng>(rng: R) -> Option<Self>
pub fn random<R: Rng>(rng: R) -> Option<Self>
Create a random trace id.
This method will return None if the given Rng fails to produce a random value, or if it produces the value 0.
Sourcepub const fn new(v: NonZeroU128) -> Self
pub const fn new(v: NonZeroU128) -> Self
Create a trace id from a non-zero integer.
Sourcepub fn from_u128(v: u128) -> Option<Self>
pub fn from_u128(v: u128) -> Option<Self>
Try create a trace id from an integer.
This method will return None if v is 0.
Sourcepub fn from_bytes(v: [u8; 16]) -> Option<Self>
pub fn from_bytes(v: [u8; 16]) -> Option<Self>
Get a trace id from a 16 byte big-endian array.
Sourcepub fn to_hex(&self) -> [u8; 32]
pub fn to_hex(&self) -> [u8; 32]
Convert the trace id into a 32 byte ASCII-compatible hex string, like 4bf92f3577b34da6a3ce929d0e0e4736.
Sourcepub fn try_from_hex_slice(hex: &[u8]) -> Result<Self, ParseIdError>
pub fn try_from_hex_slice(hex: &[u8]) -> Result<Self, ParseIdError>
Try parse a slice of ASCII hex bytes into a trace id.
If hex is not a 32 byte array of valid hex characters ([a-fA-F0-9]) then this method will fail.
Sourcepub fn try_from_hex(hex: impl Display) -> Result<Self, ParseIdError>
pub fn try_from_hex(hex: impl Display) -> Result<Self, ParseIdError>
Try parse ASCII hex characters into a trace id.
If hex is not exactly 32 valid hex characters ([a-fA-F0-9]) then this method will fail.
Trait Implementations§
Source§impl<'v> FromValue<'v> for TraceId
impl<'v> FromValue<'v> for TraceId
Source§fn from_value(value: Value<'v>) -> Option<Self>
fn from_value(value: Value<'v>) -> Option<Self>
Perform the conversion.
Source§impl Value for TraceId
Available on crate feature sval only.
impl Value for TraceId
Available on crate feature
sval only.Source§fn stream<'sval, S: Stream<'sval> + ?Sized>(
&'sval self,
stream: &mut S,
) -> Result
fn stream<'sval, S: Stream<'sval> + ?Sized>( &'sval self, stream: &mut S, ) -> Result
Stream this value through a
Stream.Source§fn to_f32(&self) -> Option<f32>
fn to_f32(&self) -> Option<f32>
Try convert this value into a 32bit binary floating point number.
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