pub struct RequestId(/* private fields */);Expand description
一次 Action 派发的运行期标识。
Display 输出为 32 位十六进制(无分隔),便于日志检索:
形如 0192f4a1c3d50000000000000000002a。
Implementations§
Source§impl RequestId
impl RequestId
Sourcepub fn parse_hex(s: &str) -> Option<Self>
pub fn parse_hex(s: &str) -> Option<Self>
解析上游 X-Request-Id 为 RequestId(供透传跨服务标识)。
接受形式:
- 1..=32 位十六进制(无分隔),如
2a、0192f4a1c3d5...; - 标准 UUID(带连字符,如
550e8400-e29b-41d4-a716-446655440000)—— 去连字符后恰为 32 位十六进制,覆盖最常见的上游标识与 W3C traceparent 的 trace-id 段。
非十六进制、全零值或去连字符后超 32 位返回 None,调用方据此降级为新生成。
限制:RequestId 底层是 u128,无法承载任意字符串标识(如纯字母 trace
id)。这类上游标识会被拒绝并降级——若需端到端透传任意字符串标识,应在传输层
自行记录原始 header,本类型只负责进程内可排序的数值标识。
Trait Implementations§
impl Copy for RequestId
impl Eq for RequestId
impl StructuralPartialEq for RequestId
Auto Trait Implementations§
impl Forget for RequestId
impl Freeze for RequestId
impl Move 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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more