pub struct ResponseContext {
pub response_ts: SV<i64>,
pub status: SV<Option<u16>>,
pub headers: DashMap<String, String>,
pub body: SV<Bytes>,
pub stream_body: SV<Option<Pin<Box<dyn Stream<Item = Result<Vec<u8>, Box<dyn Error + Send + Sync>>> + Send>>>>,
}Expand description
响应上下文
Fields§
§response_ts: SV<i64>响应时间戳,毫秒
status: SV<Option<u16>>响应状态码
headers: DashMap<String, String>响应头
body: SV<Bytes>响应体
stream_body: SV<Option<Pin<Box<dyn Stream<Item = Result<Vec<u8>, Box<dyn Error + Send + Sync>>> + Send>>>>响应流
Implementations§
Source§impl ResponseContext
impl ResponseContext
pub fn set_response_ts(&self, ts: i64)
pub fn get_response_ts(&self) -> i64
pub fn set_status(&self, status: u16)
pub fn get_status(&self) -> Option<u16>
pub fn insert_header(&self, key: &str, value: &str)
pub fn get_header(&self, key: &str) -> Option<String>
pub fn set_headers<H: IntoIterator<Item = (String, String)>>(&self, headers: H)
pub fn remove_header(&self, key: &str)
pub fn clear_headers(&self)
pub fn set_body(&self, body: Bytes)
pub fn get_body(&self) -> Option<&Bytes>
pub fn clear_body(&self)
pub fn set_stream_body( &self, body: Pin<Box<dyn Stream<Item = Result<Vec<u8>, Box<dyn Error + Send + Sync>>> + Send>>, )
pub fn take_stream_body( &self, ) -> Option<Pin<Box<dyn Stream<Item = Result<Vec<u8>, Box<dyn Error + Send + Sync>>> + Send>>>
pub fn is_success(&self) -> bool
pub fn is_client_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Trait Implementations§
Source§impl Debug for ResponseContext
impl Debug for ResponseContext
Source§impl Default for ResponseContext
impl Default for ResponseContext
Source§fn default() -> ResponseContext
fn default() -> ResponseContext
Returns the “default value” for a type. Read more
Auto 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