pub struct Ctx<H>where
H: MinimalHandler,{ /* private fields */ }Expand description
Wasmtime Context for a component instance, with access to
WASI context, HTTP context, and WRPC Invocation context.
This is a low-level API and has to be paired with Component::new_with_linker.
Trait Implementations§
Source§impl<H: MinimalHandler> Debug for Ctx<H>
impl<H: MinimalHandler> Debug for Ctx<H>
Source§impl<H> Host for Ctx<H>where
H: Handler,
impl<H> Host for Ctx<H>where
H: Handler,
Source§async fn create_container(
&mut self,
name: ContainerName,
) -> Result<Result<Resource<Container>, Error>>
async fn create_container( &mut self, name: ContainerName, ) -> Result<Result<Resource<Container>, Error>>
creates a new empty container
Source§async fn get_container(
&mut self,
name: ContainerName,
) -> Result<Result<Resource<Container>, Error>>
async fn get_container( &mut self, name: ContainerName, ) -> Result<Result<Resource<Container>, Error>>
retrieves a container by name
Source§async fn delete_container(
&mut self,
name: ContainerName,
) -> Result<Result<(), Error>>
async fn delete_container( &mut self, name: ContainerName, ) -> Result<Result<(), Error>>
deletes a container and all objects within it
Source§async fn container_exists(
&mut self,
name: ContainerName,
) -> Result<Result<bool, Error>>
async fn container_exists( &mut self, name: ContainerName, ) -> Result<Result<bool, Error>>
returns true if the container exists
Source§impl<H> Host for Ctx<H>where
H: Handler,
impl<H> Host for Ctx<H>where
H: Handler,
Source§async fn get_many(
&mut self,
bucket: Resource<Bucket>,
keys: Vec<String>,
) -> Result<Result<Vec<Option<(String, Vec<u8>)>>, Error>>
async fn get_many( &mut self, bucket: Resource<Bucket>, keys: Vec<String>, ) -> Result<Result<Vec<Option<(String, Vec<u8>)>>, Error>>
Get the key-value pairs associated with the keys in the store. It returns a list of
key-value pairs. Read more
Source§impl<H> Host for Ctx<H>where
H: Handler,
impl<H> Host for Ctx<H>where
H: Handler,
Source§impl<H> Host for Ctx<H>where
H: Handler,
impl<H> Host for Ctx<H>where
H: Handler,
Source§async fn request(
&mut self,
client: Resource<Box<dyn Client + Send + Sync>>,
topic: Topic,
message: Resource<Message>,
options: Option<Resource<RequestOptions>>,
) -> Result<Result<Vec<Resource<Message>>, Error>>
async fn request( &mut self, client: Resource<Box<dyn Client + Send + Sync>>, topic: Topic, message: Resource<Message>, options: Option<Resource<RequestOptions>>, ) -> Result<Result<Vec<Resource<Message>>, Error>>
Performs a blocking request/reply operation with an optional set of request options. Read more
Source§async fn reply(
&mut self,
reply_to: Resource<Message>,
message: Resource<Message>,
) -> Result<Result<(), Error>>
async fn reply( &mut self, reply_to: Resource<Message>, message: Resource<Message>, ) -> Result<Result<(), Error>>
Replies to the given message with the given response message. The details of which topic
the message is sent to is up to the implementation. This allows for reply-to details to be
handled in the best way possible for the underlying messaging system. Read more
Source§impl<H: Handler> Host for Ctx<H>
impl<H: Handler> Host for Ctx<H>
Source§async fn set_link_name(
&mut self,
link_name: String,
interfaces: Vec<Resource<Arc<CallTargetInterface>>>,
) -> Result<Result<(), String>>
async fn set_link_name( &mut self, link_name: String, interfaces: Vec<Resource<Arc<CallTargetInterface>>>, ) -> Result<Result<(), String>>
Set a link name to use for all interfaces specified. This is advanced functionality only
available within wasmcloud and, as such, is exposed here as part of the wasmcloud:bus package.
This is used when you are linking multiple of the same interfaces
(i.e. a keyvalue implementation for caching and another one for secrets) to a component. Read more
Source§impl<H: Handler> Host for Ctx<H>
impl<H: Handler> Host for Ctx<H>
Source§async fn set_link_name(
&mut self,
link_name: String,
interfaces: Vec<Resource<Arc<CallTargetInterface>>>,
) -> Result<()>
async fn set_link_name( &mut self, link_name: String, interfaces: Vec<Resource<Arc<CallTargetInterface>>>, ) -> Result<()>
Set a link name to use for all interfaces specified. This is advanced functionality only
available within wasmcloud and, as such, is exposed here as part of the wasmcloud:bus package.
This is used when you are linking multiple of the same interfaces
(i.e. a keyvalue implementation for caching and another one for secrets) to a component.
Source§impl<H: Handler> Host for Ctx<H>
impl<H: Handler> Host for Ctx<H>
Source§impl<H> HostBucket for Ctx<H>where
H: Handler,
impl<H> HostBucket for Ctx<H>where
H: Handler,
Source§async fn get(
&mut self,
bucket: Resource<Bucket>,
key: String,
) -> Result<Result<Option<Vec<u8>>, Error>>
async fn get( &mut self, bucket: Resource<Bucket>, key: String, ) -> Result<Result<Option<Vec<u8>>, Error>>
Get the value associated with the specified
key Read moreSource§async fn set(
&mut self,
bucket: Resource<Bucket>,
key: String,
outgoing_value: Vec<u8>,
) -> Result<Result<(), Error>>
async fn set( &mut self, bucket: Resource<Bucket>, key: String, outgoing_value: Vec<u8>, ) -> Result<Result<(), Error>>
Set the value associated with the key in the store. If the key already
exists in the store, it overwrites the value. Read more
Source§async fn delete(
&mut self,
bucket: Resource<Bucket>,
key: String,
) -> Result<Result<(), Error>>
async fn delete( &mut self, bucket: Resource<Bucket>, key: String, ) -> Result<Result<(), Error>>
Delete the key-value pair associated with the key in the store. Read more
Source§async fn exists(
&mut self,
bucket: Resource<Bucket>,
key: String,
) -> Result<Result<bool, Error>>
async fn exists( &mut self, bucket: Resource<Bucket>, key: String, ) -> Result<Result<bool, Error>>
Check if the key exists in the store. Read more
Source§async fn list_keys(
&mut self,
bucket: Resource<Bucket>,
cursor: Option<u64>,
) -> Result<Result<KeyResponse, Error>>
async fn list_keys( &mut self, bucket: Resource<Bucket>, cursor: Option<u64>, ) -> Result<Result<KeyResponse, Error>>
Get all the keys in the store with an optional cursor (for use in pagination). It
returns a list of keys. Please note that for most KeyValue implementations, this is a
can be a very expensive operation and so it should be used judiciously. Implementations
can return any number of keys in a single response, but they should never attempt to
send more data than is reasonable (i.e. on a small edge device, this may only be a few
KB, while on a large machine this could be several MB). Any response should also return
a cursor that can be used to fetch the next page of keys. See the
key-response record
for more information. Read moreasync fn drop(&mut self, bucket: Resource<Bucket>) -> Result<()>
Source§impl<H: Handler> HostCallTargetInterface for Ctx<H>
impl<H: Handler> HostCallTargetInterface for Ctx<H>
Source§impl<H: Handler> HostCallTargetInterface for Ctx<H>
impl<H: Handler> HostCallTargetInterface for Ctx<H>
Source§impl<H> HostClient for Ctx<H>where
H: Handler,
impl<H> HostClient for Ctx<H>where
H: Handler,
async fn connect( &mut self, name: String, ) -> Result<Result<Resource<Box<dyn Client + Send + Sync>>, Error>>
async fn disconnect( &mut self, client: Resource<Box<dyn Client + Send + Sync>>, ) -> Result<Result<(), Error>>
async fn drop( &mut self, client: Resource<Box<dyn Client + Send + Sync>>, ) -> Result<()>
Source§impl<H> HostContainer for Ctx<H>where
H: Handler,
impl<H> HostContainer for Ctx<H>where
H: Handler,
async fn drop(&mut self, container: Resource<Container>) -> Result<()>
Source§async fn name(
&mut self,
container: Resource<Container>,
) -> Result<Result<String, Error>>
async fn name( &mut self, container: Resource<Container>, ) -> Result<Result<String, Error>>
returns container name
Source§async fn info(
&mut self,
container: Resource<Container>,
) -> Result<Result<ContainerMetadata, Error>>
async fn info( &mut self, container: Resource<Container>, ) -> Result<Result<ContainerMetadata, Error>>
returns container metadata
Source§async fn get_data(
&mut self,
container: Resource<Container>,
name: ObjectName,
start: u64,
end: u64,
) -> Result<Result<Resource<IncomingValue>, Error>>
async fn get_data( &mut self, container: Resource<Container>, name: ObjectName, start: u64, end: u64, ) -> Result<Result<Resource<IncomingValue>, Error>>
retrieves an object or portion of an object, as a resource.
Start and end offsets are inclusive.
Once a data-blob resource has been created, the underlying bytes are held by the blobstore service for the lifetime
of the data-blob resource, even if the object they came from is later deleted.
Source§async fn write_data(
&mut self,
container: Resource<Container>,
object: ObjectName,
data: Resource<OutgoingValue>,
) -> Result<Result<(), Error>>
async fn write_data( &mut self, container: Resource<Container>, object: ObjectName, data: Resource<OutgoingValue>, ) -> Result<Result<(), Error>>
creates or replaces an object with the data blob.
Source§async fn list_objects(
&mut self,
container: Resource<Container>,
) -> Result<Result<Resource<StreamObjectNames>, Error>>
async fn list_objects( &mut self, container: Resource<Container>, ) -> Result<Result<Resource<StreamObjectNames>, Error>>
returns list of objects in the container. Order is undefined.
Source§async fn delete_object(
&mut self,
container: Resource<Container>,
name: ObjectName,
) -> Result<Result<(), Error>>
async fn delete_object( &mut self, container: Resource<Container>, name: ObjectName, ) -> Result<Result<(), Error>>
deletes object.
does not return error if object did not exist.
Source§async fn delete_objects(
&mut self,
container: Resource<Container>,
names: Vec<ObjectName>,
) -> Result<Result<(), Error>>
async fn delete_objects( &mut self, container: Resource<Container>, names: Vec<ObjectName>, ) -> Result<Result<(), Error>>
deletes multiple objects in the container
Source§async fn has_object(
&mut self,
container: Resource<Container>,
object: ObjectName,
) -> Result<Result<bool, Error>>
async fn has_object( &mut self, container: Resource<Container>, object: ObjectName, ) -> Result<Result<bool, Error>>
returns true if the object exists in this container
Source§async fn object_info(
&mut self,
container: Resource<Container>,
name: ObjectName,
) -> Result<Result<ObjectMetadata, Error>>
async fn object_info( &mut self, container: Resource<Container>, name: ObjectName, ) -> Result<Result<ObjectMetadata, Error>>
returns metadata for the object
Source§impl<H: Handler> HostError for Ctx<H>
impl<H: Handler> HostError for Ctx<H>
Source§async fn from_rpc_error(
&mut self,
error: Resource<Error>,
) -> Result<Resource<Error>>
async fn from_rpc_error( &mut self, error: Resource<Error>, ) -> Result<Resource<Error>>
Converts
wrpc:rpc/error.error into error.Source§async fn from_io_error(
&mut self,
error: Resource<Error>,
) -> Result<Result<Resource<Error>, Resource<Error>>>
async fn from_io_error( &mut self, error: Resource<Error>, ) -> Result<Result<Resource<Error>, Resource<Error>>>
Source§async fn to_debug_string(&mut self, error: Resource<Error>) -> Result<String>
async fn to_debug_string(&mut self, error: Resource<Error>) -> Result<String>
Returns a string that is suitable to assist humans in debugging
this error. Read more
async fn drop(&mut self, error: Resource<Error>) -> Result<()>
Source§impl<H: Handler> HostIncomingValue for Ctx<H>
impl<H: Handler> HostIncomingValue for Ctx<H>
async fn drop(&mut self, incoming_value: Resource<IncomingValue>) -> Result<()>
async fn incoming_value_consume_sync( &mut self, incoming_value: Resource<IncomingValue>, ) -> Result<Result<Vec<u8>, Error>>
async fn incoming_value_consume_async( &mut self, incoming_value: Resource<IncomingValue>, ) -> Result<Result<Resource<DynInputStream>, Error>>
async fn size( &mut self, _incoming_value: Resource<IncomingValue>, ) -> Result<u64>
Source§impl<H> HostMessage for Ctx<H>where
H: Handler,
impl<H> HostMessage for Ctx<H>where
H: Handler,
async fn new(&mut self, data: Vec<u8>) -> Result<Resource<Message>>
Source§async fn topic(&mut self, msg: Resource<Message>) -> Result<Option<Topic>>
async fn topic(&mut self, msg: Resource<Message>) -> Result<Option<Topic>>
The topic/subject/channel this message was received on, if any
Source§async fn content_type(
&mut self,
msg: Resource<Message>,
) -> Result<Option<String>>
async fn content_type( &mut self, msg: Resource<Message>, ) -> Result<Option<String>>
An optional content-type describing the format of the data in the message. This is
sometimes described as the “format” type
Source§async fn set_content_type(
&mut self,
msg: Resource<Message>,
content_type: String,
) -> Result<()>
async fn set_content_type( &mut self, msg: Resource<Message>, content_type: String, ) -> Result<()>
Set the content-type describing the format of the data in the message. This is
sometimes described as the “format” type
Source§async fn set_data(&mut self, msg: Resource<Message>, buf: Vec<u8>) -> Result<()>
async fn set_data(&mut self, msg: Resource<Message>, buf: Vec<u8>) -> Result<()>
Set the opaque blob of data for this message, discarding the old value
Source§async fn metadata(&mut self, msg: Resource<Message>) -> Result<Option<Metadata>>
async fn metadata(&mut self, msg: Resource<Message>) -> Result<Option<Metadata>>
Optional metadata (also called headers or attributes in some systems) attached to the
message. This metadata is simply decoration and should not be interpreted by a host
to ensure portability across different implementors (e.g., Kafka -> NATS, etc.).
Source§async fn add_metadata(
&mut self,
msg: Resource<Message>,
key: String,
value: String,
) -> Result<()>
async fn add_metadata( &mut self, msg: Resource<Message>, key: String, value: String, ) -> Result<()>
Add a new key-value pair to the metadata, overwriting any existing value for the same key
Source§async fn set_metadata(
&mut self,
msg: Resource<Message>,
meta: Metadata,
) -> Result<()>
async fn set_metadata( &mut self, msg: Resource<Message>, meta: Metadata, ) -> Result<()>
Set the metadata
Source§async fn remove_metadata(
&mut self,
msg: Resource<Message>,
key: String,
) -> Result<()>
async fn remove_metadata( &mut self, msg: Resource<Message>, key: String, ) -> Result<()>
Remove a key-value pair from the metadata
async fn drop(&mut self, rep: Resource<Message>) -> Result<()>
Source§impl<H: Handler> HostOutgoingValue for Ctx<H>
impl<H: Handler> HostOutgoingValue for Ctx<H>
async fn drop(&mut self, outgoing_value: Resource<OutgoingValue>) -> Result<()>
async fn new_outgoing_value(&mut self) -> Result<Resource<OutgoingValue>>
Source§async fn outgoing_value_write_body(
&mut self,
outgoing_value: Resource<OutgoingValue>,
) -> Result<Result<Resource<DynOutputStream>, ()>>
async fn outgoing_value_write_body( &mut self, outgoing_value: Resource<OutgoingValue>, ) -> Result<Result<Resource<DynOutputStream>, ()>>
Returns a stream for writing the value contents. Read more
Source§async fn finish(
&mut self,
this: Resource<OutgoingValue>,
) -> Result<Result<(), Error>>
async fn finish( &mut self, this: Resource<OutgoingValue>, ) -> Result<Result<(), Error>>
Finalize an outgoing value. This must be
called to signal that the outgoing value is complete. If the
outgoing-value
is dropped without calling outgoing-value.finalize, the implementation
should treat the value as corrupted.Source§impl<H> HostRequestOptions for Ctx<H>where
H: Handler,
impl<H> HostRequestOptions for Ctx<H>where
H: Handler,
Source§async fn new(&mut self) -> Result<Resource<RequestOptions>>
async fn new(&mut self) -> Result<Resource<RequestOptions>>
Creates a new request options resource with no options set.
Source§async fn set_timeout_ms(
&mut self,
opts: Resource<RequestOptions>,
timeout_ms: u32,
) -> Result<()>
async fn set_timeout_ms( &mut self, opts: Resource<RequestOptions>, timeout_ms: u32, ) -> Result<()>
The maximum amount of time to wait for a response. If the timeout value is not set, then
the request/reply operation will block until a message is received in response.
Source§async fn set_expected_replies(
&mut self,
opts: Resource<RequestOptions>,
expected_replies: u32,
) -> Result<()>
async fn set_expected_replies( &mut self, opts: Resource<RequestOptions>, expected_replies: u32, ) -> Result<()>
The maximum number of replies to expect before returning.
async fn drop(&mut self, opts: Resource<RequestOptions>) -> Result<()>
Source§impl<H: Handler> HostSecret for Ctx<H>
impl<H: Handler> HostSecret for Ctx<H>
Source§impl<H: Handler> HostStreamObjectNames for Ctx<H>
impl<H: Handler> HostStreamObjectNames for Ctx<H>
Source§impl<H> WasiHttpView for Ctx<H>where
H: Handler,
impl<H> WasiHttpView for Ctx<H>where
H: Handler,
Source§fn ctx(&mut self) -> &mut WasiHttpCtx
fn ctx(&mut self) -> &mut WasiHttpCtx
Returns a mutable reference to the WASI HTTP context.
Source§fn table(&mut self) -> &mut ResourceTable
fn table(&mut self) -> &mut ResourceTable
Returns the table used to manage resources.
Source§fn send_request(
&mut self,
request: Request<HyperOutgoingBody>,
config: OutgoingRequestConfig,
) -> HttpResult<HostFutureIncomingResponse>where
Self: Sized,
fn send_request(
&mut self,
request: Request<HyperOutgoingBody>,
config: OutgoingRequestConfig,
) -> HttpResult<HostFutureIncomingResponse>where
Self: Sized,
Send an outgoing request.
Source§fn new_incoming_request<B>(
&mut self,
scheme: Scheme,
req: Request<B>,
) -> Result<Resource<HostIncomingRequest>, Error>
fn new_incoming_request<B>( &mut self, scheme: Scheme, req: Request<B>, ) -> Result<Resource<HostIncomingRequest>, Error>
Create a new incoming request resource.
Source§fn new_response_outparam(
&mut self,
result: Sender<Result<Response<BoxBody<Bytes, ErrorCode>>, ErrorCode>>,
) -> Result<Resource<HostResponseOutparam>, Error>
fn new_response_outparam( &mut self, result: Sender<Result<Response<BoxBody<Bytes, ErrorCode>>, ErrorCode>>, ) -> Result<Resource<HostResponseOutparam>, Error>
Create a new outgoing response resource.
Source§fn is_forbidden_header(&mut self, name: &HeaderName) -> bool
fn is_forbidden_header(&mut self, name: &HeaderName) -> bool
Whether a given header should be considered forbidden and not allowed.
Source§fn outgoing_body_buffer_chunks(&mut self) -> usize
fn outgoing_body_buffer_chunks(&mut self) -> usize
Number of distinct write calls to the outgoing body’s output-stream
that the implementation will buffer.
Default: 1.
Source§fn outgoing_body_chunk_size(&mut self) -> usize
fn outgoing_body_chunk_size(&mut self) -> usize
Maximum size allowed in a write call to the outgoing body’s output-stream.
Default: 1024 * 1024.
Source§impl<H: MinimalHandler> WasiView for Ctx<H>
impl<H: MinimalHandler> WasiView for Ctx<H>
Source§fn ctx(&mut self) -> WasiCtxView<'_>
fn ctx(&mut self) -> WasiCtxView<'_>
Yields mutable access to the
WasiCtx configuration used for this
context.impl<H: Handler> Host for Ctx<H>
impl<H> Host for Ctx<H>where
H: Handler,
impl<H> Host for Ctx<H>where
H: Handler,
impl<H> Host for Ctx<H>where
H: Handler,
impl<H: Handler> Host for Ctx<H>
Auto Trait Implementations§
impl<H> Freeze for Ctx<H>where
H: Freeze,
impl<H> !RefUnwindSafe for Ctx<H>
impl<H> Send for Ctx<H>
impl<H> !Sync for Ctx<H>
impl<H> Unpin for Ctx<H>where
H: Unpin,
impl<H> !UnwindSafe for Ctx<H>
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§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.Source§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,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
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 moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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