Struct spin_sdk::http::Response

source ·
pub struct Response { /* private fields */ }
Expand description

A unified response object that can represent both outgoing and incoming responses.

This should be used in favor of OutgoingResponse and IncomingResponse when there is no need for streaming bodies.

Implementations§

source§

impl Response

source

pub fn new(status: impl IntoStatusCode, body: impl IntoBody) -> Self

Create a new response from a status and body

source

pub fn status(&self) -> &StatusCode

The response status

source

pub fn headers(&self) -> impl Iterator<Item = (&str, &HeaderValue)>

The request headers

source

pub fn header(&self, name: &str) -> Option<&HeaderValue>

Return a header value

Will return None if the header does not exist.

source

pub fn set_header(&mut self, name: impl Into<String>, value: impl Into<String>)

Set a response header

source

pub fn body(&self) -> &[u8]

The response body

source

pub fn body_mut(&mut self) -> &mut Vec<u8>

The response body

source

pub fn into_body(self) -> Vec<u8>

Consume this type and return its body

source

pub fn into_builder(self) -> ResponseBuilder

Converts this response into a ResponseBuilder. This can be used to update a response before passing it on.

source

pub fn builder() -> ResponseBuilder

Creates a ResponseBuilder

Trait Implementations§

source§

impl Debug for Response

source§

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

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

impl From<Response> for OutgoingResponse

source§

fn from(response: Response) -> Self

Converts to this type from the input type.
source§

impl IntoResponse for Response

source§

fn into_response(self) -> Response

Turn self into a Response
source§

impl TryFromIncomingResponse for Response

§

type Error = Error

The error if conversion fails
source§

fn try_from_incoming_response<'async_trait>( resp: IncomingResponse ) -> Pin<Box<dyn Future<Output = Result<Self, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,

Turn the IncomingResponse into the type

Auto Trait Implementations§

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, 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.