Struct RouterBuilder

Source
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>>
where TCtx: Send + Sync + 'static, TMeta: Send + 'static,

Source

pub fn new() -> Self

Source§

impl<TCtx, TLayerCtx, TMeta, TMiddleware> RouterBuilder<TCtx, TMeta, TMiddleware>
where TCtx: Send + Sync + 'static, TMeta: Send + 'static, TLayerCtx: Send + Sync + 'static, TMiddleware: MiddlewareBuilderLike<TCtx, LayerContext = TLayerCtx> + Send + 'static,

Source

pub fn config(self, config: Config) -> Self

Attach a configuration to the router. Calling this multiple times will overwrite the previous config.

Source

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,

Source

pub fn query<TResolver, TArg, TResult, TResultMarker>( self, key: &'static str, builder: impl Fn(UnbuiltProcedureBuilder<TLayerCtx, TResolver>) -> BuiltProcedureBuilder<TResolver>, ) -> Self
where TArg: DeserializeOwned + Type, TResult: RequestLayer<TResultMarker>, TResolver: Fn(TLayerCtx, TArg) -> TResult + Send + Sync + 'static,

Source

pub fn mutation<TResolver, TArg, TResult, TResultMarker>( self, key: &'static str, builder: impl Fn(UnbuiltProcedureBuilder<TLayerCtx, TResolver>) -> BuiltProcedureBuilder<TResolver>, ) -> Self
where TArg: DeserializeOwned + Type, TResult: RequestLayer<TResultMarker>, TResolver: Fn(TLayerCtx, TArg) -> TResult + Send + Sync + 'static,

Source

pub fn subscription<TResolver, TArg, TStream, TResult, TResultMarker>( self, key: &'static str, builder: impl Fn(UnbuiltProcedureBuilder<TLayerCtx, TResolver>) -> BuiltProcedureBuilder<TResolver>, ) -> Self
where 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,

Source

pub fn merge<TNewLayerCtx, TIncomingMiddleware>( self, prefix: &'static str, router: RouterBuilder<TLayerCtx, TMeta, TIncomingMiddleware>, ) -> Self
where TNewLayerCtx: 'static, TIncomingMiddleware: MiddlewareBuilderLike<TLayerCtx, LayerContext = TNewLayerCtx> + Send + 'static,

Source

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.

Source

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>
where TMiddleware: Sync, TMeta: Sync,

§

impl<TCtx, TMeta, TMiddleware> Unpin for RouterBuilder<TCtx, TMeta, TMiddleware>
where TMiddleware: Unpin, TMeta: Unpin,

§

impl<TCtx = (), TMeta = (), TMiddleware = BaseMiddleware<TCtx>> !UnwindSafe for RouterBuilder<TCtx, TMeta, TMiddleware>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.