Skip to main content

Module

Struct Module 

Source
pub struct Module { /* private fields */ }
Expand description

Flask’s Blueprint, Rust-grade. Built by route crates’ pub fn module().

Implementations§

Source§

impl Module

Source

pub fn new(name: impl Into<String>) -> Self

Source

pub fn route(self, path: &str, methods: MethodRouter) -> Self

Register a path relative to the module’s mount point.

Source

pub fn mount(self, prefix: &str, child: Module) -> Self

Mount a child module (subroute) under a relative prefix. Nests arbitrarily.

Source

pub fn provide<T: Send + Sync + 'static>(self, value: T) -> Self

Module-scoped singleton value; shadows any parent provider of the same type.

Source

pub fn provide_dep<F, Args, T>(self, factory: F) -> Self
where F: DepFactory<Args, T>, T: Send + Sync + 'static,

Module-scoped async factory (request scope); shadows parents likewise.

Source

pub fn middleware<M: Middleware>(self, mw: M) -> Self

Module-scoped middleware; runs after the app’s and parents’ middleware.

Source

pub fn name(&self) -> &str

The module’s name. Reserved for diagnostics and route-map introspection in a later phase; it currently has no runtime consumer.

Auto Trait Implementations§

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<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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.