I'm looking at a solution to 'embedding' python and javascript into a Rust application through RPC, my basic schema looks something like:
@0xc01ea2259855b1a4;
interface Executor {
ping @0 () -> (result :Bool);
getFunction @1 [I, O] (hashId :FunctionDescriptor) -> (fn :Function(I, O));
}
struct FunctionDescriptor {
id @0 :Text;
hash @1 :Data;
lang @2 :Language;
}
enum Language {
python @0;
javascript @1;
}
interface Function(I, O) {
call @0 (input :I) -> (output :O);
}
The compiler will happily generate rust code for me; although it seems to me I need to somehow constrain the generic I and O. In my model, a Rust client will call a Python Executor, attempt to acquire a concrete function, which might fail if the python server cannot provide that specific concrete implementation.
Should I use generics in this way; or use AnyPointers?