pub struct RequestId(/* private fields */);Expand description
A request identifier selected by the configured request-ID policy.
Values created through parse, FromStr, or TryFrom
satisfy the baseline grammar: 1 to MAX_LEN ASCII
URI-unreserved bytes. Middleware can also construct this type for one
native-safe caller value admitted by a custom validator; such a value is not
guaranteed to satisfy the baseline grammar.
Implementations§
Source§impl RequestId
impl RequestId
Sourcepub const MAX_LEN: usize = 128
pub const MAX_LEN: usize = 128
Maximum request-ID length accepted by the baseline parser, in bytes.
A caller value admitted by a custom middleware validator can be longer.
Sourcepub fn parse(value: &str) -> Result<Self, InvalidRequestId>
pub fn parse(value: &str) -> Result<Self, InvalidRequestId>
Parses and validates a request identifier.
§Errors
Returns the first deterministic baseline validation failure without retaining or echoing the rejected value.
§Examples
use axum_observability::RequestId;
let request_id = RequestId::parse("request-42")?;
assert_eq!(request_id.as_str(), "request-42");Trait Implementations§
impl Eq for RequestId
Source§impl Ord for RequestId
impl Ord for RequestId
1.21.0 (const: unstable) · 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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for RequestId
impl PartialOrd 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