pub struct ResponseContext {
pub request_id: String,
pub timestamp: Timestamp,
pub duration: Duration,
pub status: ResponseStatus,
pub metadata: Arc<HashMap<String, Value>>,
}
Expand description
Context information for response processing
Fields§
§request_id: String
Original request ID
timestamp: Timestamp
Response timestamp
duration: Duration
Processing duration
status: ResponseStatus
Response status
metadata: Arc<HashMap<String, Value>>
Custom metadata
Implementations§
Source§impl ResponseContext
impl ResponseContext
Sourcepub fn success(request_id: impl Into<String>, duration: Duration) -> Self
pub fn success(request_id: impl Into<String>, duration: Duration) -> Self
Create a successful response context
Sourcepub fn error(
request_id: impl Into<String>,
duration: Duration,
code: i32,
message: impl Into<String>,
) -> Self
pub fn error( request_id: impl Into<String>, duration: Duration, code: i32, message: impl Into<String>, ) -> Self
Create an error response context
Sourcepub fn cancelled(request_id: impl Into<String>, duration: Duration) -> Self
pub fn cancelled(request_id: impl Into<String>, duration: Duration) -> Self
Create a cancelled response context
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<Value>,
) -> Self
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<Value>, ) -> Self
Add metadata
Sourcepub const fn is_success(&self) -> bool
pub const fn is_success(&self) -> bool
Check if response is successful
Sourcepub fn error_info(&self) -> Option<(i32, &str)>
pub fn error_info(&self) -> Option<(i32, &str)>
Get error information if response is an error
Trait Implementations§
Source§impl Clone for ResponseContext
impl Clone for ResponseContext
Source§fn clone(&self) -> ResponseContext
fn clone(&self) -> ResponseContext
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 moreAuto Trait Implementations§
impl Freeze for ResponseContext
impl RefUnwindSafe for ResponseContext
impl Send for ResponseContext
impl Sync for ResponseContext
impl Unpin for ResponseContext
impl UnwindSafe for ResponseContext
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