Skip to main content

WebResponseOf

Struct WebResponseOf 

Source
pub struct WebResponseOf<T> { /* private fields */ }
Expand description

声明载荷类型的 WebResponse 包装。

运行时行为与 WebResponse 完全一致,状态码、响应头与响应体通过 Deref / DerefMut 直接访问。仅用于让 web_api* / ts_api 宏在显式构造 WebResponse(自定义响应头、 状态码等)时推导出实际载荷类型,从而导出准确的 TypeScript 返回类型。 仅返回二进制或流式响应时仍直接使用 WebResponse。

Implementations§

Source§

impl<T> WebResponseOf<T>

Source

pub fn from_t(value: T, request: Option<&WebRequest>) -> Self
where T: Serialize,

序列化载荷并构造 200 响应。

Source

pub fn from_result_t(result: Result<T>, request: Option<&WebRequest>) -> Self
where T: Serialize,

序列化载荷结果并构造响应,失败时返回错误响应。

Source

pub fn from_response(response: WebResponse) -> Self

包装已构造的响应。

Source

pub fn into_response(self) -> WebResponse

取出底层响应。

Trait Implementations§

Source§

impl<T> Deref for WebResponseOf<T>

Source§

type Target = WebResponse

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl<T> DerefMut for WebResponseOf<T>

Source§

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

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<T> !Freeze for WebResponseOf<T>

§

impl<T> !RefUnwindSafe for WebResponseOf<T>

§

impl<T> !Sync for WebResponseOf<T>

§

impl<T> !UnwindSafe for WebResponseOf<T>

§

impl<T> Send for WebResponseOf<T>
where PhantomData<fn() -> T>: Send,

§

impl<T> Unpin for WebResponseOf<T>
where PhantomData<fn() -> T>: Unpin,

§

impl<T> UnsafeUnpin for WebResponseOf<T>
where PhantomData<fn() -> T>: UnsafeUnpin,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more