ApiRes

Enum ApiRes 

Source
pub enum ApiRes<T: Serialize> {
Show 63 variants Custom(u16, u32, String, Option<T>), Ok(T), OkWith(u32, String, T), Empty, Continue(String), SwitchingProtocols(String), Processing(String), Created(String), Accepted(String), NonAuthoritativeInformation(String), NoContent(String), ResetContent(String), PartialContent(String), MultiStatus(String), AlreadyReported(String), IMUsed(String), MultipleChoices(String), MovedPermanently(String), Found(String), SeeOther(String), NotModified(String), UseProxy(String), TemporaryRedirect(String), PermanentRedirect(String), BadRequest(String), Unauthorized(String), PaymentRequired(String), Forbidden(String), NotFound(String), MethodNotAllowed(String), NotAcceptable(String), ProxyAuthenticationRequired(String), RequestTimeout(String), Conflict(String), Gone(String), LengthRequired(String), PreconditionFailed(String), PayloadTooLarge(String), URITooLong(String), UnsupportedMediaType(String), RangeNotSatisfiable(String), ExpectationFailed(String), ImATeapot(String), MisdirectedRequest(String), UnprocessableEntity(String), Locked(String), FailedDependency(String), UpgradeRequired(String), PreconditionRequired(String), TooManyRequests(String), RequestHeaderFieldsTooLarge(String), UnavailableForLegalReasons(String), InternalServerError(String), NotImplemented(String), BadGateway(String), ServiceUnavailable(String), GatewayTimeout(String), HttpVersionNotSupported(String), VariantAlsoNegotiates(String), InsufficientStorage(String), LoopDetected(String), NotExtended(String), NetworkAuthenticationRequired(String),
}

Variants§

§

Custom(u16, u32, String, Option<T>)

Custom response with status code, error code, message, and optional data

§

Ok(T)

200 OK with data [RFC7231, Section 6.3.1]

§

OkWith(u32, String, T)

200 OK with additional status code and message [RFC7231, Section 6.3.1]

§

Empty

200 OK empty data

§

Continue(String)

100 Continue [RFC7231, Section 6.2.1]

§

SwitchingProtocols(String)

101 Switching Protocols [RFC7231, Section 6.2.2]

§

Processing(String)

102 Processing [RFC2518]

§

Created(String)

201 Created [RFC7231, Section 6.3.2]

§

Accepted(String)

202 Accepted [RFC7231, Section 6.3.3]

§

NonAuthoritativeInformation(String)

203 Non-Authoritative Information [RFC7231, Section 6.3.4]

§

NoContent(String)

204 No Content [RFC7231, Section 6.3.5]

§

ResetContent(String)

205 Reset Content [RFC7231, Section 6.3.6]

§

PartialContent(String)

206 Partial Content [RFC7233, Section 4.1]

§

MultiStatus(String)

207 Multi-Status [RFC4918]

§

AlreadyReported(String)

208 Already Reported [RFC5842]

§

IMUsed(String)

226 IM Used [RFC3229]

§

MultipleChoices(String)

300 Multiple Choices [RFC7231, Section 6.4.1]

§

MovedPermanently(String)

301 Moved Permanently [RFC7231, Section 6.4.2]

§

Found(String)

§

SeeOther(String)

303 See Other [RFC7231, Section 6.4.4]

§

NotModified(String)

304 Not Modified [RFC7232, Section 4.1]

§

UseProxy(String)

305 Use Proxy [RFC7231, Section 6.4.5]

§

TemporaryRedirect(String)

307 Temporary Redirect [RFC7231, Section 6.4.7]

§

PermanentRedirect(String)

308 Permanent Redirect [RFC7238]

§

BadRequest(String)

400 Bad Request [RFC7231, Section 6.5.1]

§

Unauthorized(String)

401 Unauthorized [RFC7235, Section 3.1]

§

PaymentRequired(String)

402 Payment Required [RFC7231, Section 6.5.2]

§

Forbidden(String)

403 Forbidden [RFC7231, Section 6.5.3]

§

NotFound(String)

404 Not Found [RFC7231, Section 6.5.4]

§

MethodNotAllowed(String)

405 Method Not Allowed [RFC7231, Section 6.5.5]

§

NotAcceptable(String)

406 Not Acceptable [RFC7231, Section 6.5.6]

§

ProxyAuthenticationRequired(String)

407 Proxy Authentication Required [RFC7235, Section 3.2]

§

RequestTimeout(String)

408 Request Timeout [RFC7231, Section 6.5.7]

§

Conflict(String)

409 Conflict [RFC7231, Section 6.5.8]

§

Gone(String)

§

LengthRequired(String)

411 Length Required [RFC7231, Section 6.5.10]

§

PreconditionFailed(String)

412 Precondition Failed [RFC7232, Section 4.2]

§

PayloadTooLarge(String)

413 Payload Too Large [RFC7231, Section 6.5.11]

§

URITooLong(String)

414 URI Too Long [RFC7231, Section 6.5.12]

§

UnsupportedMediaType(String)

415 Unsupported Media Type [RFC7231, Section 6.5.13]

§

RangeNotSatisfiable(String)

416 Range Not Satisfiable [RFC7233, Section 4.4]

§

ExpectationFailed(String)

417 Expectation Failed [RFC7231, Section 6.5.14]

§

ImATeapot(String)

418 I’m a teapot [curiously not registered by IANA but RFC2324]

§

MisdirectedRequest(String)

421 Misdirected Request RFC7540, Section 9.1.2

§

UnprocessableEntity(String)

422 Unprocessable Entity [RFC4918]

§

Locked(String)

423 Locked [RFC4918]

§

FailedDependency(String)

424 Failed Dependency [RFC4918]

§

UpgradeRequired(String)

426 Upgrade Required [RFC7231, Section 6.5.15]

§

PreconditionRequired(String)

428 Precondition Required [RFC6585]

§

TooManyRequests(String)

429 Too Many Requests [RFC6585]

§

RequestHeaderFieldsTooLarge(String)

431 Request Header Fields Too Large [RFC6585]

§

UnavailableForLegalReasons(String)

451 Unavailable For Legal Reasons [RFC7725]

§

InternalServerError(String)

500 Internal Server Error [RFC7231, Section 6.6.1]

§

NotImplemented(String)

501 Not Implemented [RFC7231, Section 6.6.2]

§

BadGateway(String)

502 Bad Gateway [RFC7231, Section 6.6.3]

§

ServiceUnavailable(String)

503 Service Unavailable [RFC7231, Section 6.6.4]

§

GatewayTimeout(String)

504 Gateway Timeout [RFC7231, Section 6.6.5]

§

HttpVersionNotSupported(String)

505 HTTP Version Not Supported [RFC7231, Section 6.6.6]

§

VariantAlsoNegotiates(String)

506 Variant Also Negotiates [RFC2295]

§

InsufficientStorage(String)

507 Insufficient Storage [RFC4918]

§

LoopDetected(String)

508 Loop Detected [RFC5842]

§

NotExtended(String)

510 Not Extended [RFC2774]

§

NetworkAuthenticationRequired(String)

511 Network Authentication Required [RFC6585]

Implementations§

Source§

impl<T: Serialize> ApiRes<T>

Source

pub fn status(&self) -> StatusCode

Source

pub fn code(&self) -> u32

Source

pub fn message(&self) -> &str

Source

pub fn data(&self) -> Option<&T>

Trait Implementations§

Source§

impl<T: Clone + Serialize> Clone for ApiRes<T>

Source§

fn clone(&self) -> ApiRes<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Serialize> Debug for ApiRes<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, T> Deserialize<'de> for ApiRes<T>
where T: Deserialize<'de> + Serialize,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: Serialize> Responder for ApiRes<T>

Source§

type Body = BoxBody

Source§

fn respond_to(self, _req: &HttpRequest) -> HttpResponse

Convert self to HttpResponse.
Source§

fn customize(self) -> CustomizeResponder<Self>
where Self: Sized,

Wraps responder to allow alteration of its response. Read more
Source§

impl<T> Serialize for ApiRes<T>
where T: Serialize + Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<T> Freeze for ApiRes<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for ApiRes<T>
where T: RefUnwindSafe,

§

impl<T> Send for ApiRes<T>
where T: Send,

§

impl<T> Sync for ApiRes<T>
where T: Sync,

§

impl<T> Unpin for ApiRes<T>
where T: Unpin,

§

impl<T> UnwindSafe for ApiRes<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,