Struct ServiceFn

Source
pub struct ServiceFn<F> { /* private fields */ }
Expand description

将给定的异步函数转换为 Service

Trait Implementations§

Source§

impl<F: Clone> Clone for ServiceFn<F>

Source§

fn clone(&self) -> ServiceFn<F>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F> Debug for ServiceFn<F>

Source§

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

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

impl<F, Fut, Req, Res, Err> Service<Req> for ServiceFn<F>
where F: Fn(Req) -> Fut + Send + Sync, Fut: Future<Output = Result<Res, Err>> + Send,

Source§

type Response = Res

服务返回的响应。
Source§

type Error = Err

服务产生的错误。
Source§

fn call( &self, req: Req, ) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send

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

impl<F: Copy> Copy for ServiceFn<F>

Auto Trait Implementations§

§

impl<F> Freeze for ServiceFn<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for ServiceFn<F>
where F: RefUnwindSafe,

§

impl<F> Send for ServiceFn<F>
where F: Send,

§

impl<F> Sync for ServiceFn<F>
where F: Sync,

§

impl<F> Unpin for ServiceFn<F>
where F: Unpin,

§

impl<F> UnwindSafe for ServiceFn<F>
where F: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> + ?Sized,

Source§

fn with<T, R>(self, middleware: T) -> T::Service
where Self: Sized, T: Middleware<Self>, T::Service: Service<R>,

在此服务上应用中间件。 Read more
Source§

fn then<F, Fut, Res, Err>(self, f: F) -> Then<Self, F>
where Self: Sized, F: Fn(Result<Self::Response, Self::Error>) -> Fut + Send + Sync, Fut: Future<Output = Result<Res, Err>> + Send,

在此服务执行完成后执行给定的异步函数。 Read more
Source§

fn and_then<F, Fut, Res>(self, f: F) -> AndThen<Self, F>
where Self: Sized, F: Fn(Self::Response) -> Fut + Send + Sync, Fut: Future<Output = Result<Res, Self::Error>> + Send,

在此服务执行成功后执行给定的异步函数。 Read more
Source§

fn or_else<F, Fut, Err>(self, f: F) -> OrElse<Self, F>
where Self: Sized, F: Fn(Self::Error) -> Fut + Send + Sync, Fut: Future<Output = Result<Self::Response, Err>> + Send,

在此服务执行失败后执行给定的异步函数。 Read more
Source§

fn map_result<F, Res, Err>(self, f: F) -> MapResult<Self, F>
where Self: Sized, F: Fn(Result<Self::Response, Self::Error>) -> Result<Res, Err> + Send + Sync,

将此服务返回的结果映射为其他值。 Read more
Source§

fn map_response<F, Res>(self, f: F) -> MapResponse<Self, F>
where Self: Sized, F: Fn(Self::Response) -> Res + Send + Sync,

将此服务返回的响应映射为其他值。 Read more
Source§

fn map_err<F, Err>(self, f: F) -> MapErr<Self, F>
where Self: Sized, F: Fn(Self::Error) -> Err + Send + Sync,

将此服务返回的错误映射为其他值。 Read more
Source§

fn map_request<F, R>(self, f: F) -> MapRequest<Self, F>
where Self: Sized, F: Fn(R) -> Req + Send + Sync,

将发送给此服务的请求映射为其他值。 Read more
Source§

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

将此服务转换为 Service 特征对象并装箱。 Read more
Source§

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

将此服务转换为 Service 特征对象并装箱。 Read more
Source§

fn boxed_arc(self) -> ArcService<Req, Self::Response, Self::Error>
where Self: Sized + 'static,

将此服务转换为 Service 特征对象并装箱。 Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.