pub trait HostOutgoingResponse: Sized + Send {
// Required methods
fn new(
&mut self,
headers: Resource<Headers>,
) -> Result<Resource<OutgoingResponse>>;
fn status_code(
&mut self,
self_: Resource<OutgoingResponse>,
) -> Result<StatusCode>;
fn set_status_code(
&mut self,
self_: Resource<OutgoingResponse>,
status_code: StatusCode,
) -> Result<Result<(), ()>>;
fn headers(
&mut self,
self_: Resource<OutgoingResponse>,
) -> Result<Resource<Headers>>;
fn body(
&mut self,
self_: Resource<OutgoingResponse>,
) -> Result<Result<Resource<OutgoingBody>, ()>>;
fn drop(&mut self, rep: Resource<OutgoingResponse>) -> Result<()>;
}
Required Methods§
Sourcefn new(
&mut self,
headers: Resource<Headers>,
) -> Result<Resource<OutgoingResponse>>
fn new( &mut self, headers: Resource<Headers>, ) -> Result<Resource<OutgoingResponse>>
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<OutgoingResponse>,
) -> Result<StatusCode>
fn status_code( &mut self, self_: Resource<OutgoingResponse>, ) -> Result<StatusCode>
Get the HTTP Status Code for the Response.
Sourcefn set_status_code(
&mut self,
self_: Resource<OutgoingResponse>,
status_code: StatusCode,
) -> Result<Result<(), ()>>
fn set_status_code( &mut self, self_: Resource<OutgoingResponse>, status_code: StatusCode, ) -> Result<Result<(), ()>>
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<OutgoingResponse>,
) -> Result<Resource<Headers>>
fn headers( &mut self, self_: Resource<OutgoingResponse>, ) -> Result<Resource<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 transferred to
another component by e.g. outgoing-handler.handle
.
Sourcefn body(
&mut self,
self_: Resource<OutgoingResponse>,
) -> Result<Result<Resource<OutgoingBody>, ()>>
fn body( &mut self, self_: Resource<OutgoingResponse>, ) -> Result<Result<Resource<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.
fn drop(&mut self, rep: Resource<OutgoingResponse>) -> Result<()>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<_T: HostOutgoingResponse + ?Sized + Send> HostOutgoingResponse for &mut _T
impl<_T: HostOutgoingResponse + ?Sized + Send> HostOutgoingResponse for &mut _T
Source§fn new(
&mut self,
headers: Resource<Headers>,
) -> Result<Resource<OutgoingResponse>>
fn new( &mut self, headers: Resource<Headers>, ) -> Result<Resource<OutgoingResponse>>
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<OutgoingResponse>,
) -> Result<StatusCode>
fn status_code( &mut self, self_: Resource<OutgoingResponse>, ) -> Result<StatusCode>
Get the HTTP Status Code for the Response.
Source§fn set_status_code(
&mut self,
self_: Resource<OutgoingResponse>,
status_code: StatusCode,
) -> Result<Result<(), ()>>
fn set_status_code( &mut self, self_: Resource<OutgoingResponse>, status_code: StatusCode, ) -> Result<Result<(), ()>>
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<OutgoingResponse>,
) -> Result<Resource<Headers>>
fn headers( &mut self, self_: Resource<OutgoingResponse>, ) -> Result<Resource<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 transferred to
another component by e.g. outgoing-handler.handle
.
Source§fn body(
&mut self,
self_: Resource<OutgoingResponse>,
) -> Result<Result<Resource<OutgoingBody>, ()>>
fn body( &mut self, self_: Resource<OutgoingResponse>, ) -> Result<Result<Resource<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.