pub struct BoxedHandler { /* private fields */ }Expand description
Type-erased handler for storing in collections.
While Handler uses associated types for zero-cost abstraction,
we need type erasure to store different handlers in the same Vec.
This type performs the erasure while keeping the actual handler call as optimized as possible via vtable dispatch with inlined inner handlers.
Implementations§
Source§impl BoxedHandler
impl BoxedHandler
Sourcepub fn new<H: Handler>(handler: H) -> Self
pub fn new<H: Handler>(handler: H) -> Self
Create a new boxed handler from any Handler.
The handler is wrapped in an Arc for cheap cloning.
Sourcepub fn call(
&self,
req: HttpRequest,
) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Error>> + Send>>
pub fn call( &self, req: HttpRequest, ) -> Pin<Box<dyn Future<Output = Result<HttpResponse, Error>> + Send>>
Call the handler.
This goes through a vtable but the actual handler implementation is monomorphized and can be inlined within the wrapper.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BoxedHandler
impl !RefUnwindSafe for BoxedHandler
impl Send for BoxedHandler
impl Sync for BoxedHandler
impl Unpin for BoxedHandler
impl !UnwindSafe for BoxedHandler
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Injectable for T
impl<T> Injectable for T
Source§fn type_id_of() -> TypeIdwhere
Self: Sized,
fn type_id_of() -> TypeIdwhere
Self: Sized,
Returns the TypeId of this type (for internal use)
Source§fn type_name_of() -> &'static strwhere
Self: Sized,
fn type_name_of() -> &'static strwhere
Self: Sized,
Returns the type name for debugging