Skip to main content

Router

Struct Router 

Source
pub struct Router<S = ()> { /* private fields */ }
Expand description

Axum-like routing table using matchit under the hood.

Implementations§

Source§

impl<S> Router<S>
where S: Clone + Send + Sync + 'static,

Source

pub fn new() -> Self

Create a new empty Router.

Source

pub const fn normalize_trailing_slash(self) -> Self

Opt in to trailing-slash normalization: strips a single trailing / from the incoming request’s path before routing, so /foo and /foo/ reach the same route.

By default (matching Axum) routing is strict — /foo and /foo/ are distinct routes, and a mismatch 404s. This opts into the common convenience behavior natively, without pulling in tower/tower-http just for tower_http::normalize_path::NormalizePathLayer — this method mirrors that layer’s own semantics exactly (an in-place path normalization applied once per request, not a redirect), just built in.

Only meaningful on the outermost Router you actually .compile() (or hand to a Server) — like NormalizePathLayer, it operates on the whole incoming request before any route matching happens, so setting it on a router later merged/nested into another has no effect.

Source

pub fn no_index(self) -> Self

Opt out of search-engine indexing — appropriate default hardening for .onion/.i2p deployments, where a crawlable mirror is itself an unintentional discovery/deanonymization leak (some operators don’t realize search engines index onion mirrors at all).

Adds X-Robots-Tag: noindex, nofollow to every response from this router (routes and fallback alike), and — unless the app already registers its own /robots.txt route — serves a blanket User-agent: *\nDisallow: / there too.

§Example
use tachyon_web::{Router, get};

let router: Router = Router::new()
    .route("/", get(|| async { "hi" }))
    .no_index();
Source

pub fn with_state<S2>(self, state: S) -> Router<S2>
where S2: Clone + Send + Sync + 'static,

Set the application state for this router, transitioning it to another (typically ()) state type — matching Axum’s Router<S>::with_state<S2>(self, state: S) -> Router<S2> signature.

S2 is almost always inferred as () since a fully-stated router is normally handed straight to a Server, but leaving it generic (rather than hardcoding Router<()>) matches Axum’s nested-router pattern, where an inner router’s state is supplied by an outer router before the two are merged/nested and the outer router still has its own, different state type to resolve later.

Source

pub fn route(self, path: &str, method_router: MethodRouter<S>) -> Self

Add a route to the router.

Registering the same path more than once merges the method routers — e.g. .route("/x", get(a)).route("/x", post(b)) yields one route that answers both GET and POST — matching Axum. Registering the same method for the same path twice panics, also matching Axum.

Source

pub const fn into_make_service(self) -> Self

A dummy/compatibility method that returns the router itself, matching Axum’s API when preparing a router to be run with a server listener.

Source

pub fn serve_static(self, dir_path: impl AsRef<Path>) -> Self

Serve an entire directory as static files — the simplest, Nginx-like API.

Serves directly from disk on every request; it does not call static_dir::ServeDir::preload, so CacheConfig::enabled’s default of true has no effect here. Use serve_dir with a manually-preloaded ServeDir if you want the in-memory RAM cache.

Do not point dir_path at a directory that can ever contain files an untrusted user chose the bytes of (e.g. an upload folder mixed into the served tree) — see static_dir::ServeDir’s docs for why (in short: a user-supplied .svg served this way can carry an executable <script>).

§Example
use tachyon_web::Router;

// Serve ./public/ at /, with index.html as the default.
let router = Router::new()
    .serve_static("./public");
Source

pub fn serve_dir(self, prefix: &str, serve_dir: ServeDir) -> Self

Serve an entire static directory under a URL prefix with full configuration control.

Registers both an exact route (prefix) and a wildcard route (prefix/*path). Use serve_static() for the common case of serving a dir at /. See static_dir::ServeDir’s docs for the upload-safety warning before serving a directory that can contain user-supplied files.

Source

pub fn serve_file(self, path: &str, file_path: &str) -> Result<Self, Error>

Natively serve a specific file on a specific route.

The file is read once at startup into a Bytes buffer. Every subsequent request is served from that buffer with zero I/O and zero allocations, rivalling include_bytes! without inflating the binary.

§Errors

Returns an Err if the file cannot be read at startup.

Source

pub fn serve_file_dynamic(self, path: &str, file_path: &str) -> Self

Natively serve a specific file on a specific route dynamically.

The file is read from disk on every request. Ideal for large files that change frequently where startup preloading is undesirable.

Source

pub fn nest(self, prefix: &str, router: Self) -> Self

Nest another router under a given path prefix.

Seamlessly merges all routes from the sub-router into this router.

Matches Axum: handlers inside the nested router see a request Uri with prefix stripped (e.g. a request to /api/users/1 nested under /api sees /users/1), while crate::routing::extract::OriginalUri recovers the pre-strip, full path. Nesting is resolved once at compile() time — there’s no per-request recursive dispatch — so this is exactly as fast as a flat route table; only the one matched route’s prefix is ever stripped.

§Deviation from Axum: the inner router’s own fallback is not carried over

In real Axum, nesting mounts the whole inner Router as a recursive sub-service, so a request under prefix that the inner router’s own routes don’t match still reaches the inner router’s fallback before ever falling through to the outer one. Because this implementation flattens the inner router’s routes into the same top-level route table (the design that keeps nesting as fast as a flat lookup — see above), there is no separate inner dispatch step left for a per-nest fallback to hook into: any path under prefix that isn’t one of the inner router’s own registered routes simply falls through to whatever Router::fallback (or the default 404) is configured on the outermost router — the inner router’s own .fallback(...), if it set one, is never called. Use Router::fallback on the outer router (or register an explicit catch-all route under prefix) if you need a per-module 404 handler.

Source

pub fn merge(self, other: Self) -> Self

Merge another router’s routes into this router.

If exactly one of the two routers has a fallback (or a method_not_allowed_fallback) configured, the merged router adopts it — matching Axum, which does the same for Router::fallback. Unlike nest (where the inner router’s fallback is deliberately never reachable — it would only ever fire for a request the outer router’s own routing already decided was unmatched, which the outer fallback already handles), merge treats both routers as peers, so silently dropping one side’s fallback would silently change which handler answers unmatched requests.

§Panics

Panics if other defines a method for a path already registered in self, or if both routers already have a fallback/method_not_allowed_fallback configured — matching Axum’s Router::merge.

Source

pub fn route_service<Svc, RespBody>(self, path: &str, service: Svc) -> Self
where Svc: Service<Request<Bytes>, Response = Response<RespBody>> + Clone + Send + Sync + 'static, Svc::Future: Send + 'static, Svc::Error: Into<Error> + Send, RespBody: Body<Data = Bytes> + Send + 'static, RespBody::Error: Into<Error>,

Mount a raw tower::Service at path, handling every HTTP method.

Requires the tower feature. Prefer .route(path, get(handler)) with a native handler where possible — this exists to bridge in pre-built Tower/tower-http services (e.g. tower_http::services::ServeFile) without a rewrite.

Source

pub fn nest_service<Svc, RespBody>(self, prefix: &str, service: Svc) -> Self
where Svc: Service<Request<Bytes>, Response = Response<RespBody>> + Clone + Send + Sync + 'static, Svc::Future: Send + 'static, Svc::Error: Into<Error> + Send, RespBody: Body<Data = Bytes> + Send + 'static, RespBody::Error: Into<Error>,

Nest a raw tower::Service under prefix, with the mounted path rewritten relative to prefix before the service sees it (matching Axum’s nest_service).

Requires the tower feature.

Source

pub fn fallback_service<Svc, RespBody>(self, service: Svc) -> Self
where Svc: Service<Request<Bytes>, Response = Response<RespBody>> + Clone + Send + Sync + 'static, Svc::Future: Send + 'static, Svc::Error: Into<Error> + Send, RespBody: Body<Data = Bytes> + Send + 'static, RespBody::Error: Into<Error>,

Set a raw tower::Service as the fallback for unmatched paths.

Requires the tower feature.

Source

pub fn layer<L, RespBody>(self, layer: L) -> Self
where L: Layer<NextService<S>> + Clone + Send + Sync + 'static, L::Service: Service<Request<Bytes>, Response = Response<RespBody>> + Send + 'static, <L::Service as Service<Request<Bytes>>>::Future: Send + 'static, <L::Service as Service<Request<Bytes>>>::Error: Into<Error> + Send, RespBody: Body<Data = Bytes> + Send + 'static, RespBody::Error: Into<Error>,

Apply a tower::Layer to every route and the fallback in this router.

Requires the tower feature. Prefer .hoop()/.hoop_at() for new code — this exists to bridge in existing Tower/tower-http layers (tracing, compression, timeouts) without rewriting them as native middleware.

Source

pub fn route_layer<L, RespBody>(self, layer: L) -> Self
where L: Layer<NextService<S>> + Clone + Send + Sync + 'static, L::Service: Service<Request<Bytes>, Response = Response<RespBody>> + Send + 'static, <L::Service as Service<Request<Bytes>>>::Future: Send + 'static, <L::Service as Service<Request<Bytes>>>::Error: Into<Error> + Send, RespBody: Body<Data = Bytes> + Send + 'static, RespBody::Error: Into<Error>,

Apply a tower::Layer to every registered route, but not the fallback — matching Axum’s distinction between .layer() and .route_layer().

Requires the tower feature.

Source

pub fn fallback<H, T>(self, handler: H) -> Self
where H: Handler<T, S>, T: 'static,

Set a custom fallback handler for requests that don’t match any route.

Source

pub fn method_not_allowed_fallback<H, T>(self, handler: H) -> Self
where H: Handler<T, S>, T: 'static,

Set a custom fallback handler for requests whose path matches a route but whose method has no registered handler (the default is a bare 405 Method Not Allowed with an Allow header).

Source

pub fn hoop<F, Fut, Res>(self, middleware: F) -> Self
where F: Fn(Request<Body>, Next<S>) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send + 'static, Res: IntoResponse + Send + 'static,

Apply a middleware handler to ALL routes and the fallback registered in this Router.

Source

pub fn hoop_at<F, Fut, Res>( self, position: MiddlewarePosition, middleware: F, ) -> Self
where F: Fn(Request<Body>, Next<S>) -> Fut + Clone + Send + Sync + 'static, Fut: Future<Output = Res> + Send + 'static, Res: IntoResponse + Send + 'static,

Apply a middleware handler at a specific position (First/Last) to ALL routes and the fallback.

Source

pub async fn handle_request(&self, req: Request<Body>) -> Response<Body>
where S: Default,

Route an incoming request directly, compiling the router on the fly. Primarily useful for testing.

§Panics

Panics if router compilation fails (e.g. a duplicate route was registered).

Source

pub fn compile(self) -> Result<CompiledRouter<S>, RouterError>
where S: Default,

Build and compile the routing tree, returning a CompiledRouter.

§Errors

Returns RouterError::DuplicateRoute if the same literal path somehow reaches compile() twice. In practice this can’t happen through the public API — route()/nest()/merge() all merge same-path entries (panicking on overlapping methods, matching Axum) — this is an internal invariant check, not a condition callers need to handle.

Trait Implementations§

Source§

impl<S: Clone> Clone for Router<S>

Source§

fn clone(&self) -> Router<S>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S> Debug for Router<S>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<S> Default for Router<S>
where S: Clone + Send + Sync + 'static,

Source§

fn default() -> Self

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

impl<B> Service<Request<B>> for Router<()>
where B: Body<Data = Bytes> + Send + 'static, B::Error: Into<Error>,

Lets an uncompiled, stateless crate::routing::Router be driven directly as a tower::Service — e.g. Router::new().route(...).oneshot(req) — with no separate .compile() call, matching axum::Router’s drop-in ergonomics exactly: build with .route()/.nest()/.merge()/.hoop()/ etc., then hand the same value straight to .oneshot(), a tower server, or anything else expecting a Service.

Internally this compiles the matchit route tree once, the first time call() runs, and caches the result in Router’s private compiled field — every builder method that mutates the route table resets that cache, so it’s impossible to silently dispatch against a stale tree. Every call after the first is exactly as cheap as calling the already-CompiledRouter directly; the split from axum::Router (which has no separate compiled form at all) is now purely internal.

Deliberately restricted to Router<()>, matching Axum exactly (Axum only implements Service for Router<()> too — a Router<S> for S != () hasn’t been given its state yet, so there’s nothing meaningful to serve). This is what makes plain Router::new().route(...).oneshot(req) type-check with no turbofish: Service has exactly one impl to unify against, same as in Axum. A router built with real shared state (State<T> extractors) still needs .with_state(actual_state) first, same as Axum — at that point it’s already a Router<()> too. For testing a still-generic Router<S>/CompiledRouter<S> for S != () directly, use CompiledRouter’s broader impl above via an explicit .compile().

use tachyon_web::{Router, get};
use tower::ServiceExt;

async fn handler() -> &'static str { "hi" }

let app = Router::new().route("/", get(handler));
let req = hyper::Request::builder().uri("/").body(http_body_util::Full::new(bytes::Bytes::new()))?;
let resp = app.oneshot(req).await?;
Source§

type Response = Response<Body>

Responses given by the service.
Source§

type Error = Infallible

Errors produced by the service.
Source§

type Future = Pin<Box<dyn Future<Output = Result<<Router as Service<Request<B>>>::Response, <Router as Service<Request<B>>>::Error>> + Send>>

The future response value.
Source§

fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more
Source§

fn call(&mut self, req: Request<B>) -> Self::Future

Process the request and return the response asynchronously. Read more

Auto Trait Implementations§

§

impl<S = ()> !Freeze for Router<S>

§

impl<S = ()> !RefUnwindSafe for Router<S>

§

impl<S = ()> !UnwindSafe for Router<S>

§

impl<S> Send for Router<S>
where S: Sync + Send,

§

impl<S> Sync for Router<S>
where S: Sync + Send,

§

impl<S> Unpin for Router<S>

§

impl<S> UnsafeUnpin for Router<S>

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

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

Source§

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

Source§

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

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

Source§

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

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(state: &T) -> T

Extract a reference/clone from the parent state.
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 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
Source§

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

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> PossiblyOption<T> for T

Source§

fn to_option(self) -> Option<T>

Convert this object into an Option<T>
Source§

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, Request> ServiceExt<Request> for T
where T: Service<Request> + ?Sized,

Source§

fn ready(&mut self) -> Ready<'_, Self, Request>
where Self: Sized,

Yields a mutable reference to the service when it is ready to accept a request.
Source§

fn ready_oneshot(self) -> ReadyOneshot<Self, Request>
where Self: Sized,

Yields the service when it is ready to accept a request.
Source§

fn oneshot(self, req: Request) -> Oneshot<Self, Request>
where Self: Sized,

Consume this Service, calling it with the provided request once it is ready.
Source§

fn call_all<S>(self, reqs: S) -> CallAll<Self, S>
where Self: Sized, S: Stream<Item = Request>,

Process all requests from the given Stream, and produce a Stream of their responses. Read more
Source§

fn and_then<F>(self, f: F) -> AndThen<Self, F>
where Self: Sized, F: Clone,

Executes a new future after this service’s future resolves. This does not alter the behaviour of the poll_ready method. Read more
Source§

fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
where Self: Sized, F: FnOnce(Self::Response) -> Response + Clone,

Maps this service’s response value to a different value. This does not alter the behaviour of the poll_ready method. Read more
Source§

fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
where Self: Sized, F: FnOnce(Self::Error) -> Error + Clone,

Maps this service’s error value to a different value. This does not alter the behaviour of the poll_ready method. Read more
Source§

fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
where Self: Sized, Error: From<Self::Error>, F: FnOnce(Result<Self::Response, Self::Error>) -> Result<Response, Error> + Clone,

Maps this service’s result type (Result<Self::Response, Self::Error>) to a different value, regardless of whether the future succeeds or fails. Read more
Source§

fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>
where Self: Sized, F: FnMut(NewRequest) -> Request,

Composes a function in front of the service. Read more
Source§

fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F>
where Self: Sized, Error: From<Self::Error>, F: FnOnce(Result<Self::Response, Self::Error>) -> Fut + Clone, Fut: Future<Output = Result<Response, Error>>,

Composes an asynchronous function after this service. Read more
Source§

fn map_future<F, Fut, Response, Error>(self, f: F) -> MapFuture<Self, F>
where Self: Sized, F: FnMut(Self::Future) -> Fut, Error: From<Self::Error>, Fut: Future<Output = Result<Response, Error>>,

Composes a function that transforms futures produced by the service. Read more
Source§

fn boxed(self) -> BoxService<Request, Self::Response, Self::Error>
where Self: Sized + Send + 'static, Self::Future: Send + 'static,

Convert the service into a Service + Send trait object. Read more
Source§

fn boxed_clone(self) -> BoxCloneService<Request, Self::Response, Self::Error>
where Self: Sized + Clone + Send + 'static, Self::Future: Send + 'static,

Convert the service into a Service + Clone + Send trait object. Read more
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
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.
Source§

impl<T, U> Upcast<T> for U
where T: UpcastFrom<U>,

Source§

fn upcast(self) -> T

Source§

impl<T, B> UpcastFrom<Counter<T, B>> for T

Source§

fn upcast_from(value: Counter<T, B>) -> T

Source§

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

Source§

fn vzip(self) -> V

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