-
Notifications
You must be signed in to change notification settings - Fork 1
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
Support Stream #40
Comments
Related: hyperium/tonic#804 This PR in tonic remove
Why not add Send constraint to I know that the the type should be => I understood. |
So the generated function from |
Code from Tonic. I think rpc like (stream X, A) -> (stream Y, B) isn't permitted. let method = match (method.client_streaming(), method.server_streaming()) {
(false, false) => {
quote! {
#method_doc
async fn #name(&self, request: tonic::Request<#req_message>)
-> Result<tonic::Response<#res_message>, tonic::Status>;
}
}
(true, false) => {
quote! {
#method_doc
async fn #name(&self, request: tonic::Request<tonic::Streaming<#req_message>>)
-> Result<tonic::Response<#res_message>, tonic::Status>;
}
}
(false, true) => {
let stream = quote::format_ident!("{}Stream", method.identifier());
let stream_doc = generate_doc_comment(&format!(
"Server streaming response type for the {} method.",
method.identifier()
));
quote! {
#stream_doc
type #stream: futures_core::Stream<Item = Result<#res_message, tonic::Status>> + Send + 'static;
#method_doc
async fn #name(&self, request: tonic::Request<#req_message>)
-> Result<tonic::Response<Self::#stream>, tonic::Status>;
}
}
(true, true) => {
let stream = quote::format_ident!("{}Stream", method.identifier());
let stream_doc = generate_doc_comment(&format!(
"Server streaming response type for the {} method.",
method.identifier()
));
quote! {
#stream_doc
type #stream: futures_core::Stream<Item = Result<#res_message, tonic::Status>> + Send + 'static;
#method_doc
async fn #name(&self, request: tonic::Request<tonic::Streaming<#req_message>>)
-> Result<tonic::Response<Self::#stream>, tonic::Status>;
}
} Only these four pairs are allowed.
|
So the possible syntax would be
|
done. |
yields
fn message_stream(self) -> Pin<Box<dyn futures::stream::Stream<Item = Elem>;
?I don't know. Need some experiments.
The text was updated successfully, but these errors were encountered: