spin_sdk::http

Struct OutgoingResponse

Source
pub struct OutgoingResponse { /* private fields */ }
Expand description

Represents an outgoing HTTP Response.

Implementations§

Source§

impl OutgoingResponse

Source

pub fn new(headers: Headers) -> Self

Construct an outgoing-response, with a default status-code of 200. If a different status-code is needed, it must be set via the set-status-code method.

  • headers is the HTTP Headers for the Response.
Source§

impl OutgoingResponse

Source

pub fn status_code(&self) -> StatusCode

Get the HTTP Status Code for the Response.

Source§

impl OutgoingResponse

Source

pub fn set_status_code(&self, status_code: StatusCode) -> Result<(), ()>

Set the HTTP Status Code for the Response. Fails if the status-code given is not a valid http status code.

Source§

impl OutgoingResponse

Source

pub fn headers(&self) -> Headers

Get the headers associated with the Request.

The returned headers resource is immutable: set, append, and delete operations will fail with header-error.immutable.

This headers resource is a child: it must be dropped before the parent outgoing-request is dropped, or its ownership is transfered to another component by e.g. outgoing-handler.handle.

Source§

impl OutgoingResponse

Source

pub fn body(&self) -> Result<OutgoingBody, ()>

Returns the resource corresponding to the outgoing Body for this Response.

Returns success on the first call: the outgoing-body resource for this outgoing-response can be retrieved at most once. Subsequent calls will return error.

Source§

impl OutgoingResponse

Source

pub fn take_body(&self) -> impl Sink<Vec<u8>, Error = StreamError>

Construct a Sink which writes chunks to the body of the specified response.

§Panics

Panics if the body was already taken.

Trait Implementations§

Source§

impl Debug for OutgoingResponse

Source§

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

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

impl TryFrom<Response> for OutgoingResponse

Source§

type Error = Error

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

fn try_from(response: Response) -> Result<Self>

Performs the conversion.
Source§

impl WasmResource for OutgoingResponse

Source§

unsafe fn drop(_handle: u32)

Invokes the [resource-drop]... intrinsic.

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

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.