Struct qiniu_http::Response

source ·
pub struct Response<B> { /* private fields */ }
Expand description

HTTP 响应

封装 HTTP 响应相关字段

Implementations§

source§

impl<B: Default> Response<B>

source

pub fn builder() -> ResponseBuilder<B>

返回 HTTP 响应构建器

source§

impl<B> Response<B>

source

pub fn body(&self) -> &B

获取 HTTP 响应体

source

pub fn body_mut(&mut self) -> &mut B

获取 HTTP 响应体的可变引用

source

pub fn parts(&self) -> &ResponseParts

HTTP 响应信息

source

pub fn parts_mut(&mut self) -> &mut ResponseParts

获取 HTTP 响应信息的可变引用

source

pub fn into_body(self) -> B

转换为 HTTP 响应体

source

pub fn into_parts_and_body(self) -> (ResponseParts, B)

转换为响应信息和响应体

source

pub fn from_parts_and_body(parts: ResponseParts, body: B) -> Self

通过响应信息和响应体创建 HTTP 响应

source

pub fn map_body<B2>(self, f: impl FnOnce(B) -> B2) -> Response<B2>

对 HTTP 响应体进行映射

source

pub fn try_map_body<B2, E>( self, f: impl FnOnce(B) -> Result<B2, E> ) -> Result<Response<B2>, MapError<E>>

尝试对 HTTP 响应体进行映射

source

pub async fn try_async_map_body<B2, E, F, Fut>( self, f: F ) -> Result<Response<B2>, MapError<E>>
where F: FnOnce(B) -> Fut, Fut: Future<Output = Result<B2, E>>,

尝试对 HTTP 响应体进行异步映射

Methods from Deref<Target = ResponseParts>§

source

pub fn status_code(&self) -> StatusCode

获取 HTTP 状态码

source

pub fn status_code_mut(&mut self) -> &mut StatusCode

获取 HTTP 状态码 的可变引用

source

pub fn headers(&self) -> &HeaderMap

获取 HTTP Headers

source

pub fn headers_mut(&mut self) -> &mut HeaderMap

获取 HTTP Headers 的可变引用

source

pub fn version(&self) -> Version

获取 HTTP 版本

source

pub fn version_mut(&mut self) -> &mut Version

获取 HTTP 版本的可变引用

source

pub fn extensions(&self) -> &Extensions

获取 扩展信息

source

pub fn extensions_mut(&mut self) -> &mut Extensions

获取扩展信息的可变引用

source

pub fn header(&self, header_name: impl AsHeaderName) -> Option<&HeaderValue>

获取 HTTP 响应 Header

source

pub fn server_ip(&self) -> Option<IpAddr>

获取 HTTP 服务器 IP 地址

source

pub fn server_ip_mut(&mut self) -> &mut Option<IpAddr>

获取 HTTP 服务器 IP 地址的可变引用

source

pub fn server_port(&self) -> Option<NonZeroU16>

获取 HTTP 服务器端口号

source

pub fn server_port_mut(&mut self) -> &mut Option<NonZeroU16>

获取 HTTP 服务器端口号的可变引用

source

pub fn metrics(&self) -> Option<&Metrics>

获取 HTTP 响应的指标信息

source

pub fn metrics_mut(&mut self) -> &mut Option<Metrics>

获取 HTTP 响应的指标信息的可变引用

Trait Implementations§

source§

impl<B: Debug> Debug for Response<B>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<B: Default> Default for Response<B>

source§

fn default() -> Response<B>

Returns the “default value” for a type. Read more
source§

impl<B> Deref for Response<B>

§

type Target = ResponseParts

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<B> DerefMut for Response<B>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<B> !RefUnwindSafe for Response<B>

§

impl<B> Send for Response<B>
where B: Send,

§

impl<B> Sync for Response<B>
where B: Sync,

§

impl<B> Unpin for Response<B>
where B: Unpin,

§

impl<B> !UnwindSafe for Response<B>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.