pub struct RequestId(/* private fields */);Expand description
A UUID v4 request identifier, typically propagated via the X-Request-Id
HTTP header.
Use RequestId::new to generate a fresh identifier, or
RequestId::from_str / TryFrom to parse one from an incoming header.
The Display implementation produces the canonical hyphenated UUID string
(e.g. 550e8400-e29b-41d4-a716-446655440000).
Implementations§
Source§impl RequestId
impl RequestId
Sourcepub fn new() -> Self
pub fn new() -> Self
Generate a new random RequestId (UUID v4).
use api_bones::request_id::RequestId;
let id = RequestId::new();
assert_eq!(id.as_uuid().get_version_num(), 4);Sourcepub fn from_uuid(id: Uuid) -> Self
pub fn from_uuid(id: Uuid) -> Self
Wrap an existing uuid::Uuid as a RequestId.
use api_bones::request_id::RequestId;
let id = RequestId::from_uuid(uuid::Uuid::nil());
assert_eq!(id.to_string(), "00000000-0000-0000-0000-000000000000");Sourcepub fn as_uuid(&self) -> Uuid
pub fn as_uuid(&self) -> Uuid
Return the inner uuid::Uuid.
Sourcepub fn header_name(&self) -> &'static str
pub fn header_name(&self) -> &'static str
The canonical HTTP header name for this identifier: X-Request-Id.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RequestId
Available on crate feature serde only.
impl<'de> Deserialize<'de> for RequestId
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 RequestId
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<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