pub struct AssociatedRouteBuilder<'a, M, C, P, PE, QSE>where
    M: RouteMatcher + Send + Sync + 'static,
    C: PipelineHandleChain<P> + Copy + Send + Sync + 'static,
    P: RefUnwindSafe + Send + Sync + 'static,
    PE: PathExtractor<Body> + Send + Sync + 'static,
    QSE: QueryStringExtractor<Body> + Send + Sync + 'static,{ /* private fields */ }
Expand description

Implements the methods required for associating a number of routes with a single path. This is used by DrawRoutes::associated.

Implementations§

source§

impl<'a, C, P, PE, QSE> AssociatedRouteBuilder<'a, AnyRouteMatcher, C, P, PE, QSE>where C: PipelineHandleChain<P> + Copy + Send + Sync + 'static, P: RefUnwindSafe + Send + Sync + 'static, PE: PathExtractor<Body> + Send + Sync + 'static, QSE: QueryStringExtractor<Body> + Send + Sync + 'static,

source

pub fn new( node_builder: &'a mut Node, pipeline_chain: C, pipelines: PipelineSet<P> ) -> Self

Create an instance of AssociatedRouteBuilder

source§

impl<'a, M, C, P, PE, QSE> AssociatedRouteBuilder<'a, M, C, P, PE, QSE>where M: RouteMatcher + Send + Sync + 'static, C: PipelineHandleChain<P> + Copy + Send + Sync + 'static, P: RefUnwindSafe + Send + Sync + 'static, PE: PathExtractor<Body> + Send + Sync + 'static, QSE: QueryStringExtractor<Body> + Send + Sync + 'static,

source

pub fn add_route_matcher<'b, NM>( &'b mut self, matcher: NM ) -> AssociatedRouteBuilder<'b, AndRouteMatcher<M, NM>, C, P, PE, QSE>where NM: RouteMatcher + Send + Sync + 'static,

Adds aadditional RouteMatcher requirements to all subsequently associated routes.

Examples
build_simple_router(|route| {
    let matcher = AcceptHeaderRouteMatcher::new(vec![mime::APPLICATION_JSON]);

    route.associate("/resource/path", |assoc| {
        let mut assoc = assoc.add_route_matcher(matcher);

        assoc.get().to(my_handler);
    });
})
source

pub fn with_path_extractor<'b, NPE>( &'b mut self ) -> AssociatedRouteBuilder<'b, M, C, P, NPE, QSE>where NPE: PathExtractor<Body> + Send + Sync + 'static,

Binds a new PathExtractor to the associated routes.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

#[derive(Deserialize, StateData, StaticResponseExtender)]
struct MyPathExtractor {
    id: u32,
}

build_simple_router(|route| {
    route.associate("/resource/:id", |assoc| {
        let mut assoc = assoc.with_path_extractor::<MyPathExtractor>();
        assoc.get().to(handler);
    });
})
source

pub fn with_query_string_extractor<'b, NQSE>( &'b mut self ) -> AssociatedRouteBuilder<'b, M, C, P, PE, NQSE>where NQSE: QueryStringExtractor<Body> + Send + Sync + 'static,

Binds a new QueryStringExtractor to the associated routes.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

#[derive(StateData, Deserialize, StaticResponseExtender)]
struct MyQueryStringExtractor {
    val: String,
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        let mut assoc = assoc.with_query_string_extractor::<MyQueryStringExtractor>();
        assoc.get().to(handler);
    });
})
source

pub fn request<'b>( &'b mut self, methods: Vec<Method> ) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>

Associates a route which matches requests with any of the specified methods, to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.request(vec![Method::GET, Method::HEAD, Method::POST]).to(handler);
    });
})
source

pub fn head<'b>( &'b mut self ) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>

Associates a route which matches HEAD requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.head().to(handler);
    });
})
source

pub fn get_or_head<'b>( &'b mut self ) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>

Associates a route which matches GET or HEAD requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.get_or_head().to(handler);
    });
})
source

pub fn get<'b>( &'b mut self ) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>

Associates a route which matches GET requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.get().to(handler);
    });
})
source

pub fn post<'b>( &'b mut self ) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>

Associates a route which matches POST requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.post().to(handler);
    });
})
source

pub fn put<'b>( &'b mut self ) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>

Associates a route which matches PUT requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.put().to(handler);
    });
})
source

pub fn patch<'b>( &'b mut self ) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>

Associates a route which matches PATCH requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.patch().to(handler);
    });
})
source

pub fn delete<'b>( &'b mut self ) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>

Associates a route which matches DELETE requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.delete().to(handler);
    });
})
source

pub fn options<'b>( &'b mut self ) -> AssociatedSingleRouteBuilder<'b, AndRouteMatcher<MethodOnlyRouteMatcher, M>, C, P, PE, QSE>

Associates a route which matches OPTIONS requests to the current path.

Examples
fn handler(state: State) -> (State, Response<Body>) {
    // Implementation elided.
}

build_simple_router(|route| {
    route.associate("/resource", |assoc| {
        assoc.options().to(handler);
    });
})

Auto Trait Implementations§

§

impl<'a, M, C, P, PE, QSE> RefUnwindSafe for AssociatedRouteBuilder<'a, M, C, P, PE, QSE>

§

impl<'a, M, C, P, PE, QSE> Send for AssociatedRouteBuilder<'a, M, C, P, PE, QSE>

§

impl<'a, M, C, P, PE, QSE> Sync for AssociatedRouteBuilder<'a, M, C, P, PE, QSE>

§

impl<'a, M, C, P, PE, QSE> Unpin for AssociatedRouteBuilder<'a, M, C, P, PE, QSE>where C: Unpin, M: Unpin, PE: Unpin, QSE: Unpin,

§

impl<'a, M, C, P, PE, QSE> !UnwindSafe for AssociatedRouteBuilder<'a, M, C, P, PE, QSE>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more