Struct RouteSegment

Source
pub struct RouteSegment<State> { /* private fields */ }
Expand description

A Builder for Tide routes. RouteBuilders can be composed into a tree that represents the tree of path segments, middleware and endpoints that defines the routes in a Tide application. This tree can then be returned as a list of routes to each of the endpoints.

Implementations§

Source§

impl<State: Clone + Send + Sync + 'static> RouteSegment<State>

Source

pub fn reverse_router(&self) -> ReverseRouter

Construct a reverse router for the paths in the route builder

Trait Implementations§

Source§

impl<State: Debug> Debug for RouteSegment<State>

Source§

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

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

impl<State: Clone + Send + Sync + 'static> RouteBuilder<State> for RouteSegment<State>

Source§

fn at<R: FnOnce(Self) -> Self>(self, path: &str, routes: R) -> Self

Add a path segment with a set of sub-routes
Source§

fn with<M: Middleware<State>, R: FnOnce(Self) -> Self>( self, middleware: M, routes: R, ) -> Self

Add middleware with a set of sub-routes
Source§

fn method(self, method: Method, endpoint: impl Endpoint<State>) -> Self

Add an endpoint for an http method
Source§

fn all(self, endpoint: impl Endpoint<State>) -> Self

Add a catchall endpoint
Source§

fn name(self, name: &str) -> Self

Make this a named route

Auto Trait Implementations§

§

impl<State> Freeze for RouteSegment<State>

§

impl<State> !RefUnwindSafe for RouteSegment<State>

§

impl<State> Send for RouteSegment<State>

§

impl<State> Sync for RouteSegment<State>

§

impl<State> Unpin for RouteSegment<State>

§

impl<State> !UnwindSafe for RouteSegment<State>

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> 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<State, R> RouteBuilderExt<State> for R
where State: Clone + Send + Sync + 'static, R: RouteBuilder<State>,

Source§

fn get(self, endpoint: impl Endpoint<State>) -> Self

Add an HTTP GET endpoint
Source§

fn head(self, endpoint: impl Endpoint<State>) -> Self

Add an HTTP HEAD endpoint
Source§

fn put(self, endpoint: impl Endpoint<State>) -> Self

Add an HTTP PUT endpoint
Source§

fn post(self, endpoint: impl Endpoint<State>) -> Self

Add an HTTP POST endpoint
Source§

fn delete(self, endpoint: impl Endpoint<State>) -> Self

Add an HTTP DELETE endpoint
Source§

fn options(self, endpoint: impl Endpoint<State>) -> Self

Add an HTTP OPTIONS endpoint
Source§

fn connect(self, endpoint: impl Endpoint<State>) -> Self

Add an HTTP CONNECT endpoint
Source§

fn patch(self, endpoint: impl Endpoint<State>) -> Self

Add an HTTP PATCH endpoint
Source§

fn trace(self, endpoint: impl Endpoint<State>) -> Self

Add an HTTP TRACE endpoint
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<State, R> ServeFs<State> for R
where State: Clone + Send + Sync + 'static, R: RouteBuilder<State>,

Source§

fn serve_dir(self, dir: impl AsRef<Path>) -> Result<Self>

Serve a directory at a location
Source§

fn serve_file(self, file: impl AsRef<Path>) -> Result<Self>

Same as serve_dir, but for a single file
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<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
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T