pub struct BoundAs<M: Model, K: ParamKey>(pub M, _);Expand description
A model resolved from a named route parameter.
For the route with two of them, where the convention cannot say which:
ⓘ
router.get("/posts/{post}/comments/{comment}", show);
pub async fn show(
post: BoundAs<Post, PostParam>,
comment: BoundAs<Comment, CommentParam>,
) -> Result<Response> {
Ok(Response::json(&comment.into_inner()))
}The parameter name is a type, because an extractor’s configuration has to
live in its type — there is nowhere else for it to come from. Declare one
with param_key!.
Tuple Fields§
§0: MImplementations§
Trait Implementations§
Source§impl<M: Model, K: ParamKey> FromRequest for BoundAs<M, K>
impl<M: Model, K: ParamKey> FromRequest for BoundAs<M, K>
Source§fn from_request(request: Arc<Request>) -> BoxedFuture<Result<Self>>
fn from_request(request: Arc<Request>) -> BoxedFuture<Result<Self>>
Build
Self from the request, or fail with the error the client should
see (a 400 for a malformed body, a 422 for a failed contract).Auto Trait Implementations§
impl<M, K> Freeze for BoundAs<M, K>where
M: Freeze,
impl<M, K> RefUnwindSafe for BoundAs<M, K>where
M: RefUnwindSafe,
impl<M, K> Send for BoundAs<M, K>
impl<M, K> Sync for BoundAs<M, K>
impl<M, K> Unpin for BoundAs<M, K>where
M: Unpin,
impl<M, K> UnsafeUnpin for BoundAs<M, K>where
M: UnsafeUnpin,
impl<M, K> UnwindSafe for BoundAs<M, K>where
M: 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T, A> DynAccess<T> for A
impl<T, A> DynAccess<T> for A
Source§fn load(&self) -> DynGuard<T>
fn load(&self) -> DynGuard<T>
The equivalent of
Access::load.Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
A human-readable name, used by wildcard listeners and log output.
Always the Rust type path; see the trait docs.
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 moreCreates a shared type from an unshared type.