Struct oc_wasm_safe::component::Invoker
source · pub struct Invoker(/* private fields */);
Expand description
An object that is capable of invoking methods.
Because only one method can be invoked at a time, only one value of this type can exist. An
application written as a state machine should take the instance and store it in a static
variable. An application using async
and await
in which only one task needs to make method
calls should either take the value in that task, or take it in the top-level task and move it
into the task that needs it. An application using async
and await
in which multiple tasks
all need to make method calls needs to arrange mutual exclusion so that only one task can
access the invoker at a time.
Implementations§
source§impl Invoker
impl Invoker
sourcepub fn take() -> Option<Self>
pub fn take() -> Option<Self>
Returns the invoker.
This function can only be called once in the lifetime of the application. On the second and
subsequent calls, it will return None
.
sourcepub fn component_method<'invoker>(
&'invoker mut self,
address: &Address,
method: &str,
params: Option<&[u8]>
) -> Result<(InvokeResult, MethodCall<'invoker>)>
pub fn component_method<'invoker>( &'invoker mut self, address: &Address, method: &str, params: Option<&[u8]> ) -> Result<(InvokeResult, MethodCall<'invoker>)>
Starts invoking a method on a component.
The address
parameter identifies the component by its UUID. The method
parameter
identifies the method by its name. The params
parameter, if present, contains a
CBOR-encoded array of parameters to pass to the method.
§Errors
CborDecode
is returned if theparams
parameter is present but contains an invalid or unsupported CBOR sequence.BadDescriptor
is returned if the parameters contain a descriptor reference to a descriptor that is not open.TooManyDescriptors
is returned if the descriptor table is too full and some descriptors must be closed before another method call can be made.
sourcepub fn value<'invoker>(
&'invoker mut self,
descriptor: &impl AsDescriptor,
params: Option<&[u8]>
) -> Result<(InvokeResult, MethodCall<'invoker>)>
pub fn value<'invoker>( &'invoker mut self, descriptor: &impl AsDescriptor, params: Option<&[u8]> ) -> Result<(InvokeResult, MethodCall<'invoker>)>
Starts invoking a callable opaque value.
The descriptor
parameter identifies the opaque value by its descriptor. The params
parameter, if present, contains a CBOR-encoded array of parameters to pass to the method.
§Errors
CborDecode
is returned if theparams
parameter is present but contains an invalid or unsupported CBOR sequence.BadDescriptor
is returned if the parameters contain a descriptor reference to a descriptor that is not open.TooManyDescriptors
is returned if the descriptor table is too full and some descriptors must be closed before another method call can be made.
sourcepub fn value_indexed_read<'invoker>(
&'invoker mut self,
descriptor: &impl AsDescriptor,
params: Option<&[u8]>
) -> Result<(InvokeResult, MethodCall<'invoker>)>
pub fn value_indexed_read<'invoker>( &'invoker mut self, descriptor: &impl AsDescriptor, params: Option<&[u8]> ) -> Result<(InvokeResult, MethodCall<'invoker>)>
Starts reading from an index of an opaque value.
The descriptor
parameter identifies the opaque value by its descriptor. The params
parameter, if present, contains a CBOR-encoded array of parameters to use for indexing.
§Errors
CborDecode
is returned if theparams
parameter is present but contains an invalid or unsupported CBOR sequence.BadDescriptor
is returned if the parameters contain a descriptor reference to a descriptor that is not open.TooManyDescriptors
is returned if the descriptor table is too full and some descriptors must be closed before another method call can be made.
sourcepub fn value_indexed_write<'invoker>(
&'invoker mut self,
descriptor: &impl AsDescriptor,
params: Option<&[u8]>
) -> Result<(InvokeResult, MethodCall<'invoker>)>
pub fn value_indexed_write<'invoker>( &'invoker mut self, descriptor: &impl AsDescriptor, params: Option<&[u8]> ) -> Result<(InvokeResult, MethodCall<'invoker>)>
Starts writing to an index of an opaque value.
The descriptor
parameter identifies the opaque value by its descriptor. The params
parameter, if present, contains a CBOR-encoded array of parameters to use for indexing and
the value to write.
§Errors
CborDecode
is returned if theparams
parameter is present but contains an invalid or unsupported CBOR sequence.BadDescriptor
is returned if the parameters contain a descriptor reference to a descriptor that is not open.TooManyDescriptors
is returned if the descriptor table is too full and some descriptors must be closed before another method call can be made.
sourcepub fn value_method<'invoker>(
&'invoker mut self,
descriptor: &impl AsDescriptor,
method: &str,
params: Option<&[u8]>
) -> Result<(InvokeResult, MethodCall<'invoker>)>
pub fn value_method<'invoker>( &'invoker mut self, descriptor: &impl AsDescriptor, method: &str, params: Option<&[u8]> ) -> Result<(InvokeResult, MethodCall<'invoker>)>
Starts invoking a method on an opaque value.
The descriptor
parameter identifies the opaque value by its descriptor. The method
parameter identifies the method by its name. The params
parameter, if present, contains a
CBOR-encoded array of parameters to pass to the method.
§Errors
CborDecode
is returned if theparams
parameter is present but contains an invalid or unsupported CBOR sequence.BadDescriptor
is returned if the parameters contain a descriptor reference to a descriptor that is not open.TooManyDescriptors
is returned if the descriptor table is too full and some descriptors must be closed before another method call can be made.