pub struct RouterBuilder<TCtx = (), TMeta = (), TMiddleware = BaseMiddleware<TCtx>>where
TCtx: Send + Sync + 'static,
TMeta: Send + 'static,
TMiddleware: MiddlewareBuilderLike<TCtx> + Send + 'static,{ /* private fields */ }Implementations§
Source§impl<TCtx, TMeta> RouterBuilder<TCtx, TMeta, BaseMiddleware<TCtx>>
impl<TCtx, TMeta> RouterBuilder<TCtx, TMeta, BaseMiddleware<TCtx>>
Source§impl<TCtx, TLayerCtx, TMeta, TMiddleware> RouterBuilder<TCtx, TMeta, TMiddleware>
impl<TCtx, TLayerCtx, TMeta, TMiddleware> RouterBuilder<TCtx, TMeta, TMiddleware>
Sourcepub fn config(self, config: Config) -> Self
pub fn config(self, config: Config) -> Self
Attach a configuration to the router. Calling this multiple times will overwrite the previous config.
pub fn middleware<TNewMiddleware, TNewLayerCtx>(
self,
builder: impl Fn(MiddlewareBuilder<TLayerCtx>) -> TNewMiddleware,
) -> RouterBuilder<TCtx, TMeta, MiddlewareLayerBuilder<TCtx, TLayerCtx, TNewLayerCtx, TMiddleware, TNewMiddleware>>where
TNewLayerCtx: Send + Sync + 'static,
TNewMiddleware: MiddlewareLike<TLayerCtx, NewCtx = TNewLayerCtx> + Send + Sync + 'static,
pub fn query<TResolver, TArg, TResult, TResultMarker>(
self,
key: &'static str,
builder: impl Fn(UnbuiltProcedureBuilder<TLayerCtx, TResolver>) -> BuiltProcedureBuilder<TResolver>,
) -> Selfwhere
TArg: DeserializeOwned + Type,
TResult: RequestLayer<TResultMarker>,
TResolver: Fn(TLayerCtx, TArg) -> TResult + Send + Sync + 'static,
pub fn mutation<TResolver, TArg, TResult, TResultMarker>(
self,
key: &'static str,
builder: impl Fn(UnbuiltProcedureBuilder<TLayerCtx, TResolver>) -> BuiltProcedureBuilder<TResolver>,
) -> Selfwhere
TArg: DeserializeOwned + Type,
TResult: RequestLayer<TResultMarker>,
TResolver: Fn(TLayerCtx, TArg) -> TResult + Send + Sync + 'static,
pub fn subscription<TResolver, TArg, TStream, TResult, TResultMarker>(
self,
key: &'static str,
builder: impl Fn(UnbuiltProcedureBuilder<TLayerCtx, TResolver>) -> BuiltProcedureBuilder<TResolver>,
) -> Selfwhere
TArg: DeserializeOwned + Type,
TStream: Stream<Item = TResult> + Send + 'static,
TResult: Serialize + Type,
TResolver: Fn(TLayerCtx, TArg) -> TStream + StreamResolver<TLayerCtx, DoubleArgStreamMarker<TArg, TResultMarker, TStream>> + Send + Sync + 'static,
pub fn merge<TNewLayerCtx, TIncomingMiddleware>(
self,
prefix: &'static str,
router: RouterBuilder<TLayerCtx, TMeta, TIncomingMiddleware>,
) -> Selfwhere
TNewLayerCtx: 'static,
TIncomingMiddleware: MiddlewareBuilderLike<TLayerCtx, LayerContext = TNewLayerCtx> + Send + 'static,
Sourcepub fn legacy_merge<TNewLayerCtx, TIncomingMiddleware>(
self,
prefix: &'static str,
router: RouterBuilder<TLayerCtx, TMeta, TIncomingMiddleware>,
) -> RouterBuilder<TCtx, TMeta, MiddlewareMerger<TCtx, TLayerCtx, TNewLayerCtx, TMiddleware, TIncomingMiddleware>>where
TNewLayerCtx: 'static,
TIncomingMiddleware: MiddlewareBuilderLike<TLayerCtx, LayerContext = TNewLayerCtx> + Send + 'static,
pub fn legacy_merge<TNewLayerCtx, TIncomingMiddleware>(
self,
prefix: &'static str,
router: RouterBuilder<TLayerCtx, TMeta, TIncomingMiddleware>,
) -> RouterBuilder<TCtx, TMeta, MiddlewareMerger<TCtx, TLayerCtx, TNewLayerCtx, TMiddleware, TIncomingMiddleware>>where
TNewLayerCtx: 'static,
TIncomingMiddleware: MiddlewareBuilderLike<TLayerCtx, LayerContext = TNewLayerCtx> + Send + 'static,
legacy_merge maintains the merge functionality prior to release 0.1.3
It will flow the TMiddleware and TCtx out of the child router to the parent router.
This was a confusing behavior and is generally not useful so it has been deprecated.
This function will be remove in a future release. If you are using it open a GitHub issue to discuss your use case and longer term solutions for it.
pub fn build(self) -> Router<TCtx, TMeta>
Auto Trait Implementations§
impl<TCtx, TMeta, TMiddleware> Freeze for RouterBuilder<TCtx, TMeta, TMiddleware>where
TMiddleware: Freeze,
impl<TCtx = (), TMeta = (), TMiddleware = BaseMiddleware<TCtx>> !RefUnwindSafe for RouterBuilder<TCtx, TMeta, TMiddleware>
impl<TCtx, TMeta, TMiddleware> Send for RouterBuilder<TCtx, TMeta, TMiddleware>
impl<TCtx, TMeta, TMiddleware> Sync for RouterBuilder<TCtx, TMeta, TMiddleware>
impl<TCtx, TMeta, TMiddleware> Unpin for RouterBuilder<TCtx, TMeta, TMiddleware>
impl<TCtx = (), TMeta = (), TMiddleware = BaseMiddleware<TCtx>> !UnwindSafe for RouterBuilder<TCtx, TMeta, TMiddleware>
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