1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use std::any::{Any, TypeId};

pub struct InvocationInfo<'a> {
    pub func_name: &'a str,
    pub arg_names: &'a[&'a str],
    pub arg_values: &'a [Box<dyn Any>],
    pub return_type: TypeId,
    pub return_value: Option<Box<dyn Any>>
}

pub trait DynamicProxy {
    fn call(&self, invocation: &mut InvocationInfo);
}

impl<'a> InvocationInfo<'a> {
    pub fn set_return_value<T: 'static>(&mut self, val: T) {
        let result: Box<dyn Any> = Box::new(val);
        self.return_value = Some(result);
    }
}