Struct BoxService

Source
pub struct BoxService<Req, Res, Err> { /* private fields */ }
Expand description

装箱的Service特征对象。

BoxService将服务转换为特征对象并装箱,允许Service::Future是动态的。

如果需要一个实现Clone的装箱服务,考虑使用BoxCloneServiceRcService

Implementations§

Source§

impl<Req, Res, Err> BoxService<Req, Res, Err>

Source

pub fn new<S>(inner: S) -> BoxService<Req, Res, Err>
where S: Service<Req, Response = Res, Error = Err> + 'static, <S as Service<Req>>::Future: 'static,

Trait Implementations§

Source§

impl<Req, Res, Err> Debug for BoxService<Req, Res, Err>

Source§

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

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

impl<Req, Res, Err> Service<Req> for BoxService<Req, Res, Err>

Source§

type Response = Res

服务返回的响应。
Source§

type Error = Err

服务产生的错误。
Source§

type Future = Pin<Box<dyn Future<Output = Result<Res, Err>>>>

异步返回的响应。
Source§

fn call(&self, request: Req) -> Pin<Box<dyn Future<Output = Result<Res, Err>>>>

处理请求并异步返回响应。

Auto Trait Implementations§

§

impl<Req, Res, Err> Freeze for BoxService<Req, Res, Err>

§

impl<Req, Res, Err> !RefUnwindSafe for BoxService<Req, Res, Err>

§

impl<Req, Res, Err> !Send for BoxService<Req, Res, Err>

§

impl<Req, Res, Err> !Sync for BoxService<Req, Res, Err>

§

impl<Req, Res, Err> Unpin for BoxService<Req, Res, Err>

§

impl<Req, Res, Err> !UnwindSafe for BoxService<Req, Res, Err>

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<S, Req> ServiceExt<Req> for S
where S: Service<Req>,

Source§

fn with<T>(self, wrap: T) -> <T as Wrap<Self>>::Service
where Self: Sized, T: Wrap<Self>,

Source§

fn and_then<F>(self, f: F) -> AndThen<Self, F>
where Self: Sized,

Source§

fn then<F>(self, f: F) -> Then<Self, F>
where Self: Sized,

Source§

fn map_err<F>(self, f: F) -> MapErr<Self, F>
where Self: Sized,

Source§

fn map_future<F>(self, f: F) -> MapFuture<Self, F>
where Self: Sized,

Source§

fn map_request<F>(self, f: F) -> MapRequest<Self, F>
where Self: Sized,

Source§

fn map_response<F>(self, f: F) -> MapResponse<Self, F>
where Self: Sized,

Source§

fn map_result<F>(self, f: F) -> MapResult<Self, F>
where Self: Sized,

Source§

fn boxed(self) -> BoxService<Req, Self::Response, Self::Error>
where Self: Sized + 'static, Self::Future: 'static,

Source§

fn boxed_clone(self) -> BoxCloneService<Req, Self::Response, Self::Error>
where Self: Sized + Clone + 'static, Self::Future: 'static,

Source§

fn rc_boxed(self) -> RcService<Req, Self::Response, Self::Error>
where Self: Sized + 'static, Self::Future: 'static,

Source§

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

Source§

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>,

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.