pub struct IsolatedHandler<F> { /* private fields */ }Expand description
Wraps a handler function with panic isolation and cancellation checking.
This is a convenience for wrapping synchronous handlers that don’t need
the full RequestRegion API but still want isolation guarantees.
ⓘ
let handler = IsolatedHandler::new(|ctx| {
let id = ctx.path_param("id").unwrap_or("unknown");
Response::new(StatusCode::OK, format!("User: {id}"))
});
let cx = Cx::for_testing();
let req = Request::new("GET", "/users/42");
let resp = handler.call(&cx, req);
assert_eq!(resp.status, StatusCode::OK);Implementations§
Source§impl<F> IsolatedHandler<F>
impl<F> IsolatedHandler<F>
Auto Trait Implementations§
impl<F> Freeze for IsolatedHandler<F>where
F: Freeze,
impl<F> RefUnwindSafe for IsolatedHandler<F>where
F: RefUnwindSafe,
impl<F> Send for IsolatedHandler<F>where
F: Send,
impl<F> Sync for IsolatedHandler<F>where
F: Sync,
impl<F> Unpin for IsolatedHandler<F>where
F: Unpin,
impl<F> UnsafeUnpin for IsolatedHandler<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for IsolatedHandler<F>where
F: UnwindSafe,
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).