pub struct ApiResponse {
pub body: Body,
pub status: StatusCode,
pub headers: HeaderMap,
}Fields§
§body: Body§status: StatusCode§headers: HeaderMapImplementations§
Source§impl ApiResponse
impl ApiResponse
pub fn new(body: Body) -> Self
pub fn new_stream(stream: impl AsyncRead + Send + 'static) -> Self
Sourcepub fn new_serialized(body: impl Serialize) -> Self
pub fn new_serialized(body: impl Serialize) -> Self
Create a new API response with content negotiation based on the Accept header.
pub fn error(err: impl AsRef<str>) -> Self
pub fn with_status(self, status: StatusCode) -> Self
pub fn with_header(self, key: &'static str, value: impl AsRef<str>) -> Self
pub fn with_optional_header( self, key: &'static str, value: Option<impl AsRef<str>>, ) -> Self
pub fn ok(self) -> ApiResponseResult
Trait Implementations§
Source§impl Debug for ApiResponse
impl Debug for ApiResponse
Source§impl<T> From<T> for ApiResponse
impl<T> From<T> for ApiResponse
Source§impl IntoResponse for ApiResponse
impl IntoResponse for ApiResponse
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Create a response.
Auto Trait Implementations§
impl Freeze for ApiResponse
impl !RefUnwindSafe for ApiResponse
impl Send for ApiResponse
impl !Sync for ApiResponse
impl Unpin for ApiResponse
impl !UnwindSafe for ApiResponse
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Chain<T> for T
impl<T> Chain<T> for T
§impl<T> Classify for T
impl<T> Classify for T
type Classified = T
fn classify(self) -> T
§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more