pub struct RequestContext {
pub trace: TraceContext,
pub start_time: Instant,
pub timeout: Option<Duration>,
pub debug_request: bool,
}Expand description
Request context for protocol operations.
This is a specialized context for protocol-level requests.
Fields§
§trace: TraceContextBase trace context.
start_time: InstantRequest start time.
timeout: Option<Duration>Request timeout (if set).
debug_request: boolWhether this request should be logged at debug level.
Implementations§
Source§impl RequestContext
impl RequestContext
Sourcepub fn new() -> RequestContext
pub fn new() -> RequestContext
Create a new request context.
Sourcepub fn with_trace(trace: TraceContext) -> RequestContext
pub fn with_trace(trace: TraceContext) -> RequestContext
Create with an existing trace context.
Sourcepub fn device(self, device_id: impl Into<String>) -> RequestContext
pub fn device(self, device_id: impl Into<String>) -> RequestContext
Set the device ID.
Sourcepub fn protocol(self, protocol: impl Into<String>) -> RequestContext
pub fn protocol(self, protocol: impl Into<String>) -> RequestContext
Set the protocol.
Sourcepub fn operation(self, operation: impl Into<String>) -> RequestContext
pub fn operation(self, operation: impl Into<String>) -> RequestContext
Set the operation.
Sourcepub fn with_timeout(self, timeout: Duration) -> RequestContext
pub fn with_timeout(self, timeout: Duration) -> RequestContext
Set a timeout.
Sourcepub fn debug(self) -> RequestContext
pub fn debug(self) -> RequestContext
Mark as a debug request (logged at debug level).
Sourcepub fn is_timed_out(&self) -> bool
pub fn is_timed_out(&self) -> bool
Check if the request has timed out.
Sourcepub fn remaining_timeout(&self) -> Option<Duration>
pub fn remaining_timeout(&self) -> Option<Duration>
Get remaining time before timeout.
Sourcepub fn request_id(&self) -> &str
pub fn request_id(&self) -> &str
Get the request ID.
Trait Implementations§
Source§impl Clone for RequestContext
impl Clone for RequestContext
Source§fn clone(&self) -> RequestContext
fn clone(&self) -> RequestContext
Returns a duplicate 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 RequestContext
impl Debug for RequestContext
Source§impl Default for RequestContext
impl Default for RequestContext
Source§fn default() -> RequestContext
fn default() -> RequestContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RequestContext
impl RefUnwindSafe for RequestContext
impl Send for RequestContext
impl Sync for RequestContext
impl Unpin for RequestContext
impl UnsafeUnpin for RequestContext
impl UnwindSafe for RequestContext
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> 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