pub struct NegotiatedResponse<T, Formats> { /* private fields */ }Expand description
A response that holds a domain value and negotiates the best content type
based on the Accept header.
T is the domain type, Formats is a tuple of format markers
(e.g., (JsonFormat, TextFormat)).
Implements IntoResponse when Formats: NegotiateFormats<T>.
Implementations§
Source§impl<T, Formats> NegotiatedResponse<T, Formats>
impl<T, Formats> NegotiatedResponse<T, Formats>
Sourcepub fn new(value: T, accept: Option<String>) -> Self
pub fn new(value: T, accept: Option<String>) -> Self
Create a new negotiated response.
accept should be the value of the Accept header from the request,
or None if absent. Use the AcceptHeader extractor to obtain this.
Trait Implementations§
Source§impl<T, Formats> IntoResponse for NegotiatedResponse<T, Formats>where
Formats: NegotiateFormats<T>,
impl<T, Formats> IntoResponse for NegotiatedResponse<T, Formats>where
Formats: NegotiateFormats<T>,
Source§fn into_response(self) -> Response<BoxBody>
fn into_response(self) -> Response<BoxBody>
Convert this value into an HTTP response.
Auto Trait Implementations§
impl<T, Formats> Freeze for NegotiatedResponse<T, Formats>where
T: Freeze,
impl<T, Formats> RefUnwindSafe for NegotiatedResponse<T, Formats>where
T: RefUnwindSafe,
Formats: RefUnwindSafe,
impl<T, Formats> Send for NegotiatedResponse<T, Formats>
impl<T, Formats> Sync for NegotiatedResponse<T, Formats>
impl<T, Formats> Unpin for NegotiatedResponse<T, Formats>
impl<T, Formats> UnsafeUnpin for NegotiatedResponse<T, Formats>where
T: UnsafeUnpin,
impl<T, Formats> UnwindSafe for NegotiatedResponse<T, Formats>where
T: UnwindSafe,
Formats: 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