Struct opentelemetry_api::trace::TraceId
source · pub struct TraceId(/* private fields */);
Expand description
A 16-byte value which identifies a given trace.
The id is valid if it contains at least one non-zero byte.
Implementations§
source§impl TraceId
impl TraceId
sourcepub const fn from_bytes(bytes: [u8; 16]) -> Self
pub const fn from_bytes(bytes: [u8; 16]) -> Self
Create a trace id from its representation as a byte array.
sourcepub const fn to_bytes(self) -> [u8; 16]
pub const fn to_bytes(self) -> [u8; 16]
Return the representation of this trace id as a byte array.
sourcepub fn from_hex(hex: &str) -> Result<Self, ParseIntError>
pub fn from_hex(hex: &str) -> Result<Self, ParseIntError>
Converts a string in base 16 to a trace id.
Examples
use opentelemetry_api::trace::TraceId;
assert!(TraceId::from_hex("42").is_ok());
assert!(TraceId::from_hex("58406520a006649127e371903a2de979").is_ok());
assert!(TraceId::from_hex("not_hex").is_err());
Trait Implementations§
source§impl PartialEq for TraceId
impl PartialEq for TraceId
impl Copy for TraceId
impl Eq for TraceId
impl StructuralEq for TraceId
impl StructuralPartialEq for TraceId
Auto Trait Implementations§
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
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.