Skip to main content

Router

Struct Router 

pub struct Router<State = (), Layer = DefaultEndpointLayer, O = Response, E = RouterError> { /* private fields */ }
Available on crate features http and std only.
Expand description

A basic router that can be used to route requests to different services based on the request path.

Each route compiles to a PathPattern; on lookup the most-specific matching pattern wins (static segments beat captures beat catch-alls). Nested services are mounted under a prefix via a typed PathRouter. Path matching uses PathMatchPolicy::default unless an explicit policy is selected at construction with Router::new_with_path_match_policy or Router::new_with_state_and_path_match_policy. Routers created by Router::with_sub_router_make_fn inherit that policy. A separately constructed router passed to Router::with_sub_service retains its own policy; the parent policy still governs its mount prefix.

use rama_http::service::web::{PathMatchPolicy, Router};

let default_router: Router = Router::new();
assert_eq!(default_router.path_match_policy(), PathMatchPolicy::default());

let strict_router: Router =
    Router::new_with_path_match_policy(PathMatchPolicy::STRICT);
assert_eq!(strict_router.path_match_policy(), PathMatchPolicy::STRICT);

Implementations§

§

impl<O, E> Router<(), DefaultEndpointLayer, O, E>

pub fn new() -> Router<(), DefaultEndpointLayer, O, E>

create a new router.

pub fn new_with_path_match_policy( path_match_policy: PathMatchPolicy, ) -> Router<(), DefaultEndpointLayer, O, E>

Create a new router with an explicit path-matching policy.

The policy applies consistently to ordinary routes, fallback routes, captures, wildcards, and mounted prefixes.

§

impl<State, O, E> Router<State, DefaultEndpointLayer, O, E>
where State: Send + Sync + Clone + 'static,

pub fn new_with_state(state: State) -> Router<State, DefaultEndpointLayer, O, E>

Create a new router with state

pub fn new_with_state_and_path_match_policy( state: State, path_match_policy: PathMatchPolicy, ) -> Router<State, DefaultEndpointLayer, O, E>

Create a new router with state and an explicit path-matching policy.

The policy applies consistently to ordinary routes, fallback routes, captures, wildcards, and mounted prefixes.

§

impl<State, L, O, E> Router<State, L, O, E>
where State: Send + Sync + Clone + 'static,

pub fn state(&self) -> &State

Get reference to the state.

pub const fn path_match_policy(&self) -> PathMatchPolicy

Return the immutable path-matching policy selected at construction.

pub fn with_endpoint_layer<N>(self, layer: N) -> Router<State, N, O, E>

Apply layer to every endpoint registered after this call.

Routes registered before this call keep whatever layer was in effect at the time of registration.

pub fn with_default_endpoint_layer( self, ) -> Router<State, DefaultEndpointLayer, O, E>

Apply DefaultEndpointLayer to every endpoint registered after this call.

Routes registered before this call keep whatever layer was in effect at the time of registration.

pub fn with_get<I, T>( self, path: impl AsRef<str>, service: I, ) -> Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a GET route to the router. the path can contain parameters, e.g. /users/{id}. the path can also contain a catch call, e.g. /assets/{*path}.

pub fn set_get<I, T>( &mut self, path: impl AsRef<str>, service: I, ) -> &mut Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a GET route to the router. the path can contain parameters, e.g. /users/{id}. the path can also contain a catch call, e.g. /assets/{*path}.

pub fn with_post<I, T>( self, path: impl AsRef<str>, service: I, ) -> Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a POST route to the router.

pub fn set_post<I, T>( &mut self, path: impl AsRef<str>, service: I, ) -> &mut Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a POST route to the router.

pub fn with_put<I, T>( self, path: impl AsRef<str>, service: I, ) -> Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a PUT route to the router.

pub fn set_put<I, T>( &mut self, path: impl AsRef<str>, service: I, ) -> &mut Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a PUT route to the router.

pub fn with_delete<I, T>( self, path: impl AsRef<str>, service: I, ) -> Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a DELETE route to the router.

pub fn set_delete<I, T>( &mut self, path: impl AsRef<str>, service: I, ) -> &mut Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a DELETE route to the router.

pub fn with_patch<I, T>( self, path: impl AsRef<str>, service: I, ) -> Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a PATCH route to the router.

pub fn set_patch<I, T>( &mut self, path: impl AsRef<str>, service: I, ) -> &mut Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a PATCH route to the router.

pub fn with_head<I, T>( self, path: impl AsRef<str>, service: I, ) -> Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a HEAD route to the router.

pub fn set_head<I, T>( &mut self, path: impl AsRef<str>, service: I, ) -> &mut Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a HEAD route to the router.

pub fn with_options<I, T>( self, path: impl AsRef<str>, service: I, ) -> Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a OPTIONS route to the router.

pub fn set_options<I, T>( &mut self, path: impl AsRef<str>, service: I, ) -> &mut Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a OPTIONS route to the router.

pub fn with_trace<I, T>( self, path: impl AsRef<str>, service: I, ) -> Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a TRACE route to the router.

pub fn set_trace<I, T>( &mut self, path: impl AsRef<str>, service: I, ) -> &mut Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a TRACE route to the router.

pub fn with_connect<I, T>( self, path: impl AsRef<str>, service: I, ) -> Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a CONNECT route to the router.

pub fn set_connect<I, T>( &mut self, path: impl AsRef<str>, service: I, ) -> &mut Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a CONNECT route to the router.

pub fn with_query<I, T>( self, path: impl AsRef<str>, service: I, ) -> Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a QUERY route to the router.

QUERY (RFC 10008) is a safe, idempotent method whose request content defines the query.

pub fn set_query<I, T>( &mut self, path: impl AsRef<str>, service: I, ) -> &mut Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

add a QUERY route to the router.

pub fn with_sub_router_make_fn<Layer>( self, prefix: impl AsRef<str>, configure_router: impl FnOnce(Router<State, L, O, E>) -> Router<State, Layer, O, E>, ) -> Router<State, L, O, E>
where L: Clone, Router<State, Layer, O, E>: Service<Request, Output = O, Error = E>,

register a nested router under a prefix (path).

The prefix is used to match the request path and strip it from the request URI.

Note: this sub-router is configured with the same State this router has.

pub fn set_sub_router_make_fn<Layer>( &mut self, prefix: impl AsRef<str>, configure_router: impl FnOnce(Router<State, L, O, E>) -> Router<State, Layer, O, E>, ) -> &mut Router<State, L, O, E>
where L: Clone, Router<State, Layer, O, E>: Service<Request, Output = O, Error = E>,

register a nested router under a prefix (path).

The prefix is used to match the request path and strip it from the request URI.

Note: this sub-router is configured with the same State this router has.

pub fn with_endpoint_service<I, T>( self, prefix: impl AsRef<str>, service: I, ) -> Router<State, L, O, E>
where I: IntoEndpointService<T>, L: Layer<<I as IntoEndpointService<T>>::Service>, <L as Layer<<I as IntoEndpointService<T>>::Service>>::Service: Service<Request, Output = O, Error = E>,

Register a nested endpoint service under a prefix (path).

The prefix is used to match the request path and strip it from the request URI. Endpoint layer is applied to this sub-service.

Warning: If a sub-service is a plain Service, not an endpoint function, it has no notion of the state this router has. If you want to create a sub-router that shares the same state this router has, use Router::with_sub_router_make_fn instead.

pub fn set_endpoint_service<I, T>( &mut self, prefix: impl AsRef<str>, service: I, ) -> &mut Router<State, L, O, E>
where I: IntoEndpointService<T>, L: Layer<<I as IntoEndpointService<T>>::Service>, <L as Layer<<I as IntoEndpointService<T>>::Service>>::Service: Service<Request, Output = O, Error = E>,

Register a nested endpoint service under a prefix (path).

The prefix is used to match the request path and strip it from the request URI. Endpoint layer is applied to this sub-service.

Warning: If a sub-service is a plain Service, not an endpoint function, it has no notion of the state this router has. If you want to create a sub-router that shares the same state this router has, use Router::with_sub_router_make_fn instead.

pub fn with_sub_service<S>( self, prefix: impl AsRef<str>, service: S, ) -> Router<State, L, O, E>
where S: Service<Request, Output = O, Error = E>,

Register a nested service under a prefix (path).

The prefix is used to match the request path and strip it from the request URI.

Warning: This sub-service has no notion of the state this router has. If you want to create a sub-router that shares the same state this router has, use Router::with_sub_router_make_fn instead. Also, the endpoint layer is not applied to it, so its Output / Error must match those of the Router If you need its type conversions, consider Router::with_endpoint_service

A separately constructed Router used as the service retains its own path policy. This router’s policy applies only to the mount prefix.

pub fn set_sub_service<S>( &mut self, prefix: impl AsRef<str>, service: S, ) -> &mut Router<State, L, O, E>
where S: Service<Request, Output = O, Error = E>,

Register a nested service under a prefix.

The prefix is used to match the request path and strip it from the request URI.

Warning: This sub-service has no notion of the state this router has. If you want to create a sub-router that shares the same state this router has, use Router::with_sub_router_make_fn instead. Also, the endpoint layer is not applied to it, so its Output / Error must match those of the Router If you need its type conversions, consider Router::set_endpoint_service

pub fn with_match_route<I, T>( self, path: impl AsRef<str>, matcher: HttpMatcher<Body>, service: I, ) -> Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

Add a route to the router with its matcher and service.

The route path uses the router’s policy. Any path patterns inside matcher retain the policy explicitly selected for that matcher.

pub fn set_match_route<I, T>( &mut self, path: impl AsRef<str>, matcher: HttpMatcher<Body>, service: I, ) -> &mut Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

Add a route to the router with its matcher and service.

The route path uses the router’s policy. Any path patterns inside matcher retain the policy explicitly selected for that matcher.

pub fn with_fallback_match_route<I, T>( self, path: impl AsRef<str>, matcher: HttpMatcher<Body>, service: I, ) -> Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

Add a route fallback evaluated after ordinary handlers and mounted sub-services for the same request path.

This is useful for protocol-specific error responses that must not shadow another handler sharing the path. A matching fallback runs only when no ordinary handler or mounted sub-service accepted the request, and before the router produces its generic 405 or 404 response. The fallback path uses the router’s policy; path patterns inside matcher retain their own explicitly selected policy.

pub fn set_fallback_match_route<I, T>( &mut self, path: impl AsRef<str>, matcher: HttpMatcher<Body>, service: I, ) -> &mut Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

Add a route fallback evaluated after ordinary handlers and mounted sub-services for the same request path.

The fallback path uses the router’s policy; path patterns inside matcher retain their own explicitly selected policy.

pub fn with_not_found<I, T>(self, service: I) -> Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

use the provided service when no route matches the request.

pub fn set_not_found<I, T>(&mut self, service: I) -> &mut Router<State, L, O, E>
where I: IntoEndpointServiceWithState<T, State>, L: Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>, <L as Layer<<I as IntoEndpointServiceWithState<T, State>>::Service>>::Service: Service<Request, Output = O, Error = E>,

use the provided service when no route matches the request.

Trait Implementations§

§

impl<S, L, O, E> Debug for Router<S, L, O, E>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for Router

§

fn default() -> Router

Returns the “default value” for a type. Read more
§

impl<State, L, O, E> RouterExt<State, L, O, E> for Router<State, L, O, E>
where State: Send + Sync + Clone + 'static,

§

fn with_grpc_service<S>(self, service: S) -> Router<State, L, O, E>
where S: Service<Request> + NamedService, L: Layer<S> + Layer<UnsupportedGrpcContentType>, <L as Layer<S>>::Service: Service<Request, Output = O, Error = E>, <L as Layer<UnsupportedGrpcContentType>>::Service: Service<Request, Output = O, Error = E>,

Register a generated gRPC service and return the updated router. Read more
§

fn set_grpc_service<S>(&mut self, service: S) -> &mut Router<State, L, O, E>
where S: Service<Request> + NamedService, L: Layer<S> + Layer<UnsupportedGrpcContentType>, <L as Layer<S>>::Service: Service<Request, Output = O, Error = E>, <L as Layer<UnsupportedGrpcContentType>>::Service: Service<Request, Output = O, Error = E>,

Register a generated gRPC service on this router. Read more
§

impl<State, L, O, E> Service<Request> for Router<State, L, O, E>
where O: Send + 'static, E: Send + From<RouterError> + 'static, L: Send + Sync + 'static, State: Send + Sync + Clone + 'static,

§

type Output = O

The type of the output returned by the service.
§

type Error = E

The type of error returned by the service.
§

async fn serve( &self, req: Request, ) -> Result<<Router<State, L, O, E> as Service<Request>>::Output, <Router<State, L, O, E> as Service<Request>>::Error>

Serve an output or an error for the given input
§

fn boxed(self) -> BoxService<Input, Self::Output, Self::Error>

Box this service to allow for dynamic dispatch.

Auto Trait Implementations§

§

impl<State = (), Layer = DefaultEndpointLayer, O = Response, E = RouterError> !RefUnwindSafe for Router<State, Layer, O, E>

§

impl<State = (), Layer = DefaultEndpointLayer, O = Response, E = RouterError> !UnwindSafe for Router<State, Layer, O, E>

§

impl<State, Layer, O, E> Freeze for Router<State, Layer, O, E>
where Vec<RouteEntry<O, E>>: Freeze, Option<PathRouter<SubService<O, E>>>: Freeze, Option<BoxService<Request, O, E>>: Freeze, Layer: Freeze, State: Freeze,

§

impl<State, Layer, O, E> Send for Router<State, Layer, O, E>
where Vec<RouteEntry<O, E>>: Send, Option<PathRouter<SubService<O, E>>>: Send, Option<BoxService<Request, O, E>>: Send, Layer: Send, State: Send,

§

impl<State, Layer, O, E> Sync for Router<State, Layer, O, E>
where Vec<RouteEntry<O, E>>: Sync, Option<PathRouter<SubService<O, E>>>: Sync, Option<BoxService<Request, O, E>>: Sync, Layer: Sync, State: Sync,

§

impl<State, Layer, O, E> Unpin for Router<State, Layer, O, E>
where Vec<RouteEntry<O, E>>: Unpin, Option<PathRouter<SubService<O, E>>>: Unpin, Option<BoxService<Request, O, E>>: Unpin, Layer: Unpin, State: Unpin,

§

impl<State, Layer, O, E> UnsafeUnpin for Router<State, Layer, O, E>
where Vec<RouteEntry<O, E>>: UnsafeUnpin, Option<PathRouter<SubService<O, E>>>: UnsafeUnpin, Option<BoxService<Request, O, E>>: UnsafeUnpin, Layer: UnsafeUnpin, State: UnsafeUnpin,

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<S, Input, Connection> ConnectorService<Input> for S
where S: Service<Input, Output = EstablishedClientConnection<Connection, Input>>, <S as Service<Input>>::Error: Into<ConnectionError>, Connection: Send + ExtensionsRef,

§

type Connection = Connection

Connection returned by the ConnectorService
§

fn connect( &self, input: Input, ) -> impl Future<Output = Result<EstablishedClientConnection<<S as ConnectorService<Input>>::Connection, Input>, ConnectionError>> + Send

Establish a connection, which often involves some kind of handshake, or connection revival. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T, ReqBody, ResBody> GrpcService<ReqBody> for T
where T: Service<Request<ReqBody>, Output = Response<ResBody>>, <T as Service<Request<ReqBody>>>::Error: Into<Box<dyn Error + Send + Sync>>, ResBody: Body, <ResBody as Body>::Error: Into<Box<dyn Error + Send + Sync>>,

§

type ResponseBody = ResBody

Responses body given by the service.
§

type Error = <T as Service<Request<ReqBody>>>::Error

Errors produced by the service.
§

fn serve( &self, request: Request<ReqBody>, ) -> impl Future<Output = Result<Response<<T as GrpcService<ReqBody>>::ResponseBody>, <T as GrpcService<ReqBody>>::Error>> + Send

Process the request and return the response asynchronously. Read more
§

impl<S, Body> HttpClientExt for S
where S: Service<Request, Output = Response<Body>>, <S as Service<Request>>::Error: Into<Box<dyn Error + Send + Sync>>,

§

type ExecuteResponse = Response<Body>

The response type returned by the execute method.
§

type ExecuteError = <S as Service<Request>>::Error

The error type returned by the execute method.
§

fn get( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>

Convenience method to make a GET request to a URL. Read more
§

fn post( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>

Convenience method to make a POST request to a URL. Read more
§

fn put( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>

Convenience method to make a PUT request to a URL. Read more
§

fn patch( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>

Convenience method to make a PATCH request to a URL. Read more
§

fn delete( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>

Convenience method to make a DELETE request to a URL. Read more
§

fn head( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>

Convenience method to make a HEAD request to a URL. Read more
§

fn connect( &self, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>

Convenience method to make a CONNECT request to a URL. Read more
§

fn request( &self, method: Method, url: impl IntoUrl, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>

Start building a Request with the Method and Url. Read more
§

fn build_from_request<RequestBody>( &self, request: Request<RequestBody>, ) -> RequestBuilder<'_, S, <S as HttpClientExt>::ExecuteResponse>
where RequestBody: Into<Body>,

Start building a Request, using the given Request. Read more
§

fn execute( &self, request: Request, ) -> impl Future<Output = Result<<S as HttpClientExt>::ExecuteResponse, <S as HttpClientExt>::ExecuteError>>

Executes a Request. Read more
§

impl<S, Body> HttpClientWebSocketExt<Body> for S
where S: Service<Request, Output = Response<Body>>, <S as Service<Request>>::Error: Into<Box<dyn Error + Send + Sync>>,

§

fn websocket( &self, url: impl IntoUrl, ) -> WebSocketRequestBuilder<WithService<'_, S, Body>>

Create a new WebSocketRequestBuilder] to be used to establish a WebSocket connection over http/1.1.
§

fn websocket_h2( &self, url: impl IntoUrl, ) -> WebSocketRequestBuilder<WithService<'_, S, Body>>

Create a new WebSocketRequestBuilder to be used to establish a WebSocket connection over h2.
§

fn websocket_with_request<RequestBody>( &self, req: Request<RequestBody>, ) -> WebSocketRequestBuilder<WithService<'_, S, Body>>
where RequestBody: Into<Body>,

Create a new WebSocketRequestBuilder starting from the given request. Read more
§

impl<T> Instrument for T

§

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

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

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 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<S> IntoEndpointService<(S,)> for S
where S: Service<Request>,

§

type Service = S

§

fn into_endpoint_service(self) -> <S as IntoEndpointService<(S,)>>::Service

convert the type into a rama_core::Service.
§

impl<S, State> IntoEndpointServiceWithState<(S,), State> for S
where S: Service<Request>,

§

type Service = S

§

fn into_endpoint_service_with_state( self, _state: State, ) -> <S as IntoEndpointServiceWithState<(S,), State>>::Service

convert the type into a rama_core::Service with state.
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a rama_grpc::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

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

§

fn rama_from(value: T) -> U

§

impl<T, U, CrateMarker> RamaInto<U, CrateMarker> for T
where U: RamaFrom<T, CrateMarker>,

§

fn rama_into(self) -> U

§

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

§

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

§

fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>

§

impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for T
where U: RamaTryFrom<T, CrateMarker>,

§

type Error = <U as RamaTryFrom<T, CrateMarker>>::Error

§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<V, F> ValueFormatter<&V> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &&V)

Write value to writer
§

impl<V, F> ValueFormatter<Arc<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Arc<V>)

Write value to writer
§

impl<V, F> ValueFormatter<Box<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Box<V>)

Write value to writer
§

impl<V, F> ValueFormatter<Cow<'_, V>> for F
where V: ToOwned + ?Sized, F: ValueFormatter<V> + ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)

Write value to writer
§

impl<V, F> ValueFormatter<Option<V>> for F
where F: ValueFormatter<V> + ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Option<V>)

Write value to writer
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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