CodeChain-io/remote-trait-object

Consider generic instead of macro for export/import

Closed this issue · 1 comments

If then, the only drawback is that the user must type dyn Trait, instead of just Trait.

pub fn export_service_<T: ?Sized + Service + ExportService<T>>(context: &crate::context::Context, service: Arc<T>) -> HandleToExchange {
    <T as ExportService<T>>::export(context.get_port(), service)
}

pub fn import_service<T: ?Sized + Service + ImportService<T>>(context: &crate::context::Context, handle: HandleToExchange) -> Arc<T> {
    <T as ImportService<T>>::import(context.get_port(), handle)
}