pub struct BoxService<T, U, E> { /* private fields */ }
util
only.Expand description
A boxed Service + Send
trait object.
BoxService
turns a service into a trait object, allowing the response
future type to be dynamic. This type requires both the service and the
response future to be Send
.
If you need a boxed Service
that implements Clone
consider using
BoxCloneService
.
Dynamically dispatched Service
objects allow for erasing the underlying
Service
type and using the Service
instances as opaque handles. This can
be useful when the service instance cannot be explicitly named for whatever
reason.
§Examples
use futures_util::future::ready;
// Respond to requests using a closure, but closures cannot be named...
let svc = service_fn(|mut request: String| {
request.push_str(" response");
ready(Ok(request))
});
let service: BoxService<String, String, ()> = BoxService::new(svc);
}
Implementations§
Source§impl<T, U, E> BoxService<T, U, E>
impl<T, U, E> BoxService<T, U, E>
Trait Implementations§
Source§impl<T, U, E> Debug for BoxService<T, U, E>
impl<T, U, E> Debug for BoxService<T, U, E>
Auto Trait Implementations§
impl<T, U, E> Freeze for BoxService<T, U, E>
impl<T, U, E> !RefUnwindSafe for BoxService<T, U, E>
impl<T, U, E> Send for BoxService<T, U, E>
impl<T, U, E> Sync for BoxService<T, U, E>
impl<T, U, E> Unpin for BoxService<T, U, E>
impl<T, U, E> !UnwindSafe for BoxService<T, U, E>
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
Source§impl<T, Request> ServiceExt<Request> for T
impl<T, Request> ServiceExt<Request> for T
Source§fn ready(&mut self) -> Ready<'_, Self, Request> ⓘwhere
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request> ⓘwhere
Self: Sized,
util
only.Source§fn ready_oneshot(self) -> ReadyOneshot<Self, Request> ⓘwhere
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request> ⓘwhere
Self: Sized,
util
only.Source§fn oneshot(self, req: Request) -> Oneshot<Self, Request> ⓘwhere
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request> ⓘwhere
Self: Sized,
util
only.Service
, calling it with the provided request once it is ready.Source§fn and_then<F>(self, f: F) -> AndThen<Self, F>
fn and_then<F>(self, f: F) -> AndThen<Self, F>
util
only.poll_ready
method. Read moreSource§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
util
only.poll_ready
method. Read moreSource§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
util
only.poll_ready
method. Read moreSource§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
util
only.Result<Self::Response, Self::Error>
)
to a different value, regardless of whether the future succeeds or
fails. Read moreSource§fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
util
only.Source§fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F>
fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F>
util
only.Source§fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F>
fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F>
util
only.Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes