starpc 0.42.0 → 0.43.1

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.
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # starpc
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/starpc?style=flat-square)](https://www.npmjs.com/package/starpc)
4
+ [![crates.io](https://img.shields.io/crates/v/starpc.svg?style=flat-square)](https://crates.io/crates/starpc)
4
5
  [![Build status](https://img.shields.io/github/actions/workflow/status/aperturerobotics/starpc/tests.yml?style=flat-square&branch=master)](https://github.com/aperturerobotics/starpc/actions)
5
6
  [![GoDoc Widget]][GoDoc] [![Go Report Card Widget]][Go Report Card]
6
7
 
@@ -14,32 +15,43 @@
14
15
  ## Table of Contents
15
16
 
16
17
  - [Features](#features)
18
+ - [Documentation](#documentation)
17
19
  - [Installation](#installation)
18
20
  - [Quick Start](#quick-start)
19
21
  - [Examples](#examples)
20
22
  - [Protobuf Definition](#protobuf)
21
23
  - [Go Implementation](#go)
22
24
  - [TypeScript Implementation](#typescript)
25
+ - [Rust Implementation](#rust)
23
26
  - [Debugging](#debugging)
24
27
  - [Development Setup](#development-setup)
25
28
  - [Support](#support)
26
29
 
27
30
  ## Features
28
31
 
29
- - Full [Proto3 services] support for TypeScript and Go
32
+ - Full [Proto3 services] support for TypeScript, Go, and Rust
30
33
  - Bidirectional streaming in browsers via WebSocket or WebRTC
31
34
  - Built on libp2p streams with [@chainsafe/libp2p-yamux]
32
35
  - Efficient multiplexing of RPCs over single connections
33
36
  - Zero-reflection Go via [protobuf-go-lite]
34
37
  - Lightweight TypeScript via [protobuf-es-lite]
38
+ - Async Rust via [prost] and [tokio]
35
39
  - Sub-stream support via [rpcstream]
36
40
 
37
41
  [Proto3 services]: https://developers.google.com/protocol-buffers/docs/proto3#services
38
42
  [@chainsafe/libp2p-yamux]: https://github.com/ChainSafe/js-libp2p-yamux
39
43
  [protobuf-go-lite]: https://github.com/aperturerobotics/protobuf-go-lite
40
44
  [protobuf-es-lite]: https://github.com/aperturerobotics/protobuf-es-lite
45
+ [prost]: https://github.com/tokio-rs/prost
46
+ [tokio]: https://github.com/tokio-rs/tokio
41
47
  [rpcstream]: ./rpcstream
42
48
 
49
+ ## Documentation
50
+
51
+ - [Getting Started with TypeScript](./GET_STARTED_TYPESCRIPT.md)
52
+ - [Getting Started with Go](./GET_STARTED_GO.md)
53
+ - [Getting Started with Rust](./GET_STARTED_RUST.md)
54
+
43
55
  ## Installation
44
56
 
45
57
  ```bash
@@ -47,11 +59,10 @@
47
59
  git clone -b starpc https://github.com/aperturerobotics/protobuf-project
48
60
  cd protobuf-project
49
61
 
50
- # Install dependencies
62
+ # Install dependencies (any of these work)
63
+ bun install
51
64
  npm install
52
- yarn install
53
65
  pnpm install
54
- bun install
55
66
 
56
67
  # Generate TypeScript and Go code
57
68
  bun run gen
@@ -134,6 +145,84 @@ For TypeScript <-> TypeScript, see the [e2e] test.
134
145
  [e2e]: ./e2e/e2e.ts
135
146
  [integration]: ./integration/integration.ts
136
147
 
148
+ ### Rust
149
+
150
+ Add the dependencies to your `Cargo.toml`:
151
+
152
+ ```toml
153
+ [dependencies]
154
+ starpc = "0.1"
155
+ prost = "0.13"
156
+ tokio = { version = "1", features = ["rt", "macros"] }
157
+
158
+ [build-dependencies]
159
+ starpc-build = "0.1"
160
+ prost-build = "0.13"
161
+ ```
162
+
163
+ Create a `build.rs` to generate code from your proto files:
164
+
165
+ ```rust
166
+ fn main() -> Result<(), Box<dyn std::error::Error>> {
167
+ starpc_build::configure()
168
+ .compile_protos(&["proto/echo.proto"], &["proto"])?;
169
+ Ok(())
170
+ }
171
+ ```
172
+
173
+ Implement and use your service:
174
+
175
+ ```rust
176
+ use starpc::{Client, Mux, Server, SrpcClient};
177
+ use std::sync::Arc;
178
+
179
+ // Include generated code
180
+ mod proto {
181
+ include!(concat!(env!("OUT_DIR"), "/echo.rs"));
182
+ }
183
+
184
+ use proto::*;
185
+
186
+ // Implement the server trait
187
+ struct EchoServer;
188
+
189
+ #[starpc::async_trait]
190
+ impl EchoerServer for EchoServer {
191
+ async fn echo(&self, request: EchoMsg) -> starpc::Result<EchoMsg> {
192
+ Ok(request) // Echo back the message
193
+ }
194
+ }
195
+
196
+ #[tokio::main]
197
+ async fn main() -> Result<(), Box<dyn std::error::Error>> {
198
+ // Create server
199
+ let mux = Arc::new(Mux::new());
200
+ mux.register(Arc::new(EchoerHandler::new(EchoServer)))?;
201
+ let server = Server::with_arc(mux);
202
+
203
+ // Create an in-memory connection for demonstration
204
+ let (client_stream, server_stream) = tokio::io::duplex(64 * 1024);
205
+
206
+ // Spawn server handler
207
+ tokio::spawn(async move {
208
+ let _ = server.handle_stream(server_stream).await;
209
+ });
210
+
211
+ // Create client
212
+ let opener = starpc::client::transport::SingleStreamOpener::new(client_stream);
213
+ let client = SrpcClient::new(opener);
214
+ let echoer = EchoerClientImpl::new(client);
215
+
216
+ // Make RPC call
217
+ let response = echoer.echo(&EchoMsg { body: "Hello!".into() }).await?;
218
+ println!("Response: {}", response.body);
219
+
220
+ Ok(())
221
+ }
222
+ ```
223
+
224
+ See the [echo example](./echo/main.rs) for a complete working example.
225
+
137
226
  #### WebSocket Example
138
227
 
139
228
  Connect to a WebSocket server:
@@ -226,21 +315,8 @@ Uses [protobuf-es-lite] (fork of [protobuf-es]) for TypeScript.
226
315
 
227
316
  ### MacOS
228
317
 
229
- Install required packages:
230
-
231
- ```bash
232
- brew install bash make coreutils gnu-sed findutils protobuf
233
- brew link --overwrite protobuf
234
- ```
235
-
236
- Add to your shell rc file (.bashrc, .zshrc):
237
-
238
- ```bash
239
- export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
240
- export PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:$PATH"
241
- export PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH"
242
- export PATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH"
243
- ```
318
+ The `aptre` CLI handles all protobuf generation without requiring additional
319
+ homebrew packages. Just run `bun run gen` after installing bun.
244
320
 
245
321
  ## Support
246
322
 
@@ -1,4 +1,4 @@
1
- import type { MessageType } from "@aptre/protobuf-es-lite";
1
+ import type { MessageType } from '@aptre/protobuf-es-lite';
2
2
  export declare const protobufPackage = "e2e.mock";
3
3
  /**
4
4
  * MockMsg is the mock message body.
@@ -1,14 +1,13 @@
1
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
- import { createMessageType, ScalarType } from "@aptre/protobuf-es-lite";
5
- export const protobufPackage = "e2e.mock";
6
- ;
4
+ import { createMessageType, ScalarType } from '@aptre/protobuf-es-lite';
5
+ export const protobufPackage = 'e2e.mock';
7
6
  // MockMsg contains the message type declaration for MockMsg.
8
7
  export const MockMsg = createMessageType({
9
- typeName: "e2e.mock.MockMsg",
8
+ typeName: 'e2e.mock.MockMsg',
10
9
  fields: [
11
- { no: 1, name: "body", kind: "scalar", T: ScalarType.STRING },
10
+ { no: 1, name: 'body', kind: 'scalar', T: ScalarType.STRING },
12
11
  ],
13
12
  packedByDefault: true,
14
13
  });
@@ -1,6 +1,6 @@
1
- import { MockMsg } from "./mock.pb.js";
2
- import { MethodKind } from "@aptre/protobuf-es-lite";
3
- import { ProtoRpc } from "starpc";
1
+ import { MockMsg } from './mock.pb.js';
2
+ import { MethodKind } from '@aptre/protobuf-es-lite';
3
+ import { ProtoRpc } from 'starpc';
4
4
  /**
5
5
  * Mock service mocks some RPCs for the e2e tests.
6
6
  *
@@ -1,15 +1,15 @@
1
1
  // @generated by protoc-gen-es-starpc none 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
- import { MockMsg } from "./mock.pb.js";
5
- import { MethodKind } from "@aptre/protobuf-es-lite";
4
+ import { MockMsg } from './mock.pb.js';
5
+ import { MethodKind } from '@aptre/protobuf-es-lite';
6
6
  /**
7
7
  * Mock service mocks some RPCs for the e2e tests.
8
8
  *
9
9
  * @generated from service e2e.mock.Mock
10
10
  */
11
11
  export const MockDefinition = {
12
- typeName: "e2e.mock.Mock",
12
+ typeName: 'e2e.mock.Mock',
13
13
  methods: {
14
14
  /**
15
15
  * MockRequest runs a mock unary request.
@@ -17,12 +17,12 @@ export const MockDefinition = {
17
17
  * @generated from rpc e2e.mock.Mock.MockRequest
18
18
  */
19
19
  MockRequest: {
20
- name: "MockRequest",
20
+ name: 'MockRequest',
21
21
  I: MockMsg,
22
22
  O: MockMsg,
23
23
  kind: MethodKind.Unary,
24
24
  },
25
- }
25
+ },
26
26
  };
27
27
  export const MockServiceName = MockDefinition.typeName;
28
28
  export class MockClient {
@@ -0,0 +1,21 @@
1
+ [package]
2
+ name = "echo-example"
3
+ version.workspace = true
4
+ edition.workspace = true
5
+ rust-version.workspace = true
6
+ license.workspace = true
7
+ publish = false
8
+
9
+ [[bin]]
10
+ name = "echo-example"
11
+ path = "main.rs"
12
+
13
+ [dependencies]
14
+ starpc = { workspace = true }
15
+ prost = { workspace = true }
16
+ tokio = { version = "1", features = ["full"] }
17
+ async-trait = { workspace = true }
18
+
19
+ [build-dependencies]
20
+ starpc-build = { workspace = true }
21
+ prost-build = { workspace = true }
package/echo/build.rs ADDED
@@ -0,0 +1,15 @@
1
+ use std::io::Result;
2
+ use std::path::PathBuf;
3
+
4
+ fn main() -> Result<()> {
5
+ let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
6
+ // Use simplified proto without rpcstream dependency
7
+ let proto_path = manifest_dir.join("echo_rust.proto");
8
+
9
+ println!("cargo:rerun-if-changed={}", proto_path.display());
10
+
11
+ starpc_build::configure()
12
+ .compile_protos(&[proto_path], &[&manifest_dir])?;
13
+
14
+ Ok(())
15
+ }
@@ -0,0 +1,405 @@
1
+ //go:build deps_only && cgo
2
+
3
+ // Generated by the protocol buffer compiler. DO NOT EDIT!
4
+ // NO CHECKED-IN PROTOBUF GENCODE
5
+ // source: github.com/aperturerobotics/starpc/echo/echo.proto
6
+ // Protobuf C++ Version: 6.33.4
7
+
8
+ #include "echo.pb.h"
9
+
10
+ #include <algorithm>
11
+ #include <type_traits>
12
+ #include "google/protobuf/io/coded_stream.h"
13
+ #include "google/protobuf/generated_message_tctable_impl.h"
14
+ #include "google/protobuf/extension_set.h"
15
+ #include "google/protobuf/generated_message_util.h"
16
+ #include "google/protobuf/wire_format_lite.h"
17
+ #include "google/protobuf/descriptor.h"
18
+ #include "google/protobuf/generated_message_reflection.h"
19
+ #include "google/protobuf/reflection_ops.h"
20
+ #include "google/protobuf/wire_format.h"
21
+ // @@protoc_insertion_point(includes)
22
+
23
+ // Must be included last.
24
+ #include "google/protobuf/port_def.inc"
25
+ PROTOBUF_PRAGMA_INIT_SEG
26
+ namespace _pb = ::google::protobuf;
27
+ namespace _pbi = ::google::protobuf::internal;
28
+ namespace _fl = ::google::protobuf::internal::field_layout;
29
+ namespace echo {
30
+
31
+ inline constexpr EchoMsg::Impl_::Impl_(
32
+ ::_pbi::ConstantInitialized) noexcept
33
+ : _cached_size_{0},
34
+ body_(
35
+ &::google::protobuf::internal::fixed_address_empty_string,
36
+ ::_pbi::ConstantInitialized()) {}
37
+
38
+ template <typename>
39
+ PROTOBUF_CONSTEXPR EchoMsg::EchoMsg(::_pbi::ConstantInitialized)
40
+ #if defined(PROTOBUF_CUSTOM_VTABLE)
41
+ : ::google::protobuf::Message(EchoMsg_class_data_.base()),
42
+ #else // PROTOBUF_CUSTOM_VTABLE
43
+ : ::google::protobuf::Message(),
44
+ #endif // PROTOBUF_CUSTOM_VTABLE
45
+ _impl_(::_pbi::ConstantInitialized()) {
46
+ }
47
+ struct EchoMsgDefaultTypeInternal {
48
+ PROTOBUF_CONSTEXPR EchoMsgDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {}
49
+ ~EchoMsgDefaultTypeInternal() {}
50
+ union {
51
+ EchoMsg _instance;
52
+ };
53
+ };
54
+
55
+ PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT
56
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EchoMsgDefaultTypeInternal _EchoMsg_default_instance_;
57
+ } // namespace echo
58
+ static constexpr const ::_pb::EnumDescriptor* PROTOBUF_NONNULL* PROTOBUF_NULLABLE
59
+ file_level_enum_descriptors_github_2ecom_2faperturerobotics_2fstarpc_2fecho_2fecho_2eproto = nullptr;
60
+ static constexpr const ::_pb::ServiceDescriptor* PROTOBUF_NONNULL* PROTOBUF_NULLABLE
61
+ file_level_service_descriptors_github_2ecom_2faperturerobotics_2fstarpc_2fecho_2fecho_2eproto = nullptr;
62
+ const ::uint32_t
63
+ TableStruct_github_2ecom_2faperturerobotics_2fstarpc_2fecho_2fecho_2eproto::offsets[] ABSL_ATTRIBUTE_SECTION_VARIABLE(
64
+ protodesc_cold) = {
65
+ 0x081, // bitmap
66
+ PROTOBUF_FIELD_OFFSET(::echo::EchoMsg, _impl_._has_bits_),
67
+ 4, // hasbit index offset
68
+ PROTOBUF_FIELD_OFFSET(::echo::EchoMsg, _impl_.body_),
69
+ 0,
70
+ };
71
+
72
+ static const ::_pbi::MigrationSchema
73
+ schemas[] ABSL_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
74
+ {0, sizeof(::echo::EchoMsg)},
75
+ };
76
+ static const ::_pb::Message* PROTOBUF_NONNULL const file_default_instances[] = {
77
+ &::echo::_EchoMsg_default_instance_._instance,
78
+ };
79
+ const char descriptor_table_protodef_github_2ecom_2faperturerobotics_2fstarpc_2fecho_2fecho_2eproto[] ABSL_ATTRIBUTE_SECTION_VARIABLE(
80
+ protodesc_cold) = {
81
+ "\n2github.com/aperturerobotics/starpc/ech"
82
+ "o/echo.proto\022\004echo\032<github.com/aperturer"
83
+ "obotics/starpc/rpcstream/rpcstream.proto"
84
+ "\032\033google/protobuf/empty.proto\"\027\n\007EchoMsg"
85
+ "\022\014\n\004body\030\001 \001(\t2\320\002\n\006Echoer\022$\n\004Echo\022\r.echo"
86
+ ".EchoMsg\032\r.echo.EchoMsg\0222\n\020EchoServerStr"
87
+ "eam\022\r.echo.EchoMsg\032\r.echo.EchoMsg0\001\0222\n\020E"
88
+ "choClientStream\022\r.echo.EchoMsg\032\r.echo.Ec"
89
+ "hoMsg(\001\0222\n\016EchoBidiStream\022\r.echo.EchoMsg"
90
+ "\032\r.echo.EchoMsg(\0010\001\022G\n\tRpcStream\022\032.rpcst"
91
+ "ream.RpcStreamPacket\032\032.rpcstream.RpcStre"
92
+ "amPacket(\0010\001\022;\n\tDoNothing\022\026.google.proto"
93
+ "buf.Empty\032\026.google.protobuf.Emptyb\006proto"
94
+ "3"
95
+ };
96
+ static const ::_pbi::DescriptorTable* PROTOBUF_NONNULL const
97
+ descriptor_table_github_2ecom_2faperturerobotics_2fstarpc_2fecho_2fecho_2eproto_deps[2] = {
98
+ &::descriptor_table_github_2ecom_2faperturerobotics_2fstarpc_2frpcstream_2frpcstream_2eproto,
99
+ &::descriptor_table_google_2fprotobuf_2fempty_2eproto,
100
+ };
101
+ static ::absl::once_flag descriptor_table_github_2ecom_2faperturerobotics_2fstarpc_2fecho_2fecho_2eproto_once;
102
+ PROTOBUF_CONSTINIT const ::_pbi::DescriptorTable descriptor_table_github_2ecom_2faperturerobotics_2fstarpc_2fecho_2fecho_2eproto = {
103
+ false,
104
+ false,
105
+ 521,
106
+ descriptor_table_protodef_github_2ecom_2faperturerobotics_2fstarpc_2fecho_2fecho_2eproto,
107
+ "github.com/aperturerobotics/starpc/echo/echo.proto",
108
+ &descriptor_table_github_2ecom_2faperturerobotics_2fstarpc_2fecho_2fecho_2eproto_once,
109
+ descriptor_table_github_2ecom_2faperturerobotics_2fstarpc_2fecho_2fecho_2eproto_deps,
110
+ 2,
111
+ 1,
112
+ schemas,
113
+ file_default_instances,
114
+ TableStruct_github_2ecom_2faperturerobotics_2fstarpc_2fecho_2fecho_2eproto::offsets,
115
+ file_level_enum_descriptors_github_2ecom_2faperturerobotics_2fstarpc_2fecho_2fecho_2eproto,
116
+ file_level_service_descriptors_github_2ecom_2faperturerobotics_2fstarpc_2fecho_2fecho_2eproto,
117
+ };
118
+ namespace echo {
119
+ // ===================================================================
120
+
121
+ class EchoMsg::_Internal {
122
+ public:
123
+ using HasBits =
124
+ decltype(::std::declval<EchoMsg>()._impl_._has_bits_);
125
+ static constexpr ::int32_t kHasBitsOffset =
126
+ 8 * PROTOBUF_FIELD_OFFSET(EchoMsg, _impl_._has_bits_);
127
+ };
128
+
129
+ EchoMsg::EchoMsg(::google::protobuf::Arena* PROTOBUF_NULLABLE arena)
130
+ #if defined(PROTOBUF_CUSTOM_VTABLE)
131
+ : ::google::protobuf::Message(arena, EchoMsg_class_data_.base()) {
132
+ #else // PROTOBUF_CUSTOM_VTABLE
133
+ : ::google::protobuf::Message(arena) {
134
+ #endif // PROTOBUF_CUSTOM_VTABLE
135
+ SharedCtor(arena);
136
+ // @@protoc_insertion_point(arena_constructor:echo.EchoMsg)
137
+ }
138
+ PROTOBUF_NDEBUG_INLINE EchoMsg::Impl_::Impl_(
139
+ [[maybe_unused]] ::google::protobuf::internal::InternalVisibility visibility,
140
+ [[maybe_unused]] ::google::protobuf::Arena* PROTOBUF_NULLABLE arena, const Impl_& from,
141
+ [[maybe_unused]] const ::echo::EchoMsg& from_msg)
142
+ : _has_bits_{from._has_bits_},
143
+ _cached_size_{0},
144
+ body_(arena, from.body_) {}
145
+
146
+ EchoMsg::EchoMsg(
147
+ ::google::protobuf::Arena* PROTOBUF_NULLABLE arena,
148
+ const EchoMsg& from)
149
+ #if defined(PROTOBUF_CUSTOM_VTABLE)
150
+ : ::google::protobuf::Message(arena, EchoMsg_class_data_.base()) {
151
+ #else // PROTOBUF_CUSTOM_VTABLE
152
+ : ::google::protobuf::Message(arena) {
153
+ #endif // PROTOBUF_CUSTOM_VTABLE
154
+ EchoMsg* const _this = this;
155
+ (void)_this;
156
+ _internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(
157
+ from._internal_metadata_);
158
+ new (&_impl_) Impl_(internal_visibility(), arena, from._impl_, from);
159
+
160
+ // @@protoc_insertion_point(copy_constructor:echo.EchoMsg)
161
+ }
162
+ PROTOBUF_NDEBUG_INLINE EchoMsg::Impl_::Impl_(
163
+ [[maybe_unused]] ::google::protobuf::internal::InternalVisibility visibility,
164
+ [[maybe_unused]] ::google::protobuf::Arena* PROTOBUF_NULLABLE arena)
165
+ : _cached_size_{0},
166
+ body_(arena) {}
167
+
168
+ inline void EchoMsg::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) {
169
+ new (&_impl_) Impl_(internal_visibility(), arena);
170
+ }
171
+ EchoMsg::~EchoMsg() {
172
+ // @@protoc_insertion_point(destructor:echo.EchoMsg)
173
+ SharedDtor(*this);
174
+ }
175
+ inline void EchoMsg::SharedDtor(MessageLite& self) {
176
+ EchoMsg& this_ = static_cast<EchoMsg&>(self);
177
+ if constexpr (::_pbi::DebugHardenCheckHasBitConsistency()) {
178
+ this_.CheckHasBitConsistency();
179
+ }
180
+ this_._internal_metadata_.Delete<::google::protobuf::UnknownFieldSet>();
181
+ ABSL_DCHECK(this_.GetArena() == nullptr);
182
+ this_._impl_.body_.Destroy();
183
+ this_._impl_.~Impl_();
184
+ }
185
+
186
+ inline void* PROTOBUF_NONNULL EchoMsg::PlacementNew_(
187
+ const void* PROTOBUF_NONNULL, void* PROTOBUF_NONNULL mem,
188
+ ::google::protobuf::Arena* PROTOBUF_NULLABLE arena) {
189
+ return ::new (mem) EchoMsg(arena);
190
+ }
191
+ constexpr auto EchoMsg::InternalNewImpl_() {
192
+ return ::google::protobuf::internal::MessageCreator::CopyInit(sizeof(EchoMsg),
193
+ alignof(EchoMsg));
194
+ }
195
+ constexpr auto EchoMsg::InternalGenerateClassData_() {
196
+ return ::google::protobuf::internal::ClassDataFull{
197
+ ::google::protobuf::internal::ClassData{
198
+ &_EchoMsg_default_instance_._instance,
199
+ &_table_.header,
200
+ nullptr, // OnDemandRegisterArenaDtor
201
+ nullptr, // IsInitialized
202
+ &EchoMsg::MergeImpl,
203
+ ::google::protobuf::Message::GetNewImpl<EchoMsg>(),
204
+ #if defined(PROTOBUF_CUSTOM_VTABLE)
205
+ &EchoMsg::SharedDtor,
206
+ ::google::protobuf::Message::GetClearImpl<EchoMsg>(), &EchoMsg::ByteSizeLong,
207
+ &EchoMsg::_InternalSerialize,
208
+ #endif // PROTOBUF_CUSTOM_VTABLE
209
+ PROTOBUF_FIELD_OFFSET(EchoMsg, _impl_._cached_size_),
210
+ false,
211
+ },
212
+ &EchoMsg::kDescriptorMethods,
213
+ &descriptor_table_github_2ecom_2faperturerobotics_2fstarpc_2fecho_2fecho_2eproto,
214
+ nullptr, // tracker
215
+ };
216
+ }
217
+
218
+ PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 const
219
+ ::google::protobuf::internal::ClassDataFull EchoMsg_class_data_ =
220
+ EchoMsg::InternalGenerateClassData_();
221
+
222
+ PROTOBUF_ATTRIBUTE_WEAK const ::google::protobuf::internal::ClassData* PROTOBUF_NONNULL
223
+ EchoMsg::GetClassData() const {
224
+ ::google::protobuf::internal::PrefetchToLocalCache(&EchoMsg_class_data_);
225
+ ::google::protobuf::internal::PrefetchToLocalCache(EchoMsg_class_data_.tc_table);
226
+ return EchoMsg_class_data_.base();
227
+ }
228
+ PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
229
+ const ::_pbi::TcParseTable<0, 1, 0, 25, 2>
230
+ EchoMsg::_table_ = {
231
+ {
232
+ PROTOBUF_FIELD_OFFSET(EchoMsg, _impl_._has_bits_),
233
+ 0, // no _extensions_
234
+ 1, 0, // max_field_number, fast_idx_mask
235
+ offsetof(decltype(_table_), field_lookup_table),
236
+ 4294967294, // skipmap
237
+ offsetof(decltype(_table_), field_entries),
238
+ 1, // num_field_entries
239
+ 0, // num_aux_entries
240
+ offsetof(decltype(_table_), field_names), // no aux_entries
241
+ EchoMsg_class_data_.base(),
242
+ nullptr, // post_loop_handler
243
+ ::_pbi::TcParser::GenericFallback, // fallback
244
+ #ifdef PROTOBUF_PREFETCH_PARSE_TABLE
245
+ ::_pbi::TcParser::GetTable<::echo::EchoMsg>(), // to_prefetch
246
+ #endif // PROTOBUF_PREFETCH_PARSE_TABLE
247
+ }, {{
248
+ // string body = 1;
249
+ {::_pbi::TcParser::FastUS1,
250
+ {10, 0, 0,
251
+ PROTOBUF_FIELD_OFFSET(EchoMsg, _impl_.body_)}},
252
+ }}, {{
253
+ 65535, 65535
254
+ }}, {{
255
+ // string body = 1;
256
+ {PROTOBUF_FIELD_OFFSET(EchoMsg, _impl_.body_), _Internal::kHasBitsOffset + 0, 0, (0 | ::_fl::kFcOptional | ::_fl::kUtf8String | ::_fl::kRepAString)},
257
+ }},
258
+ // no aux_entries
259
+ {{
260
+ "\14\4\0\0\0\0\0\0"
261
+ "echo.EchoMsg"
262
+ "body"
263
+ }},
264
+ };
265
+ PROTOBUF_NOINLINE void EchoMsg::Clear() {
266
+ // @@protoc_insertion_point(message_clear_start:echo.EchoMsg)
267
+ ::google::protobuf::internal::TSanWrite(&_impl_);
268
+ ::uint32_t cached_has_bits = 0;
269
+ // Prevent compiler warnings about cached_has_bits being unused
270
+ (void) cached_has_bits;
271
+
272
+ cached_has_bits = _impl_._has_bits_[0];
273
+ if (CheckHasBit(cached_has_bits, 0x00000001U)) {
274
+ _impl_.body_.ClearNonDefaultToEmpty();
275
+ }
276
+ _impl_._has_bits_.Clear();
277
+ _internal_metadata_.Clear<::google::protobuf::UnknownFieldSet>();
278
+ }
279
+
280
+ #if defined(PROTOBUF_CUSTOM_VTABLE)
281
+ ::uint8_t* PROTOBUF_NONNULL EchoMsg::_InternalSerialize(
282
+ const ::google::protobuf::MessageLite& base, ::uint8_t* PROTOBUF_NONNULL target,
283
+ ::google::protobuf::io::EpsCopyOutputStream* PROTOBUF_NONNULL stream) {
284
+ const EchoMsg& this_ = static_cast<const EchoMsg&>(base);
285
+ #else // PROTOBUF_CUSTOM_VTABLE
286
+ ::uint8_t* PROTOBUF_NONNULL EchoMsg::_InternalSerialize(
287
+ ::uint8_t* PROTOBUF_NONNULL target,
288
+ ::google::protobuf::io::EpsCopyOutputStream* PROTOBUF_NONNULL stream) const {
289
+ const EchoMsg& this_ = *this;
290
+ #endif // PROTOBUF_CUSTOM_VTABLE
291
+ if constexpr (::_pbi::DebugHardenCheckHasBitConsistency()) {
292
+ this_.CheckHasBitConsistency();
293
+ }
294
+ // @@protoc_insertion_point(serialize_to_array_start:echo.EchoMsg)
295
+ ::uint32_t cached_has_bits = 0;
296
+ (void)cached_has_bits;
297
+
298
+ cached_has_bits = this_._impl_._has_bits_[0];
299
+ // string body = 1;
300
+ if (CheckHasBit(cached_has_bits, 0x00000001U)) {
301
+ if (!this_._internal_body().empty()) {
302
+ const ::std::string& _s = this_._internal_body();
303
+ ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
304
+ _s.data(), static_cast<int>(_s.length()), ::google::protobuf::internal::WireFormatLite::SERIALIZE, "echo.EchoMsg.body");
305
+ target = stream->WriteStringMaybeAliased(1, _s, target);
306
+ }
307
+ }
308
+
309
+ if (ABSL_PREDICT_FALSE(this_._internal_metadata_.have_unknown_fields())) {
310
+ target =
311
+ ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
312
+ this_._internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance), target, stream);
313
+ }
314
+ // @@protoc_insertion_point(serialize_to_array_end:echo.EchoMsg)
315
+ return target;
316
+ }
317
+
318
+ #if defined(PROTOBUF_CUSTOM_VTABLE)
319
+ ::size_t EchoMsg::ByteSizeLong(const MessageLite& base) {
320
+ const EchoMsg& this_ = static_cast<const EchoMsg&>(base);
321
+ #else // PROTOBUF_CUSTOM_VTABLE
322
+ ::size_t EchoMsg::ByteSizeLong() const {
323
+ const EchoMsg& this_ = *this;
324
+ #endif // PROTOBUF_CUSTOM_VTABLE
325
+ // @@protoc_insertion_point(message_byte_size_start:echo.EchoMsg)
326
+ ::size_t total_size = 0;
327
+
328
+ ::uint32_t cached_has_bits = 0;
329
+ // Prevent compiler warnings about cached_has_bits being unused
330
+ (void)cached_has_bits;
331
+
332
+ {
333
+ // string body = 1;
334
+ cached_has_bits = this_._impl_._has_bits_[0];
335
+ if (CheckHasBit(cached_has_bits, 0x00000001U)) {
336
+ if (!this_._internal_body().empty()) {
337
+ total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize(
338
+ this_._internal_body());
339
+ }
340
+ }
341
+ }
342
+ return this_.MaybeComputeUnknownFieldsSize(total_size,
343
+ &this_._impl_._cached_size_);
344
+ }
345
+
346
+ void EchoMsg::MergeImpl(::google::protobuf::MessageLite& to_msg,
347
+ const ::google::protobuf::MessageLite& from_msg) {
348
+ auto* const _this =
349
+ static_cast<EchoMsg*>(&to_msg);
350
+ auto& from = static_cast<const EchoMsg&>(from_msg);
351
+ if constexpr (::_pbi::DebugHardenCheckHasBitConsistency()) {
352
+ from.CheckHasBitConsistency();
353
+ }
354
+ // @@protoc_insertion_point(class_specific_merge_from_start:echo.EchoMsg)
355
+ ABSL_DCHECK_NE(&from, _this);
356
+ ::uint32_t cached_has_bits = 0;
357
+ (void)cached_has_bits;
358
+
359
+ cached_has_bits = from._impl_._has_bits_[0];
360
+ if (CheckHasBit(cached_has_bits, 0x00000001U)) {
361
+ if (!from._internal_body().empty()) {
362
+ _this->_internal_set_body(from._internal_body());
363
+ } else {
364
+ if (_this->_impl_.body_.IsDefault()) {
365
+ _this->_internal_set_body("");
366
+ }
367
+ }
368
+ }
369
+ _this->_impl_._has_bits_[0] |= cached_has_bits;
370
+ _this->_internal_metadata_.MergeFrom<::google::protobuf::UnknownFieldSet>(
371
+ from._internal_metadata_);
372
+ }
373
+
374
+ void EchoMsg::CopyFrom(const EchoMsg& from) {
375
+ // @@protoc_insertion_point(class_specific_copy_from_start:echo.EchoMsg)
376
+ if (&from == this) return;
377
+ Clear();
378
+ MergeFrom(from);
379
+ }
380
+
381
+
382
+ void EchoMsg::InternalSwap(EchoMsg* PROTOBUF_RESTRICT PROTOBUF_NONNULL other) {
383
+ using ::std::swap;
384
+ auto* arena = GetArena();
385
+ ABSL_DCHECK_EQ(arena, other->GetArena());
386
+ _internal_metadata_.InternalSwap(&other->_internal_metadata_);
387
+ swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]);
388
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.body_, &other->_impl_.body_, arena);
389
+ }
390
+
391
+ ::google::protobuf::Metadata EchoMsg::GetMetadata() const {
392
+ return ::google::protobuf::Message::GetMetadataImpl(GetClassData()->full());
393
+ }
394
+ // @@protoc_insertion_point(namespace_scope)
395
+ } // namespace echo
396
+ namespace google {
397
+ namespace protobuf {
398
+ } // namespace protobuf
399
+ } // namespace google
400
+ // @@protoc_insertion_point(global_scope)
401
+ PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::std::false_type
402
+ _static_init2_ [[maybe_unused]] =
403
+ (::_pbi::AddDescriptors(&descriptor_table_github_2ecom_2faperturerobotics_2fstarpc_2fecho_2fecho_2eproto),
404
+ ::std::false_type{});
405
+ #include "google/protobuf/port_undef.inc"