Trait wasmcloud_runtime::capability::http::types::HostIncomingBody
source · pub trait HostIncomingBody {
// Required methods
fn stream(
&mut self,
self_: Resource<HostIncomingBody>,
) -> Result<Result<Resource<Box<dyn HostInputStream>>, ()>, Error>;
fn finish(
&mut self,
this: Resource<HostIncomingBody>,
) -> Result<Resource<HostFutureTrailers>, Error>;
fn drop(&mut self, rep: Resource<HostIncomingBody>) -> Result<(), Error>;
}
Required Methods§
sourcefn stream(
&mut self,
self_: Resource<HostIncomingBody>,
) -> Result<Result<Resource<Box<dyn HostInputStream>>, ()>, Error>
fn stream( &mut self, self_: Resource<HostIncomingBody>, ) -> Result<Result<Resource<Box<dyn HostInputStream>>, ()>, Error>
Returns the contents of the body, as a stream of bytes.
Returns success on first call: the stream representing the contents can be retrieved at most once. Subsequent calls will return error.
The returned input-stream
resource is a child: it must be dropped
before the parent incoming-body
is dropped, or consumed by
incoming-body.finish
.
This invariant ensures that the implementation can determine whether
the user is consuming the contents of the body, waiting on the
future-trailers
to be ready, or neither. This allows for network
backpressure is to be applied when the user is consuming the body,
and for that backpressure to not inhibit delivery of the trailers if
the user does not read the entire body.
sourcefn finish(
&mut self,
this: Resource<HostIncomingBody>,
) -> Result<Resource<HostFutureTrailers>, Error>
fn finish( &mut self, this: Resource<HostIncomingBody>, ) -> Result<Resource<HostFutureTrailers>, Error>
Takes ownership of incoming-body
, and returns a future-trailers
.
This function will trap if the input-stream
child is still alive.
fn drop(&mut self, rep: Resource<HostIncomingBody>) -> Result<(), Error>
Implementations on Foreign Types§
source§impl<_T> HostIncomingBody for &mut _T
impl<_T> HostIncomingBody for &mut _T
source§fn stream(
&mut self,
self_: Resource<HostIncomingBody>,
) -> Result<Result<Resource<Box<dyn HostInputStream>>, ()>, Error>
fn stream( &mut self, self_: Resource<HostIncomingBody>, ) -> Result<Result<Resource<Box<dyn HostInputStream>>, ()>, Error>
Returns the contents of the body, as a stream of bytes.
Returns success on first call: the stream representing the contents can be retrieved at most once. Subsequent calls will return error.
The returned input-stream
resource is a child: it must be dropped
before the parent incoming-body
is dropped, or consumed by
incoming-body.finish
.
This invariant ensures that the implementation can determine whether
the user is consuming the contents of the body, waiting on the
future-trailers
to be ready, or neither. This allows for network
backpressure is to be applied when the user is consuming the body,
and for that backpressure to not inhibit delivery of the trailers if
the user does not read the entire body.
source§fn finish(
&mut self,
this: Resource<HostIncomingBody>,
) -> Result<Resource<HostFutureTrailers>, Error>
fn finish( &mut self, this: Resource<HostIncomingBody>, ) -> Result<Resource<HostFutureTrailers>, Error>
Takes ownership of incoming-body
, and returns a future-trailers
.
This function will trap if the input-stream
child is still alive.