pub struct TraceId(/* private fields */);Expand description
A 128-bit W3C trace identifier, encoded as 32 lowercase hex characters.
The all-zeros value is invalid per the W3C spec and will never be produced
by TraceId::new or accepted by TraceId::from_str.
Implementations§
Source§impl TraceId
impl TraceId
Sourcepub fn new() -> Self
pub fn new() -> Self
Generate a new random TraceId (backed by UUID v4 bytes).
use api_bones::traceparent::TraceId;
let id = TraceId::new();
assert!(!id.is_zero());Sourcepub fn from_bytes(bytes: [u8; 16]) -> Option<Self>
pub fn from_bytes(bytes: [u8; 16]) -> Option<Self>
Construct from raw bytes.
Returns None if the bytes are all zero (invalid per W3C spec).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TraceId
Available on crate feature serde only.
impl<'de> Deserialize<'de> for TraceId
Available on crate feature
serde only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
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 UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ValidateIp for Twhere
T: ToString,
impl<T> ValidateIp for Twhere
T: ToString,
Source§fn validate_ipv4(&self) -> bool
fn validate_ipv4(&self) -> bool
Validates whether the given string is an IP V4
Source§fn validate_ipv6(&self) -> bool
fn validate_ipv6(&self) -> bool
Validates whether the given string is an IP V6
Source§fn validate_ip(&self) -> bool
fn validate_ip(&self) -> bool
Validates whether the given string is an IP