pub struct WasiHttpCtxView<'a> {
pub ctx: &'a mut WasiHttpCtx,
pub table: &'a mut ResourceTable,
pub hooks: &'a mut dyn WasiHttpHooks,
}Available on crate feature
p2 only.Expand description
Structure which wasi:http Host-style traits are implemented for.
This structure is used by embedders with the WasiHttpView trait’s return
value and is used to provide access to this crate all internals necessary to
implement wasi:http. This is similar to wasmtime_wasi::WasiCtxView
for example.
Fields§
§ctx: &'a mut WasiHttpCtxA reference to a per-store WasiHttpCtx.
table: &'a mut ResourceTableA reference to a per-store table of resources to store host structures within.
hooks: &'a mut dyn WasiHttpHooksA reference to a per-store set of hooks that can be used to customize
wasi:http behavior.
Implementations§
Source§impl WasiHttpCtxView<'_>
impl WasiHttpCtxView<'_>
Sourcepub fn new_incoming_request<B>(
&mut self,
scheme: Scheme,
req: Request<B>,
) -> Result<Resource<HostIncomingRequest>>
pub fn new_incoming_request<B>( &mut self, scheme: Scheme, req: Request<B>, ) -> Result<Resource<HostIncomingRequest>>
Create a new incoming request resource.
Source§impl WasiHttpCtxView<'_>
impl WasiHttpCtxView<'_>
Sourcepub fn new_response_outparam(
&mut self,
result: Sender<Result<Response<HyperOutgoingBody>, ErrorCode>>,
) -> Result<Resource<HostResponseOutparam>>
pub fn new_response_outparam( &mut self, result: Sender<Result<Response<HyperOutgoingBody>, ErrorCode>>, ) -> Result<Resource<HostResponseOutparam>>
Create a new outgoing response resource.
Trait Implementations§
Source§impl Host for WasiHttpCtxView<'_>
impl Host for WasiHttpCtxView<'_>
Source§fn handle(
&mut self,
request_id: Resource<HostOutgoingRequest>,
options: Option<Resource<RequestOptions>>,
) -> HttpResult<Resource<HostFutureIncomingResponse>>
fn handle( &mut self, request_id: Resource<HostOutgoingRequest>, options: Option<Resource<RequestOptions>>, ) -> HttpResult<Resource<HostFutureIncomingResponse>>
Available on crate feature
component-model-async only.This function is invoked with an outgoing HTTP Request, and it returns
a resource
future-incoming-response which represents an HTTP Response
which may arrive in the future. Read moreSource§impl Host for WasiHttpCtxView<'_>
impl Host for WasiHttpCtxView<'_>
Source§fn convert_error_code(&mut self, err: HttpError) -> Result<ErrorCode>
fn convert_error_code(&mut self, err: HttpError) -> Result<ErrorCode>
Available on crate feature
component-model-async only.Source§fn convert_header_error(&mut self, err: HeaderError) -> Result<HeaderError>
fn convert_header_error(&mut self, err: HeaderError) -> Result<HeaderError>
Available on crate feature
component-model-async only.Source§impl HostFields for WasiHttpCtxView<'_>
impl HostFields for WasiHttpCtxView<'_>
Source§fn new(&mut self) -> Result<Resource<FieldMap>>
fn new(&mut self) -> Result<Resource<FieldMap>>
Available on crate feature
component-model-async only.Construct an empty HTTP Fields. Read more
Source§fn from_list(
&mut self,
entries: Vec<(String, Vec<u8>)>,
) -> HeaderResult<Resource<FieldMap>>
fn from_list( &mut self, entries: Vec<(String, Vec<u8>)>, ) -> HeaderResult<Resource<FieldMap>>
Available on crate feature
component-model-async only.Construct an HTTP Fields. Read more
Source§fn drop(&mut self, fields: Resource<FieldMap>) -> Result<()>
fn drop(&mut self, fields: Resource<FieldMap>) -> Result<()>
Available on crate feature
component-model-async only.Source§fn get(
&mut self,
fields: Resource<FieldMap>,
name: String,
) -> Result<Vec<Vec<u8>>>
fn get( &mut self, fields: Resource<FieldMap>, name: String, ) -> Result<Vec<Vec<u8>>>
Available on crate feature
component-model-async only.Get all of the values corresponding to a name. If the name is not present
in this
fields or is syntactically invalid, an empty list is returned.
However, if the name is present but empty, this is represented by a list
with one or more empty field-values present.Source§fn has(&mut self, fields: Resource<FieldMap>, name: String) -> Result<bool>
fn has(&mut self, fields: Resource<FieldMap>, name: String) -> Result<bool>
Available on crate feature
component-model-async only.Returns
true when the name is present in this fields. If the name is
syntactically invalid, false is returned.Source§fn set(
&mut self,
fields: Resource<FieldMap>,
name: String,
byte_values: Vec<Vec<u8>>,
) -> HeaderResult<()>
fn set( &mut self, fields: Resource<FieldMap>, name: String, byte_values: Vec<Vec<u8>>, ) -> HeaderResult<()>
Available on crate feature
component-model-async only.Set all of the values for a name. Clears any existing values for that
name, if they have been set. Read more
Source§fn delete(
&mut self,
fields: Resource<FieldMap>,
name: String,
) -> HeaderResult<()>
fn delete( &mut self, fields: Resource<FieldMap>, name: String, ) -> HeaderResult<()>
Available on crate feature
component-model-async only.Delete all values for a name. Does nothing if no values for the name
exist. Read more
Source§fn append(
&mut self,
fields: Resource<FieldMap>,
name: String,
value: Vec<u8>,
) -> HeaderResult<()>
fn append( &mut self, fields: Resource<FieldMap>, name: String, value: Vec<u8>, ) -> HeaderResult<()>
Available on crate feature
component-model-async only.Append a value for a name. Does not change or delete any existing
values for that name. Read more
Source§impl HostFutureIncomingResponse for WasiHttpCtxView<'_>
impl HostFutureIncomingResponse for WasiHttpCtxView<'_>
Source§fn drop(&mut self, id: Resource<HostFutureIncomingResponse>) -> Result<()>
fn drop(&mut self, id: Resource<HostFutureIncomingResponse>) -> Result<()>
Available on crate feature
component-model-async only.Source§fn get(
&mut self,
id: Resource<HostFutureIncomingResponse>,
) -> Result<Option<Result<Result<Resource<HostIncomingResponse>, ErrorCode>, ()>>>
fn get( &mut self, id: Resource<HostFutureIncomingResponse>, ) -> Result<Option<Result<Result<Resource<HostIncomingResponse>, ErrorCode>, ()>>>
Available on crate feature
component-model-async only.Returns the incoming HTTP Response, or an error, once one is ready. Read more
Source§fn subscribe(
&mut self,
id: Resource<HostFutureIncomingResponse>,
) -> Result<Resource<DynPollable>>
fn subscribe( &mut self, id: Resource<HostFutureIncomingResponse>, ) -> Result<Resource<DynPollable>>
Available on crate feature
component-model-async only.Returns a pollable which becomes ready when either the Response has
been received, or an error has occurred. When this pollable is ready,
the
get method will return some.Source§impl HostFutureTrailers for WasiHttpCtxView<'_>
impl HostFutureTrailers for WasiHttpCtxView<'_>
Source§fn drop(&mut self, id: Resource<HostFutureTrailers>) -> Result<()>
fn drop(&mut self, id: Resource<HostFutureTrailers>) -> Result<()>
Available on crate feature
component-model-async only.Source§fn subscribe(
&mut self,
index: Resource<HostFutureTrailers>,
) -> Result<Resource<DynPollable>>
fn subscribe( &mut self, index: Resource<HostFutureTrailers>, ) -> Result<Resource<DynPollable>>
Available on crate feature
component-model-async only.Returns a pollable which becomes ready when either the trailers have
been received, or an error has occurred. When this pollable is ready,
the
get method will return some.Source§impl HostIncomingBody for WasiHttpCtxView<'_>
impl HostIncomingBody for WasiHttpCtxView<'_>
Source§fn stream(
&mut self,
id: Resource<HostIncomingBody>,
) -> Result<Result<Resource<DynInputStream>, ()>>
fn stream( &mut self, id: Resource<HostIncomingBody>, ) -> Result<Result<Resource<DynInputStream>, ()>>
Available on crate feature
component-model-async only.Returns the contents of the body, as a stream of bytes. Read more
Source§fn finish(
&mut self,
id: Resource<HostIncomingBody>,
) -> Result<Resource<HostFutureTrailers>>
fn finish( &mut self, id: Resource<HostIncomingBody>, ) -> Result<Resource<HostFutureTrailers>>
Available on crate feature
component-model-async only.Takes ownership of
incoming-body, and returns a future-trailers.
This function will trap if the input-stream child is still alive.Source§impl HostIncomingRequest for WasiHttpCtxView<'_>
impl HostIncomingRequest for WasiHttpCtxView<'_>
Source§fn method(&mut self, id: Resource<HostIncomingRequest>) -> Result<Method>
fn method(&mut self, id: Resource<HostIncomingRequest>) -> Result<Method>
Available on crate feature
component-model-async only.Returns the method of the incoming request.
Source§fn path_with_query(
&mut self,
id: Resource<HostIncomingRequest>,
) -> Result<Option<String>>
fn path_with_query( &mut self, id: Resource<HostIncomingRequest>, ) -> Result<Option<String>>
Available on crate feature
component-model-async only.Returns the path with query parameters from the request, as a string.
Source§fn scheme(
&mut self,
id: Resource<HostIncomingRequest>,
) -> Result<Option<Scheme>>
fn scheme( &mut self, id: Resource<HostIncomingRequest>, ) -> Result<Option<Scheme>>
Available on crate feature
component-model-async only.Returns the protocol scheme from the request.
Available on crate feature
component-model-async only.Returns the authority of the Request’s target URI, if present.
Source§fn headers(
&mut self,
id: Resource<HostIncomingRequest>,
) -> Result<Resource<FieldMap>>
fn headers( &mut self, id: Resource<HostIncomingRequest>, ) -> Result<Resource<FieldMap>>
Available on crate feature
component-model-async only.Get the
headers associated with the request. Read moreSource§fn consume(
&mut self,
id: Resource<HostIncomingRequest>,
) -> Result<Result<Resource<HostIncomingBody>, ()>>
fn consume( &mut self, id: Resource<HostIncomingRequest>, ) -> Result<Result<Resource<HostIncomingBody>, ()>>
Available on crate feature
component-model-async only.Gives the
incoming-body associated with this request. Will only
return success at most once, and subsequent calls will return error.Source§impl HostIncomingResponse for WasiHttpCtxView<'_>
impl HostIncomingResponse for WasiHttpCtxView<'_>
Source§fn drop(&mut self, response: Resource<HostIncomingResponse>) -> Result<()>
fn drop(&mut self, response: Resource<HostIncomingResponse>) -> Result<()>
Available on crate feature
component-model-async only.Source§fn status(
&mut self,
response: Resource<HostIncomingResponse>,
) -> Result<StatusCode>
fn status( &mut self, response: Resource<HostIncomingResponse>, ) -> Result<StatusCode>
Available on crate feature
component-model-async only.Returns the status code from the incoming response.
Source§fn headers(
&mut self,
response: Resource<HostIncomingResponse>,
) -> Result<Resource<FieldMap>>
fn headers( &mut self, response: Resource<HostIncomingResponse>, ) -> Result<Resource<FieldMap>>
Available on crate feature
component-model-async only.Returns the headers from the incoming response. Read more
Source§fn consume(
&mut self,
response: Resource<HostIncomingResponse>,
) -> Result<Result<Resource<HostIncomingBody>, ()>>
fn consume( &mut self, response: Resource<HostIncomingResponse>, ) -> Result<Result<Resource<HostIncomingBody>, ()>>
Available on crate feature
component-model-async only.Returns the incoming body. May be called at most once. Returns error
if called additional times.
Source§impl HostOutgoingBody for WasiHttpCtxView<'_>
impl HostOutgoingBody for WasiHttpCtxView<'_>
Source§fn write(
&mut self,
id: Resource<HostOutgoingBody>,
) -> Result<Result<Resource<DynOutputStream>, ()>>
fn write( &mut self, id: Resource<HostOutgoingBody>, ) -> Result<Result<Resource<DynOutputStream>, ()>>
Available on crate feature
component-model-async only.Returns a stream for writing the body contents. Read more
Source§fn finish(
&mut self,
id: Resource<HostOutgoingBody>,
ts: Option<Resource<Trailers>>,
) -> HttpResult<()>
fn finish( &mut self, id: Resource<HostOutgoingBody>, ts: Option<Resource<Trailers>>, ) -> HttpResult<()>
Available on crate feature
component-model-async only.Finalize an outgoing body, optionally providing trailers. This must be
called to signal that the response is complete. If the
outgoing-body
is dropped without calling outgoing-body.finalize, the implementation
should treat the body as corrupted. Read moreSource§impl HostOutgoingRequest for WasiHttpCtxView<'_>
impl HostOutgoingRequest for WasiHttpCtxView<'_>
Source§fn new(
&mut self,
headers: Resource<FieldMap>,
) -> Result<Resource<HostOutgoingRequest>>
fn new( &mut self, headers: Resource<FieldMap>, ) -> Result<Resource<HostOutgoingRequest>>
Available on crate feature
component-model-async only.Construct a new
outgoing-request with a default method of GET, and
none values for path-with-query, scheme, and authority. Read moreSource§fn body(
&mut self,
request: Resource<HostOutgoingRequest>,
) -> Result<Result<Resource<HostOutgoingBody>, ()>>
fn body( &mut self, request: Resource<HostOutgoingRequest>, ) -> Result<Result<Resource<HostOutgoingBody>, ()>>
Available on crate feature
component-model-async only.Returns the resource corresponding to the outgoing Body for this
Request. Read more
Source§fn drop(&mut self, request: Resource<HostOutgoingRequest>) -> Result<()>
fn drop(&mut self, request: Resource<HostOutgoingRequest>) -> Result<()>
Available on crate feature
component-model-async only.Source§fn method(&mut self, request: Resource<OutgoingRequest>) -> Result<Method>
fn method(&mut self, request: Resource<OutgoingRequest>) -> Result<Method>
Available on crate feature
component-model-async only.Get the Method for the Request.
Source§fn set_method(
&mut self,
request: Resource<OutgoingRequest>,
method: Method,
) -> Result<Result<(), ()>>
fn set_method( &mut self, request: Resource<OutgoingRequest>, method: Method, ) -> Result<Result<(), ()>>
Available on crate feature
component-model-async only.Set the Method for the Request. Fails if the string present in a
method.other argument is not a syntactically valid method.Source§fn path_with_query(
&mut self,
request: Resource<OutgoingRequest>,
) -> Result<Option<String>>
fn path_with_query( &mut self, request: Resource<OutgoingRequest>, ) -> Result<Option<String>>
Available on crate feature
component-model-async only.Get the combination of the HTTP Path and Query for the Request.
When
none, this represents an empty Path and empty Query.Source§fn set_path_with_query(
&mut self,
request: Resource<OutgoingRequest>,
path_with_query: Option<String>,
) -> Result<Result<(), ()>>
fn set_path_with_query( &mut self, request: Resource<OutgoingRequest>, path_with_query: Option<String>, ) -> Result<Result<(), ()>>
Available on crate feature
component-model-async only.Set the combination of the HTTP Path and Query for the Request.
When
none, this represents an empty Path and empty Query. Fails is the
string given is not a syntactically valid path and query uri component.Source§fn scheme(
&mut self,
request: Resource<OutgoingRequest>,
) -> Result<Option<Scheme>>
fn scheme( &mut self, request: Resource<OutgoingRequest>, ) -> Result<Option<Scheme>>
Available on crate feature
component-model-async only.Get the HTTP Related Scheme for the Request. When
none, the
implementation may choose an appropriate default scheme.Source§fn set_scheme(
&mut self,
request: Resource<OutgoingRequest>,
scheme: Option<Scheme>,
) -> Result<Result<(), ()>>
fn set_scheme( &mut self, request: Resource<OutgoingRequest>, scheme: Option<Scheme>, ) -> Result<Result<(), ()>>
Available on crate feature
component-model-async only.Set the HTTP Related Scheme for the Request. When
none, the
implementation may choose an appropriate default scheme. Fails if the
string given is not a syntactically valid uri scheme.Available on crate feature
component-model-async only.Get the authority of the Request’s target URI. A value of
none may be used
with Related Schemes which do not require an authority. The HTTP and
HTTPS schemes always require an authority.Available on crate feature
component-model-async only.Set the authority of the Request’s target URI. A value of
none may be used
with Related Schemes which do not require an authority. The HTTP and
HTTPS schemes always require an authority. Fails if the string given is
not a syntactically valid URI authority.Source§impl HostOutgoingResponse for WasiHttpCtxView<'_>
impl HostOutgoingResponse for WasiHttpCtxView<'_>
Source§fn new(
&mut self,
headers: Resource<FieldMap>,
) -> Result<Resource<HostOutgoingResponse>>
fn new( &mut self, headers: Resource<FieldMap>, ) -> Result<Resource<HostOutgoingResponse>>
Available on crate feature
component-model-async only.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. Read moreSource§fn body(
&mut self,
id: Resource<HostOutgoingResponse>,
) -> Result<Result<Resource<HostOutgoingBody>, ()>>
fn body( &mut self, id: Resource<HostOutgoingResponse>, ) -> Result<Result<Resource<HostOutgoingBody>, ()>>
Available on crate feature
component-model-async only.Returns the resource corresponding to the outgoing Body for this Response. Read more
Source§fn status_code(
&mut self,
id: Resource<HostOutgoingResponse>,
) -> Result<StatusCode>
fn status_code( &mut self, id: Resource<HostOutgoingResponse>, ) -> Result<StatusCode>
Available on crate feature
component-model-async only.Get the HTTP Status Code for the Response.
Source§fn set_status_code(
&mut self,
id: Resource<HostOutgoingResponse>,
status: StatusCode,
) -> Result<Result<(), ()>>
fn set_status_code( &mut self, id: Resource<HostOutgoingResponse>, status: StatusCode, ) -> Result<Result<(), ()>>
Available on crate feature
component-model-async only.Set the HTTP Status Code for the Response. Fails if the status-code
given is not a valid http status code.
Source§impl HostRequestOptions for WasiHttpCtxView<'_>
impl HostRequestOptions for WasiHttpCtxView<'_>
Source§fn new(&mut self) -> Result<Resource<RequestOptions>>
fn new(&mut self) -> Result<Resource<RequestOptions>>
Available on crate feature
component-model-async only.Construct a default
request-options value.Source§fn connect_timeout(
&mut self,
opts: Resource<RequestOptions>,
) -> Result<Option<Duration>>
fn connect_timeout( &mut self, opts: Resource<RequestOptions>, ) -> Result<Option<Duration>>
Available on crate feature
component-model-async only.The timeout for the initial connect to the HTTP Server.
Source§fn set_connect_timeout(
&mut self,
opts: Resource<RequestOptions>,
duration: Option<Duration>,
) -> Result<Result<(), ()>>
fn set_connect_timeout( &mut self, opts: Resource<RequestOptions>, duration: Option<Duration>, ) -> Result<Result<(), ()>>
Available on crate feature
component-model-async only.Set the timeout for the initial connect to the HTTP Server. An error
return value indicates that this timeout is not supported.
Source§fn first_byte_timeout(
&mut self,
opts: Resource<RequestOptions>,
) -> Result<Option<Duration>>
fn first_byte_timeout( &mut self, opts: Resource<RequestOptions>, ) -> Result<Option<Duration>>
Available on crate feature
component-model-async only.The timeout for receiving the first byte of the Response body.
Source§fn set_first_byte_timeout(
&mut self,
opts: Resource<RequestOptions>,
duration: Option<Duration>,
) -> Result<Result<(), ()>>
fn set_first_byte_timeout( &mut self, opts: Resource<RequestOptions>, duration: Option<Duration>, ) -> Result<Result<(), ()>>
Available on crate feature
component-model-async only.Set the timeout for receiving the first byte of the Response body. An
error return value indicates that this timeout is not supported.
Source§fn between_bytes_timeout(
&mut self,
opts: Resource<RequestOptions>,
) -> Result<Option<Duration>>
fn between_bytes_timeout( &mut self, opts: Resource<RequestOptions>, ) -> Result<Option<Duration>>
Available on crate feature
component-model-async only.The timeout for receiving subsequent chunks of bytes in the Response
body stream.
Source§fn set_between_bytes_timeout(
&mut self,
opts: Resource<RequestOptions>,
duration: Option<Duration>,
) -> Result<Result<(), ()>>
fn set_between_bytes_timeout( &mut self, opts: Resource<RequestOptions>, duration: Option<Duration>, ) -> Result<Result<(), ()>>
Available on crate feature
component-model-async only.Set the timeout for receiving subsequent chunks of bytes in the Response
body stream. An error return value indicates that this timeout is not
supported.
Source§impl HostResponseOutparam for WasiHttpCtxView<'_>
impl HostResponseOutparam for WasiHttpCtxView<'_>
Source§fn drop(&mut self, id: Resource<HostResponseOutparam>) -> Result<()>
fn drop(&mut self, id: Resource<HostResponseOutparam>) -> Result<()>
Available on crate feature
component-model-async only.Source§fn set(
&mut self,
id: Resource<HostResponseOutparam>,
resp: Result<Resource<HostOutgoingResponse>, ErrorCode>,
) -> Result<()>
fn set( &mut self, id: Resource<HostResponseOutparam>, resp: Result<Resource<HostOutgoingResponse>, ErrorCode>, ) -> Result<()>
Available on crate feature
component-model-async only.Set the value of the
response-outparam to either send a response,
or indicate an error. Read moreSource§fn send_informational(
&mut self,
_id: Resource<HostResponseOutparam>,
_status: u16,
_headers: Resource<FieldMap>,
) -> HttpResult<()>
fn send_informational( &mut self, _id: Resource<HostResponseOutparam>, _status: u16, _headers: Resource<FieldMap>, ) -> HttpResult<()>
Available on crate feature
component-model-async only.Send an HTTP 1xx response. Read more
Auto Trait Implementations§
impl<'a> Freeze for WasiHttpCtxView<'a>
impl<'a> !RefUnwindSafe for WasiHttpCtxView<'a>
impl<'a> Send for WasiHttpCtxView<'a>
impl<'a> !Sync for WasiHttpCtxView<'a>
impl<'a> Unpin for WasiHttpCtxView<'a>
impl<'a> !UnwindSafe for WasiHttpCtxView<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
Query the “status” flags for the
self file descriptor.§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more