pub struct HttpResponseCreated<T: HttpResponseContent + Send + Sync + 'static>(pub T);Expand description
HttpResponseCreated<T: Serialize> wraps an object of any serializable type.
It denotes an HTTP 201 “Created” response whose body is generated by
serializing the object.
Tuple Fields§
§0: TImplementations§
Source§impl<T: HttpResponseContent + Send + Sync + 'static> HttpResponseCreated<T>
impl<T: HttpResponseContent + Send + Sync + 'static> HttpResponseCreated<T>
Sourcepub fn map<U, F>(self, f: F) -> HttpResponseCreated<U>
pub fn map<U, F>(self, f: F) -> HttpResponseCreated<U>
Convert this response into one with a different type parameter; this may be useful when multiple, related endpoints return similar response types that are convertible into a common type.
Sourcepub fn try_map<U, E, F>(self, f: F) -> Result<HttpResponseCreated<U>, E>
pub fn try_map<U, E, F>(self, f: F) -> Result<HttpResponseCreated<U>, E>
Similar to HttpResponseCreated::map but with support for
fallibility.
Trait Implementations§
Source§impl<T: HttpResponseContent + Send + Sync + 'static> From<HttpResponseCreated<T>> for Result<Response<Body>, HttpError>
impl<T: HttpResponseContent + Send + Sync + 'static> From<HttpResponseCreated<T>> for Result<Response<Body>, HttpError>
Source§impl<T: HttpResponseContent + Send + Sync + 'static> HttpCodedResponse for HttpResponseCreated<T>
impl<T: HttpResponseContent + Send + Sync + 'static> HttpCodedResponse for HttpResponseCreated<T>
const STATUS_CODE: StatusCode = StatusCode::CREATED
const DESCRIPTION: &'static str = "successful creation"
type Body = T
Source§fn for_object(body: Self::Body) -> Result<Response<Body>, HttpError>
fn for_object(body: Self::Body) -> Result<Response<Body>, HttpError>
Convenience method to produce a response based on the input
body_object (whose specific type is defined by the implementing type)
and the STATUS_CODE specified by the implementing type. This is a default
trait method to allow callers to avoid redundant type specification.Auto Trait Implementations§
impl<T> Freeze for HttpResponseCreated<T>where
T: Freeze,
impl<T> RefUnwindSafe for HttpResponseCreated<T>where
T: RefUnwindSafe,
impl<T> Send for HttpResponseCreated<T>
impl<T> Sync for HttpResponseCreated<T>
impl<T> Unpin for HttpResponseCreated<T>where
T: Unpin,
impl<T> UnwindSafe for HttpResponseCreated<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> HttpResponse for Twhere
T: HttpCodedResponse,
impl<T> HttpResponse for Twhere
T: HttpCodedResponse,
Source§fn to_result(self) -> Result<Response<Body>, HttpError>
fn to_result(self) -> Result<Response<Body>, HttpError>
Generate the response to the HTTP call.
Source§fn response_metadata() -> ApiEndpointResponse
fn response_metadata() -> ApiEndpointResponse
Extract status code and structure metadata for the non-error response.
Type information for errors is handled generically across all endpoints.
Source§fn status_code(&self) -> StatusCode
fn status_code(&self) -> StatusCode
Extract the status code from the concrete response instance. Read more