Struct viceroy_lib::ExecuteCtx

source ·
pub struct ExecuteCtx { /* private fields */ }
Expand description

Execution context used by a ViceroyService.

This is all of the state needed to instantiate a module, in order to respond to an HTTP request. Note that it is very important that ExecuteCtx be cheaply clonable, as it is cloned every time that a viceroy service handles an incoming connection.

Implementations§

Create a new execution context, given the path to a module and a set of experimental wasi modules.

Get the engine for this execution context.

Get the backends for this execution context.

Set the backends for this execution context.

Get the geolocation mappings for this execution context.

Set the geolocation mappings for this execution context.

Get the dictionaries for this execution context.

Set the dictionaries for this execution context.

Set the object store for this execution context.

Set the secret stores for this execution context.

Set the path to the config for this execution context.

Whether to treat stdout as a logging endpoint.

Set the stdout logging policy for this execution context.

Whether to treat stderr as a logging endpoint.

Set the stderr logging policy for this execution context.

Gets the TLS configuration

Asynchronously handle a request.

This method fully instantiates the wasm module housed within the ExecuteCtx, including running the wasm start function. It then proceeds to execute the instantiated module’s WASI entry point, running to completion. If execution results in an error, a response is still produced, but with a 500 status code.

Build time: Before you build or test your code, we recommend to set the release flag e.g. cargo test --release otherwise the execution will be very slow. This has to do with the Cranelift compiler, which is extremely slow when compiled in debug mode.

Example
use hyper::{Body, http::Request};
let ctx = ExecuteCtx::new("path/to/a/file.wasm", ProfilingStrategy::None, HashSet::new())?;
let resp = ctx.handle_request(req, "127.0.0.1".parse().unwrap()).await?;

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Query the “status” flags for the self file descriptor.
Create a new SetFdFlags value for use with set_fd_flags. Read more
Set the “status” flags for the self file descriptor. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more