Struct opentelemetry::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::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<'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 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