pub struct VldPath<T>(pub T);Expand description
Axum extractor that validates URL path parameters.
Drop-in replacement for axum::extract::Path<T>.
Path segment values are coerced the same way as query parameters.
§Example
ⓘ
// Route: /users/{id}/posts/{post_id}
vld::schema! {
#[derive(Debug)]
pub struct PostPath {
pub id: i64 => vld::number().int().min(1),
pub post_id: i64 => vld::number().int().min(1),
}
}
async fn get_post(VldPath(p): VldPath<PostPath>) -> String {
format!("user {} post {}", p.id, p.post_id)
}Tuple Fields§
§0: TTrait Implementations§
Source§impl<S, T> FromRequestParts<S> for VldPath<T>
impl<S, T> FromRequestParts<S> for VldPath<T>
Auto Trait Implementations§
impl<T> Freeze for VldPath<T>where
T: Freeze,
impl<T> RefUnwindSafe for VldPath<T>where
T: RefUnwindSafe,
impl<T> Send for VldPath<T>where
T: Send,
impl<T> Sync for VldPath<T>where
T: Sync,
impl<T> Unpin for VldPath<T>where
T: Unpin,
impl<T> UnsafeUnpin for VldPath<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for VldPath<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<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
Source§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
Perform the extraction.