starpc 0.45.0 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,312 @@
1
+ // Code generated by protoc-gen-starpc-rust. DO NOT EDIT.
2
+ // protoc-gen-starpc-rust version: v0.45.1-0.20260203090429-3e915608d4e8
3
+ // source: github.com/aperturerobotics/starpc/echo/echo.proto
4
+
5
+ #[allow(unused_imports)]
6
+ use starpc::StreamExt;
7
+
8
+ /// Service ID for Echoer.
9
+ pub const ECHOER_SERVICE_ID: &str = "echo.Echoer";
10
+
11
+ /// Stream trait for Echoer.EchoServerStream.
12
+ #[starpc::async_trait]
13
+ pub trait EchoerEchoServerStreamStream: Send + Sync {
14
+ /// Returns the context for this stream.
15
+ fn context(&self) -> &starpc::Context;
16
+ /// Receives a message from the stream.
17
+ async fn recv(&self) -> starpc::Result<EchoMsg>;
18
+ /// Closes the stream.
19
+ async fn close(&self) -> starpc::Result<()>;
20
+ }
21
+
22
+ /// Stream trait for Echoer.EchoClientStream.
23
+ #[starpc::async_trait]
24
+ pub trait EchoerEchoClientStreamStream: Send + Sync {
25
+ /// Returns the context for this stream.
26
+ fn context(&self) -> &starpc::Context;
27
+ /// Sends a message on the stream.
28
+ async fn send(&self, msg: &EchoMsg) -> starpc::Result<()>;
29
+ /// Closes the send side and receives the response.
30
+ async fn close_and_recv(&self) -> starpc::Result<EchoMsg>;
31
+ }
32
+
33
+ /// Stream trait for Echoer.EchoBidiStream.
34
+ #[starpc::async_trait]
35
+ pub trait EchoerEchoBidiStreamStream: Send + Sync {
36
+ /// Returns the context for this stream.
37
+ fn context(&self) -> &starpc::Context;
38
+ /// Sends a message on the stream.
39
+ async fn send(&self, msg: &EchoMsg) -> starpc::Result<()>;
40
+ /// Receives a message from the stream.
41
+ async fn recv(&self) -> starpc::Result<EchoMsg>;
42
+ /// Closes the stream.
43
+ async fn close(&self) -> starpc::Result<()>;
44
+ }
45
+
46
+ /// Stream trait for Echoer.RpcStream.
47
+ #[starpc::async_trait]
48
+ pub trait EchoerRpcStreamStream: Send + Sync {
49
+ /// Returns the context for this stream.
50
+ fn context(&self) -> &starpc::Context;
51
+ /// Sends a message on the stream.
52
+ async fn send(&self, msg: &RpcStreamPacket) -> starpc::Result<()>;
53
+ /// Receives a message from the stream.
54
+ async fn recv(&self) -> starpc::Result<RpcStreamPacket>;
55
+ /// Closes the stream.
56
+ async fn close(&self) -> starpc::Result<()>;
57
+ }
58
+
59
+ /// Client trait for Echoer.
60
+ #[starpc::async_trait]
61
+ pub trait EchoerClient: Send + Sync {
62
+ /// Echo.
63
+ async fn echo(&self, request: &EchoMsg) -> starpc::Result<EchoMsg>;
64
+ /// EchoServerStream.
65
+ async fn echo_server_stream(&self, request: &EchoMsg) -> starpc::Result<Box<dyn EchoerEchoServerStreamStream>>;
66
+ /// EchoClientStream.
67
+ async fn echo_client_stream(&self) -> starpc::Result<Box<dyn EchoerEchoClientStreamStream>>;
68
+ /// EchoBidiStream.
69
+ async fn echo_bidi_stream(&self) -> starpc::Result<Box<dyn EchoerEchoBidiStreamStream>>;
70
+ /// RpcStream.
71
+ async fn rpc_stream(&self) -> starpc::Result<Box<dyn EchoerRpcStreamStream>>;
72
+ /// DoNothing.
73
+ async fn do_nothing(&self, request: &Empty) -> starpc::Result<Empty>;
74
+ }
75
+
76
+ /// Client implementation for Echoer.
77
+ pub struct EchoerClientImpl<C> {
78
+ client: C,
79
+ }
80
+
81
+ impl<C: starpc::Client> EchoerClientImpl<C> {
82
+ /// Creates a new client.
83
+ pub fn new(client: C) -> Self {
84
+ Self { client }
85
+ }
86
+ }
87
+
88
+ #[starpc::async_trait]
89
+ impl<C: starpc::Client + 'static> EchoerClient for EchoerClientImpl<C> {
90
+ async fn echo(&self, request: &EchoMsg) -> starpc::Result<EchoMsg> {
91
+ self.client.exec_call("echo.Echoer", "Echo", request).await
92
+ }
93
+ async fn echo_server_stream(&self, request: &EchoMsg) -> starpc::Result<Box<dyn EchoerEchoServerStreamStream>> {
94
+ use starpc::ProstMessage;
95
+ let data = request.encode_to_vec();
96
+ let stream = self.client.new_stream("echo.Echoer", "EchoServerStream", Some(&data)).await?;
97
+ stream.close_send().await?;
98
+ Ok(Box::new(EchoerEchoServerStreamStreamImpl { stream }))
99
+ }
100
+ async fn echo_client_stream(&self) -> starpc::Result<Box<dyn EchoerEchoClientStreamStream>> {
101
+ let stream = self.client.new_stream("echo.Echoer", "EchoClientStream", None).await?;
102
+ Ok(Box::new(EchoerEchoClientStreamStreamImpl { stream }))
103
+ }
104
+ async fn echo_bidi_stream(&self) -> starpc::Result<Box<dyn EchoerEchoBidiStreamStream>> {
105
+ let stream = self.client.new_stream("echo.Echoer", "EchoBidiStream", None).await?;
106
+ Ok(Box::new(EchoerEchoBidiStreamStreamImpl { stream }))
107
+ }
108
+ async fn rpc_stream(&self) -> starpc::Result<Box<dyn EchoerRpcStreamStream>> {
109
+ let stream = self.client.new_stream("echo.Echoer", "RpcStream", None).await?;
110
+ Ok(Box::new(EchoerRpcStreamStreamImpl { stream }))
111
+ }
112
+ async fn do_nothing(&self, request: &Empty) -> starpc::Result<Empty> {
113
+ self.client.exec_call("echo.Echoer", "DoNothing", request).await
114
+ }
115
+ }
116
+
117
+ struct EchoerEchoServerStreamStreamImpl {
118
+ stream: Box<dyn starpc::Stream>,
119
+ }
120
+
121
+ #[starpc::async_trait]
122
+ impl EchoerEchoServerStreamStream for EchoerEchoServerStreamStreamImpl {
123
+ fn context(&self) -> &starpc::Context {
124
+ self.stream.context()
125
+ }
126
+ async fn recv(&self) -> starpc::Result<EchoMsg> {
127
+ self.stream.msg_recv().await
128
+ }
129
+ async fn close(&self) -> starpc::Result<()> {
130
+ self.stream.close().await
131
+ }
132
+ }
133
+
134
+ struct EchoerEchoClientStreamStreamImpl {
135
+ stream: Box<dyn starpc::Stream>,
136
+ }
137
+
138
+ #[starpc::async_trait]
139
+ impl EchoerEchoClientStreamStream for EchoerEchoClientStreamStreamImpl {
140
+ fn context(&self) -> &starpc::Context {
141
+ self.stream.context()
142
+ }
143
+ async fn send(&self, msg: &EchoMsg) -> starpc::Result<()> {
144
+ self.stream.msg_send(msg).await
145
+ }
146
+ async fn close_and_recv(&self) -> starpc::Result<EchoMsg> {
147
+ self.stream.close_send().await?;
148
+ self.stream.msg_recv().await
149
+ }
150
+ }
151
+
152
+ struct EchoerEchoBidiStreamStreamImpl {
153
+ stream: Box<dyn starpc::Stream>,
154
+ }
155
+
156
+ #[starpc::async_trait]
157
+ impl EchoerEchoBidiStreamStream for EchoerEchoBidiStreamStreamImpl {
158
+ fn context(&self) -> &starpc::Context {
159
+ self.stream.context()
160
+ }
161
+ async fn send(&self, msg: &EchoMsg) -> starpc::Result<()> {
162
+ self.stream.msg_send(msg).await
163
+ }
164
+ async fn recv(&self) -> starpc::Result<EchoMsg> {
165
+ self.stream.msg_recv().await
166
+ }
167
+ async fn close(&self) -> starpc::Result<()> {
168
+ self.stream.close().await
169
+ }
170
+ }
171
+
172
+ struct EchoerRpcStreamStreamImpl {
173
+ stream: Box<dyn starpc::Stream>,
174
+ }
175
+
176
+ #[starpc::async_trait]
177
+ impl EchoerRpcStreamStream for EchoerRpcStreamStreamImpl {
178
+ fn context(&self) -> &starpc::Context {
179
+ self.stream.context()
180
+ }
181
+ async fn send(&self, msg: &RpcStreamPacket) -> starpc::Result<()> {
182
+ self.stream.msg_send(msg).await
183
+ }
184
+ async fn recv(&self) -> starpc::Result<RpcStreamPacket> {
185
+ self.stream.msg_recv().await
186
+ }
187
+ async fn close(&self) -> starpc::Result<()> {
188
+ self.stream.close().await
189
+ }
190
+ }
191
+
192
+ /// Server trait for Echoer.
193
+ #[starpc::async_trait]
194
+ pub trait EchoerServer: Send + Sync {
195
+ /// Echo.
196
+ async fn echo(&self, request: EchoMsg) -> starpc::Result<EchoMsg>;
197
+ /// EchoServerStream.
198
+ async fn echo_server_stream(&self, request: EchoMsg, stream: Box<dyn starpc::Stream>) -> starpc::Result<()>;
199
+ /// EchoClientStream.
200
+ async fn echo_client_stream(&self, stream: &dyn starpc::Stream) -> starpc::Result<EchoMsg>;
201
+ /// EchoBidiStream.
202
+ async fn echo_bidi_stream(&self, stream: Box<dyn starpc::Stream>) -> starpc::Result<()>;
203
+ /// RpcStream.
204
+ async fn rpc_stream(&self, stream: Box<dyn starpc::Stream>) -> starpc::Result<()>;
205
+ /// DoNothing.
206
+ async fn do_nothing(&self, request: Empty) -> starpc::Result<Empty>;
207
+ }
208
+
209
+ const ECHOER_METHOD_IDS: &[&str] = &[
210
+ "Echo",
211
+ "EchoServerStream",
212
+ "EchoClientStream",
213
+ "EchoBidiStream",
214
+ "RpcStream",
215
+ "DoNothing",
216
+ ];
217
+
218
+ /// Handler for Echoer.
219
+ pub struct EchoerHandler<S: EchoerServer> {
220
+ server: std::sync::Arc<S>,
221
+ }
222
+
223
+ impl<S: EchoerServer + 'static> EchoerHandler<S> {
224
+ /// Creates a new handler wrapping the server implementation.
225
+ pub fn new(server: S) -> Self {
226
+ Self { server: std::sync::Arc::new(server) }
227
+ }
228
+
229
+ /// Creates a new handler with a shared server.
230
+ pub fn with_arc(server: std::sync::Arc<S>) -> Self {
231
+ Self { server }
232
+ }
233
+ }
234
+
235
+ #[starpc::async_trait]
236
+ impl<S: EchoerServer + 'static> starpc::Invoker for EchoerHandler<S> {
237
+ async fn invoke_method(
238
+ &self,
239
+ _service_id: &str,
240
+ method_id: &str,
241
+ stream: Box<dyn starpc::Stream>,
242
+ ) -> (bool, starpc::Result<()>) {
243
+ match method_id {
244
+ "Echo" => {
245
+ let request: EchoMsg = match stream.msg_recv().await {
246
+ Ok(r) => r,
247
+ Err(e) => return (true, Err(e)),
248
+ };
249
+ match self.server.echo(request).await {
250
+ Ok(response) => {
251
+ if let Err(e) = stream.msg_send(&response).await {
252
+ return (true, Err(e));
253
+ }
254
+ (true, Ok(()))
255
+ }
256
+ Err(e) => (true, Err(e)),
257
+ }
258
+ }
259
+ "EchoServerStream" => {
260
+ let request: EchoMsg = match stream.msg_recv().await {
261
+ Ok(r) => r,
262
+ Err(e) => return (true, Err(e)),
263
+ };
264
+ (true, self.server.echo_server_stream(request, stream).await)
265
+ }
266
+ "EchoClientStream" => {
267
+ match self.server.echo_client_stream(stream.as_ref()).await {
268
+ Ok(response) => {
269
+ if let Err(e) = stream.msg_send(&response).await {
270
+ return (true, Err(e));
271
+ }
272
+ (true, Ok(()))
273
+ }
274
+ Err(e) => (true, Err(e)),
275
+ }
276
+ }
277
+ "EchoBidiStream" => {
278
+ (true, self.server.echo_bidi_stream(stream).await)
279
+ }
280
+ "RpcStream" => {
281
+ (true, self.server.rpc_stream(stream).await)
282
+ }
283
+ "DoNothing" => {
284
+ let request: Empty = match stream.msg_recv().await {
285
+ Ok(r) => r,
286
+ Err(e) => return (true, Err(e)),
287
+ };
288
+ match self.server.do_nothing(request).await {
289
+ Ok(response) => {
290
+ if let Err(e) = stream.msg_send(&response).await {
291
+ return (true, Err(e));
292
+ }
293
+ (true, Ok(()))
294
+ }
295
+ Err(e) => (true, Err(e)),
296
+ }
297
+ }
298
+ _ => (false, Err(starpc::Error::Unimplemented)),
299
+ }
300
+ }
301
+ }
302
+
303
+ impl<S: EchoerServer + 'static> starpc::Handler for EchoerHandler<S> {
304
+ fn service_id(&self) -> &'static str {
305
+ "echo.Echoer"
306
+ }
307
+
308
+ fn method_ids(&self) -> &'static [&'static str] {
309
+ ECHOER_METHOD_IDS
310
+ }
311
+ }
312
+
package/echo/gen/mod.rs CHANGED
@@ -1,3 +1,16 @@
1
- //! Generated code - do not edit.
1
+ //! Generated code for the echo service.
2
+ //!
3
+ //! This module includes pre-generated protobuf types and service stubs.
2
4
 
3
- include!(concat!(env!("OUT_DIR"), "/echo.rs"));
5
+ // Re-export starpc's RpcStreamPacket types for use by the service stubs.
6
+ pub use starpc::rpcstream::RpcStreamPacket;
7
+
8
+ // Empty type for google.protobuf.Empty
9
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
10
+ pub struct Empty {}
11
+
12
+ // Include the generated message types.
13
+ include!("../echo.pb.rs");
14
+
15
+ // Include the generated service stubs.
16
+ include!("../echo_srpc.pb.rs");
package/echo/main.rs CHANGED
@@ -89,6 +89,15 @@ impl EchoerServer for EchoServerImpl {
89
89
 
90
90
  Ok(())
91
91
  }
92
+
93
+ async fn rpc_stream(&self, _stream: Box<dyn Stream>) -> Result<()> {
94
+ // RPC stream is not implemented in this example.
95
+ Err(Error::Unimplemented)
96
+ }
97
+
98
+ async fn do_nothing(&self, _request: gen::Empty) -> Result<gen::Empty> {
99
+ Ok(gen::Empty {})
100
+ }
92
101
  }
93
102
 
94
103
  #[tokio::main]
package/go.mod CHANGED
@@ -11,8 +11,8 @@ replace (
11
11
  )
12
12
 
13
13
  require (
14
- github.com/aperturerobotics/common v0.29.0 // latest
15
- github.com/aperturerobotics/protobuf-go-lite v0.12.0 // latest
14
+ github.com/aperturerobotics/common v0.30.1-0.20260203095300-e0754eb22a37 // latest
15
+ github.com/aperturerobotics/protobuf-go-lite v0.12.1 // latest
16
16
  github.com/aperturerobotics/util v1.32.3 // latest
17
17
  )
18
18
 
@@ -34,6 +34,7 @@ require (
34
34
  )
35
35
 
36
36
  require (
37
+ github.com/aperturerobotics/go-protoc-gen-prost v0.0.0-20260203094828-3faf47d2c868 // indirect
37
38
  github.com/ipfs/go-cid v0.4.1 // indirect
38
39
  github.com/klauspost/cpuid/v2 v2.2.8 // indirect
39
40
  github.com/libp2p/go-buffer-pool v0.1.0 // indirect
package/go.sum CHANGED
@@ -2,18 +2,20 @@ github.com/aperturerobotics/abseil-cpp v0.0.0-20260131110040-4bb56e2f9017 h1:3U7
2
2
  github.com/aperturerobotics/abseil-cpp v0.0.0-20260131110040-4bb56e2f9017/go.mod h1:lNSJTKECIUFAnfeSqy01kXYTYe1BHubW7198jNX3nEw=
3
3
  github.com/aperturerobotics/cli v1.1.0 h1:7a+YRC+EY3npAnTzhHV5gLCiw91KS0Ts3XwLILGOsT8=
4
4
  github.com/aperturerobotics/cli v1.1.0/go.mod h1:M7BFP9wow5ytTzMyJQOOO991fGfsUqdTI7gGEsHfTQ8=
5
- github.com/aperturerobotics/common v0.29.0 h1:zSRERLPqmOD0RNs0I/Jr0YVv2Top0oKoDojEdxJEu38=
6
- github.com/aperturerobotics/common v0.29.0/go.mod h1:q8ix+7nLZZ0FQ1j5w/EXI5S0FbVUX8k+eJkw83pPTT4=
5
+ github.com/aperturerobotics/common v0.30.1-0.20260203095300-e0754eb22a37 h1:ia/PiOkGovJUA2Evo3Qjn6mARVbpeACO5ENs5EKH3aQ=
6
+ github.com/aperturerobotics/common v0.30.1-0.20260203095300-e0754eb22a37/go.mod h1:o3LkfVkdyNtWz31nGkCKuMP7H2dxarmYCYgXmy1zjtg=
7
7
  github.com/aperturerobotics/go-libp2p v0.37.1-0.20241111002741-5cfbb50b74e0 h1:tGwbeDoEeQCrUQL+ClUywldqvz9eRmhcVrGwGxz2xJg=
8
8
  github.com/aperturerobotics/go-libp2p v0.37.1-0.20241111002741-5cfbb50b74e0/go.mod h1:FJkAtQcP9XxqG1NNLNHKm+wLVIGSCQX2s6CEoD+w97g=
9
+ github.com/aperturerobotics/go-protoc-gen-prost v0.0.0-20260203094828-3faf47d2c868 h1:r2j7F1tGHkchPBLL55e44g/DfYqK2JV0Ed8suMAxmlU=
10
+ github.com/aperturerobotics/go-protoc-gen-prost v0.0.0-20260203094828-3faf47d2c868/go.mod h1:OBb/beWmr/pDIZAUfi86j/4tBh2v5ctTxKMqSnh9c/4=
9
11
  github.com/aperturerobotics/go-protoc-wasi v0.0.0-20260131050911-b5f94b044584 h1:ER8DYYL71cTg39uZ+Gi699tL/hZoscUWDOw4DbizqhI=
10
12
  github.com/aperturerobotics/go-protoc-wasi v0.0.0-20260131050911-b5f94b044584/go.mod h1:vEq8i7EKb32+KXGtIEZjjhNns+BdsL2dUMw4uhy3578=
11
13
  github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20251104042408-0c9eb8a3f726 h1:4B1F0DzuqPzb6WqgCjWaqDD7JU9RDsevQG5OP0DFBgs=
12
14
  github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20251104042408-0c9eb8a3f726/go.mod h1:SvGGBv3OVxUyqO0ZxA/nvs6z3cg7NIbZ64TnbV2OISo=
13
15
  github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4 h1:4Dy3BAHh2kgVdHAqtlwcFsgY0kAwUe2m3rfFcaGwGQg=
14
16
  github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4/go.mod h1:tMgO7y6SJo/d9ZcvrpNqIQtdYT9de+QmYaHOZ4KnhOg=
15
- github.com/aperturerobotics/protobuf-go-lite v0.12.0 h1:ZPPokQtm/NPhgGv+vYD9AhInvkrzQal6MDnqcYLWvlg=
16
- github.com/aperturerobotics/protobuf-go-lite v0.12.0/go.mod h1:lGH3s5ArCTXKI4wJdlNpaybUtwSjfAG0vdWjxOfMcF8=
17
+ github.com/aperturerobotics/protobuf-go-lite v0.12.1 h1:o9of87F/LFS2p5xfq32CrU99dvfqIAalTP7ZzoZK6Kg=
18
+ github.com/aperturerobotics/protobuf-go-lite v0.12.1/go.mod h1:lGH3s5ArCTXKI4wJdlNpaybUtwSjfAG0vdWjxOfMcF8=
17
19
  github.com/aperturerobotics/util v1.32.3 h1:wBc6L2guYMgLEzFwORH3CLMoMpfEqbV6pDqYervo3S0=
18
20
  github.com/aperturerobotics/util v1.32.3/go.mod h1:qfRZZUDn0sEfc43JRA6rKP8bwFxliqGqJZX+p1jeOnQ=
19
21
  github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g=
package/mock/mock.pb.go CHANGED
@@ -1,5 +1,5 @@
1
1
  // Code generated by protoc-gen-go-lite. DO NOT EDIT.
2
- // protoc-gen-go-lite version: v0.12.0
2
+ // protoc-gen-go-lite version: v0.12.1
3
3
  // source: github.com/aperturerobotics/starpc/mock/mock.proto
4
4
 
5
5
  package e2e_mock
@@ -0,0 +1,9 @@
1
+ // @generated
2
+ // This file is @generated by prost-build.
3
+ /// MockMsg is the mock message body.
4
+ #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
5
+ pub struct MockMsg {
6
+ #[prost(string, tag="1")]
7
+ pub body: ::prost::alloc::string::String,
8
+ }
9
+ // @@protoc_insertion_point(module)
package/mock/mock.pb.ts CHANGED
@@ -1,4 +1,4 @@
1
- // @generated by protoc-gen-es-lite unknown with parameter "ts_nocheck=false,target=ts"
1
+ // @generated by protoc-gen-es-lite unknown with parameter "target=ts,ts_nocheck=false"
2
2
  // @generated from file github.com/aperturerobotics/starpc/mock/mock.proto (package e2e.mock, syntax proto3)
3
3
  /* eslint-disable */
4
4
 
@@ -1,28 +1,27 @@
1
- // go:build deps_only
1
+ //go:build deps_only
2
2
 
3
3
  // Code generated by protoc-gen-starpc-cpp. DO NOT EDIT.
4
- // protoc-gen-starpc-cpp version: v0.43.2-0.20260131104303-1de77bff6409+dirty
4
+ // protoc-gen-starpc-cpp version: v0.45.1-0.20260203090429-3e915608d4e8
5
5
  // source: github.com/aperturerobotics/starpc/mock/mock.proto
6
6
 
7
7
  #include "mock_srpc.pb.hpp"
8
8
 
9
9
  namespace e2e::mock {
10
10
 
11
- starpc::Error SRPCMockClientImpl::MockRequest(const e2e::mock::MockMsg &in,
12
- e2e::mock::MockMsg *out) {
11
+ starpc::Error SRPCMockClientImpl::MockRequest(const e2e::mock::MockMsg& in, e2e::mock::MockMsg* out) {
13
12
  return cc_->ExecCall(service_id_, "MockRequest", in, out);
14
13
  }
15
14
 
16
15
  std::vector<std::string> SRPCMockHandler::GetMethodIDs() const {
17
16
  return {
18
- "MockRequest",
17
+ "MockRequest",
19
18
  };
20
19
  }
21
20
 
22
- std::pair<bool, starpc::Error>
23
- SRPCMockHandler::InvokeMethod(const std::string &service_id,
24
- const std::string &method_id,
25
- starpc::Stream *strm) {
21
+ std::pair<bool, starpc::Error> SRPCMockHandler::InvokeMethod(
22
+ const std::string& service_id,
23
+ const std::string& method_id,
24
+ starpc::Stream* strm) {
26
25
  if (!service_id.empty() && service_id != service_id_) {
27
26
  return {false, starpc::Error::OK};
28
27
  }
@@ -30,16 +29,14 @@ SRPCMockHandler::InvokeMethod(const std::string &service_id,
30
29
  if (method_id == "MockRequest") {
31
30
  e2e::mock::MockMsg req;
32
31
  starpc::Error err = strm->MsgRecv(&req);
33
- if (err != starpc::Error::OK)
34
- return {true, err};
32
+ if (err != starpc::Error::OK) return {true, err};
35
33
  e2e::mock::MockMsg resp;
36
34
  err = impl_->MockRequest(req, &resp);
37
- if (err != starpc::Error::OK)
38
- return {true, err};
35
+ if (err != starpc::Error::OK) return {true, err};
39
36
  return {true, strm->MsgSend(resp)};
40
37
  }
41
38
 
42
39
  return {false, starpc::Error::OK};
43
40
  }
44
41
 
45
- } // namespace e2e::mock
42
+ } // namespace e2e::mock
@@ -1,5 +1,5 @@
1
1
  // Code generated by protoc-gen-srpc. DO NOT EDIT.
2
- // protoc-gen-srpc version: v0.42.0
2
+ // protoc-gen-srpc version: v0.45.1-0.20260203090429-3e915608d4e8
3
3
  // source: github.com/aperturerobotics/starpc/mock/mock.proto
4
4
 
5
5
  package e2e_mock
@@ -1,5 +1,7 @@
1
+ //go:build deps_only && cgo
2
+
1
3
  // Code generated by protoc-gen-starpc-cpp. DO NOT EDIT.
2
- // protoc-gen-starpc-cpp version: v0.43.2-0.20260131104303-1de77bff6409+dirty
4
+ // protoc-gen-starpc-cpp version: v0.45.1-0.20260203090429-3e915608d4e8
3
5
  // source: github.com/aperturerobotics/starpc/mock/mock.proto
4
6
 
5
7
  #pragma once
@@ -16,83 +18,77 @@
16
18
  namespace e2e::mock {
17
19
 
18
20
  // Service ID for Mock
19
- constexpr const char *kSRPCMockServiceID = "e2e.mock.Mock";
21
+ constexpr const char* kSRPCMockServiceID = "e2e.mock.Mock";
22
+
20
23
 
21
24
  // SRPCMockClient is the client API for Mock service.
22
25
  class SRPCMockClient {
23
- public:
26
+ public:
24
27
  virtual ~SRPCMockClient() = default;
25
28
 
26
29
  // SRPCClient returns the underlying SRPC client.
27
- virtual starpc::Client *SRPCClient() = 0;
30
+ virtual starpc::Client* SRPCClient() = 0;
28
31
 
29
32
  // MockRequest
30
- virtual starpc::Error MockRequest(const e2e::mock::MockMsg &in,
31
- e2e::mock::MockMsg *out) = 0;
33
+ virtual starpc::Error MockRequest(const e2e::mock::MockMsg& in, e2e::mock::MockMsg* out) = 0;
32
34
  };
33
35
 
34
36
  // SRPCMockClientImpl implements SRPCMockClient.
35
37
  class SRPCMockClientImpl : public SRPCMockClient {
36
- public:
37
- explicit SRPCMockClientImpl(starpc::Client *cc,
38
- const std::string &service_id = "")
39
- : cc_(cc),
40
- service_id_(service_id.empty() ? kSRPCMockServiceID : service_id) {}
38
+ public:
39
+ explicit SRPCMockClientImpl(starpc::Client* cc, const std::string& service_id = "")
40
+ : cc_(cc), service_id_(service_id.empty() ? kSRPCMockServiceID : service_id) {}
41
41
 
42
- starpc::Client *SRPCClient() override { return cc_; }
42
+ starpc::Client* SRPCClient() override { return cc_; }
43
43
 
44
44
  // MockRequest
45
- virtual starpc::Error MockRequest(const e2e::mock::MockMsg &in,
46
- e2e::mock::MockMsg *out) override;
45
+ virtual starpc::Error MockRequest(const e2e::mock::MockMsg& in, e2e::mock::MockMsg* out) override;
47
46
 
48
- private:
49
- starpc::Client *cc_;
47
+ private:
48
+ starpc::Client* cc_;
50
49
  std::string service_id_;
51
50
  };
52
51
 
53
52
  // NewSRPCMockClient creates a new client.
54
- inline std::unique_ptr<SRPCMockClient> NewSRPCMockClient(starpc::Client *cc) {
53
+ inline std::unique_ptr<SRPCMockClient> NewSRPCMockClient(starpc::Client* cc) {
55
54
  return std::make_unique<SRPCMockClientImpl>(cc);
56
55
  }
57
56
 
58
57
  // SRPCMockServer is the server API for Mock service.
59
58
  class SRPCMockServer {
60
- public:
59
+ public:
61
60
  virtual ~SRPCMockServer() = default;
62
61
 
63
62
  // MockRequest
64
- virtual starpc::Error MockRequest(const e2e::mock::MockMsg &req,
65
- e2e::mock::MockMsg *resp) = 0;
63
+ virtual starpc::Error MockRequest(const e2e::mock::MockMsg& req, e2e::mock::MockMsg* resp) = 0;
66
64
  };
67
65
 
68
66
  // SRPCMockHandler implements starpc::Handler for Mock.
69
67
  class SRPCMockHandler : public starpc::Handler {
70
- public:
71
- SRPCMockHandler(SRPCMockServer *impl, const std::string &service_id = "")
72
- : impl_(impl),
73
- service_id_(service_id.empty() ? kSRPCMockServiceID : service_id) {}
68
+ public:
69
+ SRPCMockHandler(SRPCMockServer* impl, const std::string& service_id = "")
70
+ : impl_(impl), service_id_(service_id.empty() ? kSRPCMockServiceID : service_id) {}
74
71
 
75
- const std::string &GetServiceID() const override { return service_id_; }
72
+ const std::string& GetServiceID() const override { return service_id_; }
76
73
  std::vector<std::string> GetMethodIDs() const override;
77
- std::pair<bool, starpc::Error> InvokeMethod(const std::string &service_id,
78
- const std::string &method_id,
79
- starpc::Stream *strm) override;
74
+ std::pair<bool, starpc::Error> InvokeMethod(
75
+ const std::string& service_id,
76
+ const std::string& method_id,
77
+ starpc::Stream* strm) override;
80
78
 
81
- private:
82
- SRPCMockServer *impl_;
79
+ private:
80
+ SRPCMockServer* impl_;
83
81
  std::string service_id_;
84
82
  };
85
83
 
86
84
  // NewSRPCMockHandler creates a new handler for the given implementation.
87
- inline std::unique_ptr<SRPCMockHandler>
88
- NewSRPCMockHandler(SRPCMockServer *impl) {
85
+ inline std::unique_ptr<SRPCMockHandler> NewSRPCMockHandler(SRPCMockServer* impl) {
89
86
  return std::make_unique<SRPCMockHandler>(impl);
90
87
  }
91
88
 
92
89
  // SRPCRegisterMock registers the server implementation with the mux.
93
90
  // The returned handler must outlive the mux registration.
94
- inline std::pair<std::unique_ptr<SRPCMockHandler>, starpc::Error>
95
- SRPCRegisterMock(starpc::Mux *mux, SRPCMockServer *impl) {
91
+ inline std::pair<std::unique_ptr<SRPCMockHandler>, starpc::Error> SRPCRegisterMock(starpc::Mux* mux, SRPCMockServer* impl) {
96
92
  auto handler = NewSRPCMockHandler(impl);
97
93
  starpc::Error err = mux->Register(handler.get());
98
94
  if (err != starpc::Error::OK) {
@@ -101,4 +97,4 @@ SRPCRegisterMock(starpc::Mux *mux, SRPCMockServer *impl) {
101
97
  return {std::move(handler), starpc::Error::OK};
102
98
  }
103
99
 
104
- } // namespace e2e::mock
100
+ } // namespace e2e::mock