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

RpcServiceT: remove associated type Future and replace with impl future #1289

Open
Tracked by #1292
niklasad1 opened this issue Feb 10, 2024 · 0 comments
Open
Tracked by #1292

Comments

@niklasad1
Copy link
Member

niklasad1 commented Feb 10, 2024

Currently the RpcServiceT is very similar to the tower::Service

pub trait RpcServiceT<'a> {
	/// The future response value.
	type Future: Future<Output = MethodResponse> + Send;

	/// Process a single JSON-RPC call it may be a subscription or regular call.
	/// In this interface they are treated in the same way but it's possible to
	/// distinguish those based on the `MethodResponse`.
	fn call(&self, request: Request<'a>) -> Self::Future;

and it should be modified to

pub trait RpcServiceT<'a> {
	/// Process a single JSON-RPC call it may be a subscription or regular call.
	/// In this interface they are treated in the same way but it's possible to
	/// distinguish those based on the `MethodResponse`.
	fn call(&self, request: Request<'a>) -> impl Future<Output = MethodResponse> + Send;
}

The reason is that in many cases the current design ends up with that the Future needs to be Boxed
or a complicated ResponseFuture has to be written. With impl Future is much more flexible and would improve things.

The only reason why we haven't changed this is because changing this ends up with rustc generic lifetime error, rust-lang/rust#100013

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

1 participant