Trait wasmcloud_runtime::capability::http::types::HostOutgoingResponse
source · pub trait HostOutgoingResponse {
// Required methods
fn new(
&mut self,
headers: Resource<HostFields>,
) -> Result<Resource<HostOutgoingResponse>, Error>;
fn status_code(
&mut self,
self_: Resource<HostOutgoingResponse>,
) -> Result<u16, Error>;
fn set_status_code(
&mut self,
self_: Resource<HostOutgoingResponse>,
status_code: u16,
) -> Result<Result<(), ()>, Error>;
fn headers(
&mut self,
self_: Resource<HostOutgoingResponse>,
) -> Result<Resource<HostFields>, Error>;
fn body(
&mut self,
self_: Resource<HostOutgoingResponse>,
) -> Result<Result<Resource<HostOutgoingBody>, ()>, Error>;
fn drop(&mut self, rep: Resource<HostOutgoingResponse>) -> Result<(), Error>;
}
Required Methods§
sourcefn new(
&mut self,
headers: Resource<HostFields>,
) -> Result<Resource<HostOutgoingResponse>, Error>
fn new( &mut self, headers: Resource<HostFields>, ) -> Result<Resource<HostOutgoingResponse>, Error>
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.
sourcefn status_code(
&mut self,
self_: Resource<HostOutgoingResponse>,
) -> Result<u16, Error>
fn status_code( &mut self, self_: Resource<HostOutgoingResponse>, ) -> Result<u16, Error>
Get the HTTP Status Code for the Response.
sourcefn set_status_code(
&mut self,
self_: Resource<HostOutgoingResponse>,
status_code: u16,
) -> Result<Result<(), ()>, Error>
fn set_status_code( &mut self, self_: Resource<HostOutgoingResponse>, status_code: u16, ) -> Result<Result<(), ()>, Error>
Set the HTTP Status Code for the Response. Fails if the status-code given is not a valid http status code.
sourcefn headers(
&mut self,
self_: Resource<HostOutgoingResponse>,
) -> Result<Resource<HostFields>, Error>
fn headers( &mut self, self_: Resource<HostOutgoingResponse>, ) -> Result<Resource<HostFields>, Error>
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 transferred to
another component by e.g. outgoing-handler.handle
.
sourcefn body(
&mut self,
self_: Resource<HostOutgoingResponse>,
) -> Result<Result<Resource<HostOutgoingBody>, ()>, Error>
fn body( &mut self, self_: Resource<HostOutgoingResponse>, ) -> Result<Result<Resource<HostOutgoingBody>, ()>, Error>
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.
fn drop(&mut self, rep: Resource<HostOutgoingResponse>) -> Result<(), Error>
Implementations on Foreign Types§
source§impl<_T> HostOutgoingResponse for &mut _T
impl<_T> HostOutgoingResponse for &mut _T
source§fn new(
&mut self,
headers: Resource<HostFields>,
) -> Result<Resource<HostOutgoingResponse>, Error>
fn new( &mut self, headers: Resource<HostFields>, ) -> Result<Resource<HostOutgoingResponse>, Error>
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§fn status_code(
&mut self,
self_: Resource<HostOutgoingResponse>,
) -> Result<u16, Error>
fn status_code( &mut self, self_: Resource<HostOutgoingResponse>, ) -> Result<u16, Error>
Get the HTTP Status Code for the Response.
source§fn set_status_code(
&mut self,
self_: Resource<HostOutgoingResponse>,
status_code: u16,
) -> Result<Result<(), ()>, Error>
fn set_status_code( &mut self, self_: Resource<HostOutgoingResponse>, status_code: u16, ) -> Result<Result<(), ()>, Error>
Set the HTTP Status Code for the Response. Fails if the status-code given is not a valid http status code.
source§fn headers(
&mut self,
self_: Resource<HostOutgoingResponse>,
) -> Result<Resource<HostFields>, Error>
fn headers( &mut self, self_: Resource<HostOutgoingResponse>, ) -> Result<Resource<HostFields>, Error>
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 transferred to
another component by e.g. outgoing-handler.handle
.
source§fn body(
&mut self,
self_: Resource<HostOutgoingResponse>,
) -> Result<Result<Resource<HostOutgoingBody>, ()>, Error>
fn body( &mut self, self_: Resource<HostOutgoingResponse>, ) -> Result<Result<Resource<HostOutgoingBody>, ()>, Error>
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.