Struct NestedPath

pub struct NestedPath(/* private field */);

Access the path the matched the route is nested at.

This can for example be used when doing redirects.

Example

use axum::{
    Router,
    extract::NestedPath,
    routing::get,
};

let api = Router::new().route(
    "/users",
    get(|path: NestedPath| async move {
        // `path` will be "/api" because that's what this
        // router is nested at when we build `app`
        let path = path.as_str();
    })
);

let app = Router::new().nest("/api", api);
# let _: Router = app;

Implementations

impl NestedPath

fn as_str(&self) -> &str

Returns a str representation of the path.

Trait Implementations

impl Clone for NestedPath

fn clone(&self) -> NestedPath

impl Debug for NestedPath

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

impl<S> FromRequestParts<S> for NestedPath where S: Send + Sync,

type Rejection = NestedPathRejection;
async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result<Self, Self::Rejection>

Auto Trait Implementations

impl Freeze for NestedPath

impl RefUnwindSafe for NestedPath

impl Send for NestedPath

impl Sync for NestedPath

impl Unpin for NestedPath

impl UnsafeUnpin for NestedPath

impl UnwindSafe for NestedPath

Blanket Implementations

impl<S, T> FromRequest<S, ViaParts> for NestedPath where S: Send + Sync, T: FromRequestParts<S>,

type Rejection = <T as FromRequestParts<S>>::Rejection;
fn from_request(req: Request<Body>, state: &S) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>

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

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

impl<T> Any for NestedPath where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for NestedPath where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for NestedPath where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

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

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

impl<T> From<T> for NestedPath

fn from(t: T) -> T

Returns the argument unchanged.

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

fn from_ref(input: &T) -> T

impl<T> Instrument for NestedPath

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

impl<T> Same for NestedPath

type Output = T;

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

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> WithSubscriber for NestedPath

impl<T, U> Into<U> for NestedPath where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

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

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for NestedPath where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

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

fn vzip(self) -> V