Skip to main content

HttpResponseCreated

Struct HttpResponseCreated 

Source
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: T

Implementations§

Source§

impl<T: HttpResponseContent + Send + Sync + 'static> HttpResponseCreated<T>

Source

pub fn map<U, F>(self, f: F) -> HttpResponseCreated<U>
where U: HttpResponseContent + Send + Sync + 'static, F: FnOnce(T) -> 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.

Source

pub fn try_map<U, E, F>(self, f: F) -> Result<HttpResponseCreated<U>, E>
where U: HttpResponseContent + Send + Sync + 'static, F: FnOnce(T) -> Result<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>

Source§

fn from(response: HttpResponseCreated<T>) -> Result<Response<Body>, HttpError>

Converts to this type from the input type.
Source§

impl<T: HttpResponseContent + Send + Sync + 'static> HttpCodedResponse for HttpResponseCreated<T>

Source§

const STATUS_CODE: StatusCode = StatusCode::CREATED

Source§

const DESCRIPTION: &'static str = "successful creation"

Source§

type Body = T

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HttpResponse for T

Source§

fn to_result(self) -> Result<Response<Body>, HttpError>

Generate the response to the HTTP call.
Source§

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

Extract the status code from the concrete response instance. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,

Source§

impl<T> ServerContext for T
where T: 'static + Send + Sync,