pub struct WasiHttp;Expand description
A helper struct which implements HasData for the wasi:http APIs.
This can be useful when directly calling add_to_linker functions directly,
such as wasmtime_wasi_http::p3::bindings::http::types::add_to_linker as
the D type parameter. See HasData for more information about the type
parameter’s purpose.
When using this type you can skip the WasiHttpView trait, for example.
§Examples
use wasmtime::component::Linker;
use wasmtime::{Engine, Result};
use wasmtime_wasi_http::{WasiHttp, WasiHttpCtxView};
struct MyStoreState {
// ...
}
impl MyStoreState {
fn http(&mut self) -> WasiHttpCtxView<'_> {
// ...
}
}
fn main() -> Result<()> {
let engine = Engine::default();
let mut linker = Linker::new(&engine);
wasmtime_wasi_http::p3::bindings::http::types::add_to_linker::<MyStoreState, WasiHttp>(
&mut linker,
|state| state.http(),
)?;
Ok(())
}Trait Implementations§
Source§impl HasData for WasiHttp
impl HasData for WasiHttp
Source§type Data<'a> = WasiHttpCtxView<'a>
type Data<'a> = WasiHttpCtxView<'a>
The data associated with this trait implementation, chiefly used as a
generic associated type to allow plumbing the
'a lifetime into the
definition here. Read moreSource§impl<T> HostRequestWithStore<T> for WasiHttp
Available on crate feature p3 only.
impl<T> HostRequestWithStore<T> for WasiHttp
Available on crate feature
p3 only.Source§fn new(
store: Access<'_, T, Self>,
headers: Resource<Headers>,
contents: Option<StreamReader<u8>>,
trailers: FutureReader<Result<Option<Resource<Trailers>>, ErrorCode>>,
options: Option<Resource<RequestOptions>>,
) -> Result<(Resource<Request>, FutureReader<Result<(), ErrorCode>>)>
fn new( store: Access<'_, T, Self>, headers: Resource<Headers>, contents: Option<StreamReader<u8>>, trailers: FutureReader<Result<Option<Resource<Trailers>>, ErrorCode>>, options: Option<Resource<RequestOptions>>, ) -> Result<(Resource<Request>, FutureReader<Result<(), ErrorCode>>)>
Construct a new
request with a default method of GET, and
none values for path-with-query, scheme, and authority. Read moreSource§fn consume_body(
store: Access<'_, T, Self>,
req: Resource<Request>,
fut: FutureReader<Result<(), ErrorCode>>,
) -> Result<(StreamReader<u8>, FutureReader<Result<Option<Resource<Trailers>>, ErrorCode>>)>
fn consume_body( store: Access<'_, T, Self>, req: Resource<Request>, fut: FutureReader<Result<(), ErrorCode>>, ) -> Result<(StreamReader<u8>, FutureReader<Result<Option<Resource<Trailers>>, ErrorCode>>)>
Get body of the Request. Read more
fn drop(store: Access<'_, T, Self>, req: Resource<Request>) -> Result<()>
Source§impl<T> HostResponseWithStore<T> for WasiHttp
Available on crate feature p3 only.
impl<T> HostResponseWithStore<T> for WasiHttp
Available on crate feature
p3 only.Source§fn new(
store: Access<'_, T, Self>,
headers: Resource<Headers>,
contents: Option<StreamReader<u8>>,
trailers: FutureReader<Result<Option<Resource<Trailers>>, ErrorCode>>,
) -> Result<(Resource<Response>, FutureReader<Result<(), ErrorCode>>)>
fn new( store: Access<'_, T, Self>, headers: Resource<Headers>, contents: Option<StreamReader<u8>>, trailers: FutureReader<Result<Option<Resource<Trailers>>, ErrorCode>>, ) -> Result<(Resource<Response>, FutureReader<Result<(), ErrorCode>>)>
Construct a new
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 consume_body(
store: Access<'_, T, Self>,
res: Resource<Response>,
fut: FutureReader<Result<(), ErrorCode>>,
) -> Result<(StreamReader<u8>, FutureReader<Result<Option<Resource<Trailers>>, ErrorCode>>)>
fn consume_body( store: Access<'_, T, Self>, res: Resource<Response>, fut: FutureReader<Result<(), ErrorCode>>, ) -> Result<(StreamReader<u8>, FutureReader<Result<Option<Resource<Trailers>>, ErrorCode>>)>
Get body of the Response. Read more
fn drop(store: Access<'_, T, Self>, res: Resource<Response>) -> Result<()>
Source§impl<T> HostWithStore<T> for WasiHttp
Available on crate feature p3 only.
impl<T> HostWithStore<T> for WasiHttp
Available on crate feature
p3 only.Auto Trait Implementations§
impl Freeze for WasiHttp
impl RefUnwindSafe for WasiHttp
impl Send for WasiHttp
impl Sync for WasiHttp
impl Unpin for WasiHttp
impl UnsafeUnpin for WasiHttp
impl UnwindSafe for WasiHttp
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> ErasedDestructor for Twhere
T: 'static,
impl<H, T> HostDescriptorWithStore<T> for H
impl<H, T> HostDescriptorWithStore<T> for H
impl<H, T> HostDirectoryEntryStreamWithStore<T> for H
impl<H, T> HostDirectoryEntryStreamWithStore<T> for H
impl<H, T> HostErrorWithStore<T> for H
impl<H, T> HostFieldsWithStore<T> for H
impl<H, T> HostFieldsWithStore<T> for H
impl<H, T> HostFutureIncomingResponseWithStore<T> for H
impl<H, T> HostFutureTrailersWithStore<T> for H
impl<H, T> HostIncomingBodyWithStore<T> for H
impl<H, T> HostIncomingDatagramStreamWithStore<T> for H
impl<H, T> HostIncomingDatagramStreamWithStore<T> for H
impl<H, T> HostIncomingRequestWithStore<T> for H
impl<H, T> HostIncomingResponseWithStore<T> for H
impl<H, T> HostInputStreamWithStore<T> for H
impl<H, T> HostInputStreamWithStore<T> for H
impl<H, T> HostNetworkWithStore<T> for H
impl<H, T> HostOutgoingBodyWithStore<T> for H
impl<H, T> HostOutgoingDatagramStreamWithStore<T> for H
impl<H, T> HostOutgoingDatagramStreamWithStore<T> for H
impl<H, T> HostOutgoingRequestWithStore<T> for H
impl<H, T> HostOutgoingResponseWithStore<T> for H
impl<H, T> HostOutputStreamWithStore<T> for H
impl<H, T> HostOutputStreamWithStore<T> for H
impl<H, T> HostPollableWithStore<T> for H
impl<H, T> HostPollableWithStore<T> for H
impl<H, T> HostRequestOptionsWithStore<T> for H
impl<H, T> HostRequestOptionsWithStore<T> for H
impl<H, T> HostResolveAddressStreamWithStore<T> for H
impl<H, T> HostResolveAddressStreamWithStore<T> for H
impl<H, T> HostResponseOutparamWithStore<T> for H
impl<H, T> HostTcpSocketWithStore<T> for H
impl<H, T> HostTcpSocketWithStore<T> for H
impl<H, T> HostTerminalInputWithStore<T> for H
impl<H, T> HostTerminalInputWithStore<T> for H
impl<H, T> HostTerminalOutputWithStore<T> for H
impl<H, T> HostTerminalOutputWithStore<T> for H
impl<H, T> HostUdpSocketWithStore<T> for H
impl<H, T> HostUdpSocketWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for Hwhere
H: HasData + HostFieldsWithStore<T> + HostIncomingRequestWithStore<T> + HostOutgoingRequestWithStore<T> + HostRequestOptionsWithStore<T> + HostResponseOutparamWithStore<T> + HostIncomingResponseWithStore<T> + HostIncomingBodyWithStore<T> + HostFutureTrailersWithStore<T> + HostOutgoingResponseWithStore<T> + HostOutgoingBodyWithStore<T> + HostFutureIncomingResponseWithStore<T> + ?Sized,
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for Hwhere
H: HasData + HostFieldsWithStore<T> + HostRequestWithStore<T> + HostRequestOptionsWithStore<T> + HostResponseWithStore<T> + ?Sized,
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for Hwhere
H: HasData + HostUdpSocketWithStore<T> + HostIncomingDatagramStreamWithStore<T> + HostOutgoingDatagramStreamWithStore<T> + ?Sized,
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for Hwhere
H: HasData + HostDescriptorWithStore<T> + HostDirectoryEntryStreamWithStore<T> + Send + ?Sized,
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for Hwhere
H: HasData + HostUdpSocketWithStore<T> + HostIncomingDatagramStreamWithStore<T> + HostOutgoingDatagramStreamWithStore<T> + Send + ?Sized,
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
impl<H, T> HostWithStore<T> for H
§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