MCPcopy Create free account
hub / github.com/HFQR/xitca-web / handler_sync_service

Function handler_sync_service

web/src/handler/sync.rs:37–47  ·  view source on GitHub ↗

synchronous version of [handler_service] `handler_sync_service` run given function on a separate thread pool from the event loop and async logic of xitca-web itself. Therefore it comes with different requirement of function argument compared to [handler_service] where the arguments must be types that impl [FromRequest] trait, being thread safe with `Send` trait bound and with `'static` lifetime.

(func: F)

Source from the content-addressed store, hash-verified

35///
36/// [handler_service]: super::handler_service
37pub fn handler_sync_service<Arg, F, T>(func: F) -> FnService<impl AsyncFn(Arg) -> FnServiceOutput<F, T>>
38where
39 F: Closure<T> + Send + Clone,
40{
41 fn_build(async move |_| {
42 Ok(HandlerServiceSync {
43 func: func.clone(),
44 _p: PhantomData,
45 })
46 })
47}
48
49type FnServiceOutput<F, T> = Result<HandlerServiceSync<F, T>, Infallible>;
50

Callers 1

mainFunction · 0.85

Calls 2

fn_buildFunction · 0.85
cloneMethod · 0.45

Tested by

no test coverage detected