Skip to main content

Group

Struct Group 

Source
pub struct Group<I, R> { /* private fields */ }
Expand description

Routes sharing a path prefix and a default access.

A route that declares its own access keeps it; one that declares none takes the group’s.

use web_net::{App, Group, get};

let app = App::builder()
    .group(
        Group::new("/docs")
            .public()
            .route(get("/", |cx| { cx.text(200, "index"); Ok(()) }))
            .route(get("/:page", |cx| { cx.text(200, "page"); Ok(()) })),
    )
    .build()?;

Implementations§

Source§

impl<I: 'static, R> Group<I, R>

Source

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

A group under prefix (/admin).

Source

pub fn public(self) -> Self

Routes without their own access are public.

Source

pub fn allow(self, rule: R) -> Self

Routes without their own access need rule.

Source

pub fn route(self, route: Route<I, R>) -> Self

Adds a route; its pattern is joined to the prefix.

Source

pub fn group(self, group: Group<I, R>) -> Self

Adds a nested group; its prefix is joined to this one, and it takes this group’s access when it declares none.

Trait Implementations§

Source§

impl<I, R> Debug for Group<I, R>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<I, R> !RefUnwindSafe for Group<I, R>

§

impl<I, R> !UnwindSafe for Group<I, R>

§

impl<I, R> Forget for Group<I, R>

§

impl<I, R> Freeze for Group<I, R>
where Access<R>: Freeze, Vec<Route<I, R>>: Freeze,

§

impl<I, R> Send for Group<I, R>
where Access<R>: Send, Vec<Route<I, R>>: Send,

§

impl<I, R> Sync for Group<I, R>
where Access<R>: Sync, Vec<Route<I, R>>: Sync,

§

impl<I, R> Unpin for Group<I, R>
where Access<R>: Unpin, Vec<Route<I, R>>: Unpin,

§

impl<I, R> UnsafeUnpin for Group<I, R>
where Access<R>: UnsafeUnpin, Vec<Route<I, R>>: 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
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, 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.