Struct pavex::telemetry::ServerRequestId
source · pub struct ServerRequestId(/* private fields */);
Expand description
A unique identifier generated for each incoming request.
It is a TypeId.
The prefix is always sri
, followed by an underscore and UUIDv7 in base32 encoding.
For example:
sri_2x4y6z8a0b1c2d3e4f5g6h7j8k
└─┘ └────────────────────────┘
prefix uuid suffix (base32)
§Example
use http::{HeaderName, HeaderValue};
use pavex::response::Response;
use pavex::telemetry::ServerRequestId;
pub async fn request_handler(request_id: ServerRequestId) -> Response {
// Add the request id as a header on the outgoing response
Response::ok()
.insert_header(
HeaderName::from_static("X-Request-Id"),
request_id.header_value()
)
}
Implementations§
source§impl ServerRequestId
impl ServerRequestId
sourcepub fn generate() -> Self
pub fn generate() -> Self
The default constructor for ServerRequestId
.
It generates a new request id using a UUID v7, with a random number and the current (UNIX) timestamp.
sourcepub fn header_value(&self) -> HeaderValue
pub fn header_value(&self) -> HeaderValue
Return a hyphenated representation
of ServerRequestId
to be used as a HeaderValue
.
source§impl ServerRequestId
impl ServerRequestId
Registration helpers.
sourcepub fn register(bp: &mut Blueprint) -> RegisteredConstructor<'_>
pub fn register(bp: &mut Blueprint) -> RegisteredConstructor<'_>
Register the default constructor
for ServerRequestId
with a Blueprint
.
sourcepub fn default_constructor() -> Constructor
pub fn default_constructor() -> Constructor
The default constructor for ServerRequestId
.
Trait Implementations§
source§impl Clone for ServerRequestId
impl Clone for ServerRequestId
source§fn clone(&self) -> ServerRequestId
fn clone(&self) -> ServerRequestId
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ServerRequestId
impl Debug for ServerRequestId
source§impl Display for ServerRequestId
impl Display for ServerRequestId
source§impl From<Uuid> for ServerRequestId
impl From<Uuid> for ServerRequestId
source§impl Hash for ServerRequestId
impl Hash for ServerRequestId
source§impl Ord for ServerRequestId
impl Ord for ServerRequestId
source§fn cmp(&self, other: &ServerRequestId) -> Ordering
fn cmp(&self, other: &ServerRequestId) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for ServerRequestId
impl PartialEq for ServerRequestId
source§impl PartialOrd for ServerRequestId
impl PartialOrd for ServerRequestId
impl Copy for ServerRequestId
impl Eq for ServerRequestId
impl StructuralPartialEq for ServerRequestId
Auto Trait Implementations§
impl Freeze for ServerRequestId
impl RefUnwindSafe for ServerRequestId
impl Send for ServerRequestId
impl Sync for ServerRequestId
impl Unpin for ServerRequestId
impl UnwindSafe for ServerRequestId
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.