Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic type parameters #412

Closed
jimouris opened this issue Dec 8, 2023 · 4 comments
Closed

Generic type parameters #412

jimouris opened this issue Dec 8, 2023 · 4 comments

Comments

@jimouris
Copy link

jimouris commented Dec 8, 2023

Can I have a generic type as a parameter to the service?

#[tarpc::service]
trait Service<T> {

async fn hello(name: T) -> String;
}

or maybe as

#[tarpc::service]
trait Service {

async fn hello<T>(name: T) -> String;
}

?

Thanks

@jimouris jimouris changed the title Generic type parameters" Generic type parameters Dec 8, 2023
@tikue
Copy link
Collaborator

tikue commented Dec 8, 2023

Unfortunately no :( I haven't made any progress on this since filing #257.

@jimouris
Copy link
Author

jimouris commented Dec 8, 2023

Oh, no problem, thank you for your quick response! I also see that defining custom types inside the trait is not allowed. Is there any way around that or is it just a blocker for now?

@jimouris
Copy link
Author

jimouris commented Dec 8, 2023

Also, please feel free to close this issue since it's a duplicate of #257.

@tikue
Copy link
Collaborator

tikue commented Dec 8, 2023

Oh, no problem, thank you for your quick response! I also see that defining custom types inside the trait is not allowed. Is there any way around that or is it just a blocker for now?

I think it's essentially a blocker. RPC services can't be generic over types at all, whether that's a type parameter on the trait or an associated type in the trait.

Closing in favor of #257 but feel free to comment more there!

@tikue tikue closed this as completed Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants