pub struct Path<T>(pub T);Expand description
Typed path-parameter extractor (axum parity).
T may be a single primitive (Path<u64>), a tuple (Path<(u64, String)>),
a Vec<T> for repeated captures, an Option<T> (None when no captures
matched), or a struct deriving serde::Deserialize.
Internally delegates to the path-params deserializer in tako-core, which
has been extended in v2 to support tuples, sequences, and primitive
destructuring on top of the original struct/map mode.
§Examples
ⓘ
use tako::extractors::path::Path;
// Single primitive
async fn by_id(Path(id): Path<u64>) -> String { format!("id={id}") }
// Tuple
async fn pair(Path((a, b)): Path<(String, u32)>) -> String { format!("{a}/{b}") }
// Struct
#[derive(serde::Deserialize)]
struct UserKey { tenant: String, user_id: u64 }
async fn user(Path(key): Path<UserKey>) -> String {
format!("{}:{}", key.tenant, key.user_id)
}Tuple Fields§
§0: TTrait Implementations§
Source§impl<'a, T> FromRequest<'a> for Path<T>where
T: DeserializeOwned + Send + 'a,
impl<'a, T> FromRequest<'a> for Path<T>where
T: DeserializeOwned + Send + 'a,
Source§impl<'a, T> FromRequestParts<'a> for Path<T>where
T: DeserializeOwned + Send + 'a,
impl<'a, T> FromRequestParts<'a> for Path<T>where
T: DeserializeOwned + Send + 'a,
Source§type Error = ParamsError
type Error = ParamsError
Error type returned when extraction fails.
Auto Trait Implementations§
impl<T> Freeze for Path<T>where
T: Freeze,
impl<T> RefUnwindSafe for Path<T>where
T: RefUnwindSafe,
impl<T> Send for Path<T>where
T: Send,
impl<T> Sync for Path<T>where
T: Sync,
impl<T> Unpin for Path<T>where
T: Unpin,
impl<T> UnsafeUnpin for Path<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Path<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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