Trait Invocable

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

Source

fn object_type(&self) -> TypeId

Return the type of object that this Invocable will accept.

Source

fn method_type(&self) -> TypeId

Return the type of method that this Invocable will accept.

Source

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.

Source

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§

Source

fn describe_invocable(&self, f: &mut Formatter<'_>) -> Result

Describe the types for this Invocable. Used for debugging.

Implementations on Foreign Types§

Source§

impl<M, OBJ, Fut, S, E> Invocable for fn(Arc<OBJ>, Box<M>, Arc<dyn Context + 'static>) -> Fut
where M: Method, OBJ: Object, S: 'static, E: 'static, Fut: Future<Output = Result<S, E>> + Send + 'static,

Source§

fn object_type(&self) -> TypeId

Source§

fn method_type(&self) -> TypeId

Source§

fn object_and_method_type_names(&self) -> (&'static str, &'static str)

Source§

fn invoke_special( &self, obj: Arc<dyn Object>, method: Box<dyn DynMethod>, ctx: Arc<dyn Context>, ) -> Result<BoxFuture<'static, Box<dyn Any>>, InvokeError>

Source§

impl<M, OBJ, Fut, S, E, U> Invocable for fn(Arc<OBJ>, Box<M>, Arc<dyn Context + 'static>, UpdateSink<U>) -> Fut
where M: Method, OBJ: Object, S: 'static, E: 'static, Fut: Future<Output = Result<S, E>> + Send + 'static, M::Update: From<U> + Serialize, U: 'static + Send,

Source§

fn object_type(&self) -> TypeId

Source§

fn method_type(&self) -> TypeId

Source§

fn object_and_method_type_names(&self) -> (&'static str, &'static str)

Source§

fn invoke_special( &self, obj: Arc<dyn Object>, method: Box<dyn DynMethod>, ctx: Arc<dyn Context>, ) -> Result<BoxFuture<'static, Box<dyn Any>>, InvokeError>

Implementors§