Struct wasmtime_wasi_http::types::WasiHttpImpl

source ·
#[repr(transparent)]
pub struct WasiHttpImpl<T>(pub T);
Expand description

A concrete structure that all generated Host traits are implemented for.

This type serves as a small newtype wrapper to implement all of the Host traits for wasi:http. This type is internally used and is only needed if you’re interacting with add_to_linker functions generated by bindings themselves (or add_to_linker_get_host).

This type is automatically used when using add_to_linker_async or add_to_linker_sync and doesn’t need to be manually configured.

Tuple Fields§

§0: T

Trait Implementations§

source§

impl<T> Host for WasiHttpImpl<T>
where T: WasiHttpView,

source§

fn handle( &mut self, request_id: Resource<HostOutgoingRequest>, options: Option<Resource<RequestOptions>>, ) -> HttpResult<Resource<HostFutureIncomingResponse>>

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 more
source§

impl<T> Host for WasiHttpImpl<T>
where T: WasiHttpView,

source§

fn convert_error_code(&mut self, err: HttpError) -> Result<ErrorCode>

source§

fn http_error_code( &mut self, err: Resource<IoError>, ) -> Result<Option<ErrorCode>>

Attempts to extract a http-related error from the wasi:io error provided. Read more
source§

impl<T> HostFields for WasiHttpImpl<T>
where T: WasiHttpView,

source§

fn new(&mut self) -> Result<Resource<HostFields>>

Construct an empty HTTP Fields. Read more
source§

fn from_list( &mut self, entries: Vec<(String, Vec<u8>)>, ) -> Result<Result<Resource<HostFields>, HeaderError>>

Construct an HTTP Fields. Read more
source§

fn drop(&mut self, fields: Resource<HostFields>) -> Result<()>

source§

fn get( &mut self, fields: Resource<HostFields>, name: String, ) -> Result<Vec<Vec<u8>>>

Get all of the values corresponding to a key. If the key is not present in this fields or is syntactically invalid, an empty list is returned. However, if the key 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<HostFields>, name: String) -> Result<bool>

Returns true when the key is present in this fields. If the key is syntactically invalid, false is returned.
source§

fn set( &mut self, fields: Resource<HostFields>, name: String, byte_values: Vec<Vec<u8>>, ) -> Result<Result<(), HeaderError>>

Set all of the values for a key. Clears any existing values for that key, if they have been set. Read more
source§

fn delete( &mut self, fields: Resource<HostFields>, name: String, ) -> Result<Result<(), HeaderError>>

Delete all values for a key. Does nothing if no values for the key exist. Read more
source§

fn append( &mut self, fields: Resource<HostFields>, name: String, value: Vec<u8>, ) -> Result<Result<(), HeaderError>>

Append a value for a key. Does not change or delete any existing values for that key. Read more
source§

fn entries( &mut self, fields: Resource<HostFields>, ) -> Result<Vec<(String, Vec<u8>)>>

Retrieve the full set of keys and values in the Fields. Like the constructor, the list represents each key-value pair. Read more
source§

fn clone( &mut self, fields: Resource<HostFields>, ) -> Result<Resource<HostFields>>

Make a deep copy of the Fields. Equivalent in behavior to calling the fields constructor on the return value of entries. The resulting fields is mutable.
source§

impl<T> HostFutureIncomingResponse for WasiHttpImpl<T>
where T: WasiHttpView,

source§

fn drop(&mut self, id: Resource<HostFutureIncomingResponse>) -> Result<()>

source§

fn get( &mut self, id: Resource<HostFutureIncomingResponse>, ) -> Result<Option<Result<Result<Resource<HostIncomingResponse>, ErrorCode>, ()>>>

Returns the incoming HTTP Response, or an error, once one is ready. Read more
source§

fn subscribe( &mut self, id: Resource<HostFutureIncomingResponse>, ) -> Result<Resource<Pollable>>

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<T> HostFutureTrailers for WasiHttpImpl<T>
where T: WasiHttpView,

source§

fn drop(&mut self, id: Resource<HostFutureTrailers>) -> Result<()>

source§

fn subscribe( &mut self, index: Resource<HostFutureTrailers>, ) -> Result<Resource<Pollable>>

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§

fn get( &mut self, id: Resource<HostFutureTrailers>, ) -> Result<Option<Result<Result<Option<Resource<Trailers>>, ErrorCode>, ()>>>

Returns the contents of the trailers, or an error which occurred, once the future is ready. Read more
source§

impl<T> HostIncomingBody for WasiHttpImpl<T>
where T: WasiHttpView,

source§

fn stream( &mut self, id: Resource<HostIncomingBody>, ) -> Result<Result<Resource<InputStream>, ()>>

Returns the contents of the body, as a stream of bytes. Read more
source§

fn finish( &mut self, id: Resource<HostIncomingBody>, ) -> Result<Resource<HostFutureTrailers>>

Takes ownership of incoming-body, and returns a future-trailers. This function will trap if the input-stream child is still alive.
source§

fn drop(&mut self, id: Resource<HostIncomingBody>) -> Result<()>

source§

impl<T> HostIncomingRequest for WasiHttpImpl<T>
where T: WasiHttpView,

source§

fn method(&mut self, id: Resource<HostIncomingRequest>) -> Result<Method>

Returns the method of the incoming request.
source§

fn path_with_query( &mut self, id: Resource<HostIncomingRequest>, ) -> Result<Option<String>>

Returns the path with query parameters from the request, as a string.
source§

fn scheme( &mut self, id: Resource<HostIncomingRequest>, ) -> Result<Option<Scheme>>

Returns the protocol scheme from the request.
source§

fn authority( &mut self, id: Resource<HostIncomingRequest>, ) -> Result<Option<String>>

Returns the authority of the Request’s target URI, if present.
source§

fn headers( &mut self, id: Resource<HostIncomingRequest>, ) -> Result<Resource<Headers>>

Get the headers associated with the request. Read more
source§

fn consume( &mut self, id: Resource<HostIncomingRequest>, ) -> Result<Result<Resource<HostIncomingBody>, ()>>

Gives the incoming-body associated with this request. Will only return success at most once, and subsequent calls will return error.
source§

fn drop(&mut self, id: Resource<HostIncomingRequest>) -> Result<()>

source§

impl<T> HostIncomingResponse for WasiHttpImpl<T>
where T: WasiHttpView,

source§

fn drop(&mut self, response: Resource<HostIncomingResponse>) -> Result<()>

source§

fn status( &mut self, response: Resource<HostIncomingResponse>, ) -> Result<StatusCode>

Returns the status code from the incoming response.
source§

fn headers( &mut self, response: Resource<HostIncomingResponse>, ) -> Result<Resource<Headers>>

Returns the headers from the incoming response. Read more
source§

fn consume( &mut self, response: Resource<HostIncomingResponse>, ) -> Result<Result<Resource<HostIncomingBody>, ()>>

Returns the incoming body. May be called at most once. Returns error if called additional times.
source§

impl<T> HostOutgoingBody for WasiHttpImpl<T>
where T: WasiHttpView,

source§

fn write( &mut self, id: Resource<HostOutgoingBody>, ) -> Result<Result<Resource<OutputStream>, ()>>

Returns a stream for writing the body contents. Read more
source§

fn finish( &mut self, id: Resource<HostOutgoingBody>, ts: Option<Resource<Trailers>>, ) -> HttpResult<()>

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 more
source§

fn drop(&mut self, id: Resource<HostOutgoingBody>) -> Result<()>

source§

impl<T> HostOutgoingRequest for WasiHttpImpl<T>
where T: WasiHttpView,

source§

fn new( &mut self, headers: Resource<Headers>, ) -> Result<Resource<HostOutgoingRequest>>

Construct a new outgoing-request with a default method of GET, and none values for path-with-query, scheme, and authority. Read more
source§

fn body( &mut self, request: Resource<HostOutgoingRequest>, ) -> Result<Result<Resource<HostOutgoingBody>, ()>>

Returns the resource corresponding to the outgoing Body for this Request. Read more
source§

fn drop(&mut self, request: Resource<HostOutgoingRequest>) -> Result<()>

source§

fn method(&mut self, request: Resource<OutgoingRequest>) -> Result<Method>

Get the Method for the Request.
source§

fn set_method( &mut self, request: Resource<OutgoingRequest>, method: Method, ) -> Result<Result<(), ()>>

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>>

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<(), ()>>

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>>

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<(), ()>>

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.
source§

fn authority( &mut self, request: Resource<OutgoingRequest>, ) -> Result<Option<String>>

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.
source§

fn set_authority( &mut self, request: Resource<OutgoingRequest>, authority: Option<String>, ) -> Result<Result<(), ()>>

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§

fn headers( &mut self, request: Resource<OutgoingRequest>, ) -> Result<Resource<Headers>>

Get the headers associated with the Request. Read more
source§

impl<T> HostOutgoingResponse for WasiHttpImpl<T>
where T: WasiHttpView,

source§

fn new( &mut self, headers: Resource<Headers>, ) -> Result<Resource<HostOutgoingResponse>>

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 more
source§

fn body( &mut self, id: Resource<HostOutgoingResponse>, ) -> Result<Result<Resource<HostOutgoingBody>, ()>>

Returns the resource corresponding to the outgoing Body for this Response. Read more
source§

fn status_code( &mut self, id: Resource<HostOutgoingResponse>, ) -> Result<StatusCode>

Get the HTTP Status Code for the Response.
source§

fn set_status_code( &mut self, id: Resource<HostOutgoingResponse>, status: 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, id: Resource<HostOutgoingResponse>, ) -> Result<Resource<Headers>>

Get the headers associated with the Request. Read more
source§

fn drop(&mut self, id: Resource<HostOutgoingResponse>) -> Result<()>

source§

impl<T> HostRequestOptions for WasiHttpImpl<T>
where T: WasiHttpView,

source§

fn new(&mut self) -> Result<Resource<RequestOptions>>

Construct a default request-options value.
source§

fn connect_timeout( &mut self, opts: Resource<RequestOptions>, ) -> Result<Option<Duration>>

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<(), ()>>

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>>

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<(), ()>>

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>>

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<(), ()>>

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§

fn drop(&mut self, rep: Resource<RequestOptions>) -> Result<()>

source§

impl<T> HostResponseOutparam for WasiHttpImpl<T>
where T: WasiHttpView,

source§

fn drop(&mut self, id: Resource<HostResponseOutparam>) -> Result<()>

source§

fn set( &mut self, id: Resource<HostResponseOutparam>, resp: Result<Resource<HostOutgoingResponse>, ErrorCode>, ) -> Result<()>

Set the value of the response-outparam to either send a response, or indicate an error. Read more
source§

impl<T: WasiHttpView> WasiHttpView for WasiHttpImpl<T>

source§

fn ctx(&mut self) -> &mut WasiHttpCtx

Returns a mutable reference to the WASI HTTP context.
source§

fn table(&mut self) -> &mut ResourceTable

Returns a mutable reference to the WASI HTTP resource table.
source§

fn new_response_outparam( &mut self, result: Sender<Result<Response<HyperOutgoingBody>, ErrorCode>>, ) -> Result<Resource<HostResponseOutparam>>

Create a new outgoing response resource.
source§

fn send_request( &mut self, request: Request<HyperOutgoingBody>, config: OutgoingRequestConfig, ) -> HttpResult<HostFutureIncomingResponse>

Send an outgoing request.
source§

fn is_forbidden_header(&mut self, name: &HeaderName) -> bool

Whether a given header should be considered forbidden and not allowed.
source§

fn new_incoming_request<B>( &mut self, scheme: Scheme, req: Request<B>, ) -> Result<Resource<HostIncomingRequest>>
where B: Body<Data = Bytes, Error = Error> + Send + Sync + 'static, Self: Sized,

Create a new incoming request resource.

Auto Trait Implementations§

§

impl<T> Freeze for WasiHttpImpl<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for WasiHttpImpl<T>
where T: RefUnwindSafe,

§

impl<T> Send for WasiHttpImpl<T>
where T: Send,

§

impl<T> Sync for WasiHttpImpl<T>
where T: Sync,

§

impl<T> Unpin for WasiHttpImpl<T>
where T: Unpin,

§

impl<T> UnwindSafe for WasiHttpImpl<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> GetSetFdFlags for T

source§

fn get_fd_flags(&self) -> Result<FdFlags, Error>
where T: AsFilelike,

Query the “status” flags for the self file descriptor.
source§

fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>
where T: AsFilelike,

Create a new SetFdFlags value for use with set_fd_flags. Read more
source§

fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>
where T: AsFilelike,

Set the “status” flags for the self file descriptor. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more