pub struct Accept(/* private fields */);
Expand description
Extractor for the request’s desired response ContentType
.
§Examples
ⓘ
#[axum_codec::apply(encode)]
struct User {
name: String,
age: u8,
}
fn get_user(accept: Accept) -> impl IntoResponse {
Codec(User {
name: "Alice".into(),
age: 42,
})
.to_response(accept)
}
Implementations§
Source§impl Accept
impl Accept
Sourcepub fn content_type(self) -> ContentType
pub fn content_type(self) -> ContentType
Returns the request’s desired response ContentType
.
Trait Implementations§
Source§impl From<Accept> for ContentType
impl From<Accept> for ContentType
Source§impl<S> FromRequestParts<S> for Accept
impl<S> FromRequestParts<S> for Accept
impl Copy for Accept
Auto Trait Implementations§
impl Freeze for Accept
impl RefUnwindSafe for Accept
impl Send for Accept
impl Sync for Accept
impl Unpin for Accept
impl UnwindSafe for Accept
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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§async fn from_request(
req: Request<Body>,
state: &S,
) -> Result<T, <T as FromRequest<S, ViaParts>>::Rejection>
async fn from_request( req: Request<Body>, state: &S, ) -> Result<T, <T as FromRequest<S, ViaParts>>::Rejection>
Perform the extraction.