starpc 0.45.0 → 0.46.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/dist/echo/echo.pb.js +1 -1
- package/dist/mock/mock.pb.js +1 -1
- package/dist/rpcstream/rpcstream.pb.js +1 -1
- package/dist/srpc/rpcproto.pb.js +1 -1
- package/echo/Cargo.toml +0 -4
- package/echo/echo.pb.go +1 -1
- package/echo/echo.pb.rs +9 -0
- package/echo/echo.pb.ts +1 -1
- package/echo/echo_e2e_test.cpp +3 -3
- package/echo/echo_srpc.pb.cpp +29 -41
- package/echo/echo_srpc.pb.go +1 -1
- package/echo/echo_srpc.pb.hpp +109 -132
- package/echo/echo_srpc.pb.rs +312 -0
- package/echo/gen/mod.rs +15 -2
- package/echo/main.rs +9 -0
- package/go.mod +3 -2
- package/go.sum +6 -4
- package/mock/mock.pb.go +1 -1
- package/mock/mock.pb.rs +9 -0
- package/mock/mock.pb.ts +1 -1
- package/mock/mock_srpc.pb.cpp +11 -14
- package/mock/mock_srpc.pb.go +1 -1
- package/mock/mock_srpc.pb.hpp +31 -35
- package/mock/mock_srpc.pb.rs +103 -0
- package/package.json +1 -1
- package/srpc/Cargo.toml +1 -2
- package/srpc/client-rpc.cpp +1 -1
- package/srpc/client.cpp +1 -1
- package/srpc/common-rpc.cpp +1 -1
- package/srpc/lib.rs +2 -0
- package/srpc/mux.cpp +1 -1
- package/srpc/packet.cpp +1 -1
- package/srpc/proto.rs +5 -0
- package/srpc/rpcproto.pb.go +1 -1
- package/srpc/rpcproto.pb.rs +62 -0
- package/srpc/rpcproto.pb.ts +1 -1
- package/srpc/server-rpc.cpp +1 -1
- package/echo/build.rs +0 -15
- package/srpc/build.rs +0 -15
- package/srpc/proto/mod.rs +0 -10
|
@@ -0,0 +1,103 @@
|
|
|
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/mock/mock.proto
|
|
4
|
+
|
|
5
|
+
#[allow(unused_imports)]
|
|
6
|
+
use starpc::StreamExt;
|
|
7
|
+
|
|
8
|
+
/// Service ID for Mock.
|
|
9
|
+
pub const MOCK_SERVICE_ID: &str = "e2e.mock.Mock";
|
|
10
|
+
|
|
11
|
+
/// Client trait for Mock.
|
|
12
|
+
#[starpc::async_trait]
|
|
13
|
+
pub trait MockClient: Send + Sync {
|
|
14
|
+
/// MockRequest.
|
|
15
|
+
async fn mock_request(&self, request: &MockMsg) -> starpc::Result<MockMsg>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/// Client implementation for Mock.
|
|
19
|
+
pub struct MockClientImpl<C> {
|
|
20
|
+
client: C,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
impl<C: starpc::Client> MockClientImpl<C> {
|
|
24
|
+
/// Creates a new client.
|
|
25
|
+
pub fn new(client: C) -> Self {
|
|
26
|
+
Self { client }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#[starpc::async_trait]
|
|
31
|
+
impl<C: starpc::Client + 'static> MockClient for MockClientImpl<C> {
|
|
32
|
+
async fn mock_request(&self, request: &MockMsg) -> starpc::Result<MockMsg> {
|
|
33
|
+
self.client.exec_call("e2e.mock.Mock", "MockRequest", request).await
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/// Server trait for Mock.
|
|
38
|
+
#[starpc::async_trait]
|
|
39
|
+
pub trait MockServer: Send + Sync {
|
|
40
|
+
/// MockRequest.
|
|
41
|
+
async fn mock_request(&self, request: MockMsg) -> starpc::Result<MockMsg>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const MOCK_METHOD_IDS: &[&str] = &[
|
|
45
|
+
"MockRequest",
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
/// Handler for Mock.
|
|
49
|
+
pub struct MockHandler<S: MockServer> {
|
|
50
|
+
server: std::sync::Arc<S>,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
impl<S: MockServer + 'static> MockHandler<S> {
|
|
54
|
+
/// Creates a new handler wrapping the server implementation.
|
|
55
|
+
pub fn new(server: S) -> Self {
|
|
56
|
+
Self { server: std::sync::Arc::new(server) }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/// Creates a new handler with a shared server.
|
|
60
|
+
pub fn with_arc(server: std::sync::Arc<S>) -> Self {
|
|
61
|
+
Self { server }
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
#[starpc::async_trait]
|
|
66
|
+
impl<S: MockServer + 'static> starpc::Invoker for MockHandler<S> {
|
|
67
|
+
async fn invoke_method(
|
|
68
|
+
&self,
|
|
69
|
+
_service_id: &str,
|
|
70
|
+
method_id: &str,
|
|
71
|
+
stream: Box<dyn starpc::Stream>,
|
|
72
|
+
) -> (bool, starpc::Result<()>) {
|
|
73
|
+
match method_id {
|
|
74
|
+
"MockRequest" => {
|
|
75
|
+
let request: MockMsg = match stream.msg_recv().await {
|
|
76
|
+
Ok(r) => r,
|
|
77
|
+
Err(e) => return (true, Err(e)),
|
|
78
|
+
};
|
|
79
|
+
match self.server.mock_request(request).await {
|
|
80
|
+
Ok(response) => {
|
|
81
|
+
if let Err(e) = stream.msg_send(&response).await {
|
|
82
|
+
return (true, Err(e));
|
|
83
|
+
}
|
|
84
|
+
(true, Ok(()))
|
|
85
|
+
}
|
|
86
|
+
Err(e) => (true, Err(e)),
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
_ => (false, Err(starpc::Error::Unimplemented)),
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
impl<S: MockServer + 'static> starpc::Handler for MockHandler<S> {
|
|
95
|
+
fn service_id(&self) -> &'static str {
|
|
96
|
+
"e2e.mock.Mock"
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
fn method_ids(&self) -> &'static [&'static str] {
|
|
100
|
+
MOCK_METHOD_IDS
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
package/package.json
CHANGED
package/srpc/Cargo.toml
CHANGED
package/srpc/client-rpc.cpp
CHANGED
package/srpc/client.cpp
CHANGED
package/srpc/common-rpc.cpp
CHANGED
package/srpc/lib.rs
CHANGED
package/srpc/mux.cpp
CHANGED
package/srpc/packet.cpp
CHANGED
package/srpc/proto.rs
ADDED
package/srpc/rpcproto.pb.go
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// @generated
|
|
2
|
+
// This file is @generated by prost-build.
|
|
3
|
+
/// Packet is a message sent over a srpc packet connection.
|
|
4
|
+
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
|
5
|
+
pub struct Packet {
|
|
6
|
+
/// Body is the packet body.
|
|
7
|
+
#[prost(oneof="packet::Body", tags="1, 2, 3")]
|
|
8
|
+
pub body: ::core::option::Option<packet::Body>,
|
|
9
|
+
}
|
|
10
|
+
/// Nested message and enum types in `Packet`.
|
|
11
|
+
pub mod packet {
|
|
12
|
+
/// Body is the packet body.
|
|
13
|
+
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
|
|
14
|
+
pub enum Body {
|
|
15
|
+
/// CallStart initiates a new call.
|
|
16
|
+
#[prost(message, tag="1")]
|
|
17
|
+
CallStart(super::CallStart),
|
|
18
|
+
/// CallData is a message in a streaming RPC sequence.
|
|
19
|
+
#[prost(message, tag="2")]
|
|
20
|
+
CallData(super::CallData),
|
|
21
|
+
/// CallCancel cancels the call.
|
|
22
|
+
#[prost(bool, tag="3")]
|
|
23
|
+
CallCancel(bool),
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/// CallStart requests starting a new RPC call.
|
|
27
|
+
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
|
28
|
+
pub struct CallStart {
|
|
29
|
+
/// RpcService is the service to contact.
|
|
30
|
+
/// Must be set.
|
|
31
|
+
#[prost(string, tag="1")]
|
|
32
|
+
pub rpc_service: ::prost::alloc::string::String,
|
|
33
|
+
/// RpcMethod is the RPC method to call.
|
|
34
|
+
/// Must be set.
|
|
35
|
+
#[prost(string, tag="2")]
|
|
36
|
+
pub rpc_method: ::prost::alloc::string::String,
|
|
37
|
+
/// Data contains the request or the first message in the stream.
|
|
38
|
+
/// Optional if streaming.
|
|
39
|
+
#[prost(bytes="vec", tag="3")]
|
|
40
|
+
pub data: ::prost::alloc::vec::Vec<u8>,
|
|
41
|
+
/// DataIsZero indicates Data is set with an empty message.
|
|
42
|
+
#[prost(bool, tag="4")]
|
|
43
|
+
pub data_is_zero: bool,
|
|
44
|
+
}
|
|
45
|
+
/// CallData contains a message in a streaming RPC sequence.
|
|
46
|
+
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
|
47
|
+
pub struct CallData {
|
|
48
|
+
/// Data contains the packet in the sequence.
|
|
49
|
+
#[prost(bytes="vec", tag="1")]
|
|
50
|
+
pub data: ::prost::alloc::vec::Vec<u8>,
|
|
51
|
+
/// DataIsZero indicates Data is set with an empty message.
|
|
52
|
+
#[prost(bool, tag="2")]
|
|
53
|
+
pub data_is_zero: bool,
|
|
54
|
+
/// Complete indicates the RPC call is completed.
|
|
55
|
+
#[prost(bool, tag="3")]
|
|
56
|
+
pub complete: bool,
|
|
57
|
+
/// Error contains any error that caused the RPC to fail.
|
|
58
|
+
/// If set, implies complete=true.
|
|
59
|
+
#[prost(string, tag="4")]
|
|
60
|
+
pub error: ::prost::alloc::string::String,
|
|
61
|
+
}
|
|
62
|
+
// @@protoc_insertion_point(module)
|
package/srpc/rpcproto.pb.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protoc-gen-es-lite unknown with parameter "ts_nocheck=false
|
|
1
|
+
// @generated by protoc-gen-es-lite unknown with parameter "target=ts,ts_nocheck=false"
|
|
2
2
|
// @generated from file github.com/aperturerobotics/starpc/srpc/rpcproto.proto (package srpc, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
|
package/srpc/server-rpc.cpp
CHANGED
package/echo/build.rs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
}
|
package/srpc/build.rs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
use std::io::Result;
|
|
2
|
-
use std::path::PathBuf;
|
|
3
|
-
|
|
4
|
-
fn main() -> Result<()> {
|
|
5
|
-
// Get the path to the proto file in the same directory.
|
|
6
|
-
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
|
7
|
-
let proto_path = manifest_dir.join("rpcproto.proto");
|
|
8
|
-
|
|
9
|
-
println!("cargo:rerun-if-changed={}", proto_path.display());
|
|
10
|
-
|
|
11
|
-
prost_build::Config::new()
|
|
12
|
-
.compile_protos(&[proto_path], &[&manifest_dir])?;
|
|
13
|
-
|
|
14
|
-
Ok(())
|
|
15
|
-
}
|
package/srpc/proto/mod.rs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
//! Generated protocol buffer types for starpc.
|
|
2
|
-
//!
|
|
3
|
-
//! This module contains the Packet, CallStart, CallData types generated from
|
|
4
|
-
//! rpcproto.proto. These types define the wire protocol for starpc.
|
|
5
|
-
|
|
6
|
-
// Include the generated protobuf types.
|
|
7
|
-
include!(concat!(env!("OUT_DIR"), "/srpc.rs"));
|
|
8
|
-
|
|
9
|
-
// Re-export commonly used items.
|
|
10
|
-
pub use self::packet::Body;
|