pub struct RequestId(/* private fields */);Expand description
Unique identifier for tracking a request through the system.
Request IDs enable correlation of logs, metrics, and traces across different components and services. They can be extracted from incoming headers or generated automatically.
Implementations§
Source§impl RequestId
impl RequestId
Sourcepub fn from_string(s: impl Into<String>) -> Self
pub fn from_string(s: impl Into<String>) -> Self
Creates a request ID from a string value.
This is useful when extracting request IDs from headers or
other sources. For a fallible variant, use RequestId::from_str() from the FromStr trait.
Sourcepub fn from_header(header: &HeaderValue) -> Option<Self>
pub fn from_header(header: &HeaderValue) -> Option<Self>
Attempts to extract a request ID from an HTTP header.
Returns None if the header value is not valid UTF-8.
Sourcepub fn from_request<B>(req: &Request<B>) -> Self
pub fn from_request<B>(req: &Request<B>) -> Self
Extracts a request ID from the request headers, or generates a new one.
Looks for the X-Request-ID header first. If not present or invalid,
generates a new random ID.
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Consumes the request ID and returns the inner string.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RequestId
impl<'de> Deserialize<'de> for RequestId
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
impl Eq for RequestId
impl StructuralPartialEq for RequestId
Auto Trait Implementations§
impl Freeze for RequestId
impl RefUnwindSafe for RequestId
impl Send for RequestId
impl Sync for RequestId
impl Unpin for RequestId
impl UnsafeUnpin for RequestId
impl UnwindSafe for RequestId
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.