pub trait Invocable:
Send
+ Sync
+ 'static {
// Required methods
fn object_type(&self) -> TypeId;
fn method_type(&self) -> TypeId;
fn object_and_method_type_names(&self) -> (&'static str, &'static str);
fn invoke_special(
&self,
obj: Arc<dyn Object>,
method: Box<dyn DynMethod>,
ctx: Arc<dyn Context>,
) -> Result<BoxFuture<'static, Box<dyn Any>>, InvokeError>;
// Provided method
fn describe_invocable(&self, f: &mut Formatter<'_>) -> Result { ... }
}
Expand description
An installable handler for running a method on an object type.
Callers should not typically implement this trait directly; instead, use one of its blanket implementations.
Required Methods§
Sourcefn object_type(&self) -> TypeId
fn object_type(&self) -> TypeId
Return the type of object that this Invocable will accept.
Sourcefn method_type(&self) -> TypeId
fn method_type(&self) -> TypeId
Return the type of method that this Invocable will accept.
Sourcefn object_and_method_type_names(&self) -> (&'static str, &'static str)
fn object_and_method_type_names(&self) -> (&'static str, &'static str)
Return the names of the type for the object and methods types this Invocable will accept.
Caveats apply as for any::type_name
.
Sourcefn invoke_special(
&self,
obj: Arc<dyn Object>,
method: Box<dyn DynMethod>,
ctx: Arc<dyn Context>,
) -> Result<BoxFuture<'static, Box<dyn Any>>, InvokeError>
fn invoke_special( &self, obj: Arc<dyn Object>, method: Box<dyn DynMethod>, ctx: Arc<dyn Context>, ) -> Result<BoxFuture<'static, Box<dyn Any>>, InvokeError>
Invoke this method on an object.
Requires that obj
has the type self.object_type()
,
and that method
has the type self.method_type()
.
Unlike RpcInvocable::invoke()
, does not convert the resulting types
into serializable formats, and does not require that they can be
so converted.
Provided Methods§
Sourcefn describe_invocable(&self, f: &mut Formatter<'_>) -> Result
fn describe_invocable(&self, f: &mut Formatter<'_>) -> Result
Describe the types for this Invocable. Used for debugging.