userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
stream_read_future.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <
userver/proto-structs/convert.hpp
>
7
#include <
userver/ugrpc/client/stream_read_future.hpp
>
8
9
USERVER_NAMESPACE_BEGIN
10
11
namespace
grpc_proto_structs::client {
12
14
template
<
typename
StructsResponse>
15
class
StreamReadFuture final {
16
public
:
17
using
ProtobufResponse = proto_structs::traits::CompatibleMessageType<StructsResponse>;
18
using
ProtobufStreamFuture =
ugrpc::client::StreamReadFuture<ProtobufResponse>
;
19
20
StreamReadFuture(ProtobufStreamFuture&& future, ProtobufResponse& response)
21
: future_{std::move(future)},
22
response_(response)
23
{}
24
28
[[nodiscard]]
bool
IsReady
() const noexcept {
return
future_.IsReady(); }
29
39
std::optional<StructsResponse>
Get
() {
40
if
(future_.Get()) {
41
StructsResponse response;
42
proto_structs::MessageToStruct
(response_, response);
43
return
{response};
44
}
45
return
std::nullopt;
46
}
47
48
private
:
49
ProtobufStreamFuture future_;
50
ProtobufResponse& response_;
51
};
52
53
}
// namespace grpc_proto_structs::client
54
55
USERVER_NAMESPACE_END
grpc-proto-structs
include
userver
grpc-proto-structs
client
stream_read_future.hpp
Generated on
for userver by
Doxygen
1.17.0