futu_grpc/Users/leaf/ai-lab/futu-opend-rs/target/debug/build/futu-grpc-49ffe9c6b17e3c8f/out/
futu.service.rs

1// This file is @generated by prost-build.
2/// 通用请求:指定 proto_id + 原始 protobuf body
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct FutuRequest {
5    /// 协议 ID (如 3004=GetBasicQot)
6    #[prost(uint32, tag = "1")]
7    pub proto_id: u32,
8    /// protobuf 编码的请求 body (C2S)
9    #[prost(bytes = "vec", tag = "2")]
10    pub body: ::prost::alloc::vec::Vec<u8>,
11}
12/// 通用响应:原始 protobuf body
13#[derive(Clone, PartialEq, ::prost::Message)]
14pub struct FutuResponse {
15    /// 0=成功, 其他=错误码
16    #[prost(int32, tag = "1")]
17    pub ret_type: i32,
18    /// 错误信息
19    #[prost(string, tag = "2")]
20    pub ret_msg: ::prost::alloc::string::String,
21    /// 对应的协议 ID
22    #[prost(uint32, tag = "3")]
23    pub proto_id: u32,
24    /// protobuf 编码的响应 body
25    #[prost(bytes = "vec", tag = "4")]
26    pub body: ::prost::alloc::vec::Vec<u8>,
27}
28/// 推送事件
29#[derive(Clone, PartialEq, ::prost::Message)]
30pub struct PushEvent {
31    /// 推送协议 ID
32    #[prost(uint32, tag = "1")]
33    pub proto_id: u32,
34    /// 证券标识 (行情推送, 如 "1.00700")
35    #[prost(string, tag = "2")]
36    pub sec_key: ::prost::alloc::string::String,
37    /// 订阅类型 (行情推送)
38    #[prost(int32, tag = "3")]
39    pub sub_type: i32,
40    /// protobuf 编码的推送数据
41    #[prost(bytes = "vec", tag = "4")]
42    pub body: ::prost::alloc::vec::Vec<u8>,
43    /// 推送类型: "quote", "trade", "notify"
44    #[prost(string, tag = "5")]
45    pub event_type: ::prost::alloc::string::String,
46    /// 交易账户 ID (交易推送)
47    #[prost(uint64, tag = "6")]
48    pub acc_id: u64,
49}
50/// 订阅推送请求
51///
52/// 空请求,建立流式连接后接收所有推送
53#[derive(Clone, Copy, PartialEq, ::prost::Message)]
54pub struct SubscribePushRequest {}
55/// Generated client implementations.
56pub mod futu_open_d_client {
57    #![allow(
58        unused_variables,
59        dead_code,
60        missing_docs,
61        clippy::wildcard_imports,
62        clippy::let_unit_value,
63    )]
64    use tonic::codegen::*;
65    use tonic::codegen::http::Uri;
66    /// ── 通用服务 ──
67    /// 单一 RPC 方法处理所有请求,通过 proto_id 区分
68    #[derive(Debug, Clone)]
69    pub struct FutuOpenDClient<T> {
70        inner: tonic::client::Grpc<T>,
71    }
72    impl FutuOpenDClient<tonic::transport::Channel> {
73        /// Attempt to create a new client by connecting to a given endpoint.
74        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
75        where
76            D: TryInto<tonic::transport::Endpoint>,
77            D::Error: Into<StdError>,
78        {
79            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
80            Ok(Self::new(conn))
81        }
82    }
83    impl<T> FutuOpenDClient<T>
84    where
85        T: tonic::client::GrpcService<tonic::body::Body>,
86        T::Error: Into<StdError>,
87        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
88        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
89    {
90        pub fn new(inner: T) -> Self {
91            let inner = tonic::client::Grpc::new(inner);
92            Self { inner }
93        }
94        pub fn with_origin(inner: T, origin: Uri) -> Self {
95            let inner = tonic::client::Grpc::with_origin(inner, origin);
96            Self { inner }
97        }
98        pub fn with_interceptor<F>(
99            inner: T,
100            interceptor: F,
101        ) -> FutuOpenDClient<InterceptedService<T, F>>
102        where
103            F: tonic::service::Interceptor,
104            T::ResponseBody: Default,
105            T: tonic::codegen::Service<
106                http::Request<tonic::body::Body>,
107                Response = http::Response<
108                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
109                >,
110            >,
111            <T as tonic::codegen::Service<
112                http::Request<tonic::body::Body>,
113            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
114        {
115            FutuOpenDClient::new(InterceptedService::new(inner, interceptor))
116        }
117        /// Compress requests with the given encoding.
118        ///
119        /// This requires the server to support it otherwise it might respond with an
120        /// error.
121        #[must_use]
122        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
123            self.inner = self.inner.send_compressed(encoding);
124            self
125        }
126        /// Enable decompressing responses.
127        #[must_use]
128        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
129            self.inner = self.inner.accept_compressed(encoding);
130            self
131        }
132        /// Limits the maximum size of a decoded message.
133        ///
134        /// Default: `4MB`
135        #[must_use]
136        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
137            self.inner = self.inner.max_decoding_message_size(limit);
138            self
139        }
140        /// Limits the maximum size of an encoded message.
141        ///
142        /// Default: `usize::MAX`
143        #[must_use]
144        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
145            self.inner = self.inner.max_encoding_message_size(limit);
146            self
147        }
148        /// 通用请求-响应(覆盖所有行情/交易/系统接口)
149        pub async fn request(
150            &mut self,
151            request: impl tonic::IntoRequest<super::FutuRequest>,
152        ) -> std::result::Result<tonic::Response<super::FutuResponse>, tonic::Status> {
153            self.inner
154                .ready()
155                .await
156                .map_err(|e| {
157                    tonic::Status::unknown(
158                        format!("Service was not ready: {}", e.into()),
159                    )
160                })?;
161            let codec = tonic::codec::ProstCodec::default();
162            let path = http::uri::PathAndQuery::from_static(
163                "/futu.service.FutuOpenD/Request",
164            );
165            let mut req = request.into_request();
166            req.extensions_mut()
167                .insert(GrpcMethod::new("futu.service.FutuOpenD", "Request"));
168            self.inner.unary(req, path, codec).await
169        }
170        /// 流式推送(行情更新、订单更新等)
171        pub async fn subscribe_push(
172            &mut self,
173            request: impl tonic::IntoRequest<super::SubscribePushRequest>,
174        ) -> std::result::Result<
175            tonic::Response<tonic::codec::Streaming<super::PushEvent>>,
176            tonic::Status,
177        > {
178            self.inner
179                .ready()
180                .await
181                .map_err(|e| {
182                    tonic::Status::unknown(
183                        format!("Service was not ready: {}", e.into()),
184                    )
185                })?;
186            let codec = tonic::codec::ProstCodec::default();
187            let path = http::uri::PathAndQuery::from_static(
188                "/futu.service.FutuOpenD/SubscribePush",
189            );
190            let mut req = request.into_request();
191            req.extensions_mut()
192                .insert(GrpcMethod::new("futu.service.FutuOpenD", "SubscribePush"));
193            self.inner.server_streaming(req, path, codec).await
194        }
195    }
196}
197/// Generated server implementations.
198pub mod futu_open_d_server {
199    #![allow(
200        unused_variables,
201        dead_code,
202        missing_docs,
203        clippy::wildcard_imports,
204        clippy::let_unit_value,
205    )]
206    use tonic::codegen::*;
207    /// Generated trait containing gRPC methods that should be implemented for use with FutuOpenDServer.
208    #[async_trait]
209    pub trait FutuOpenD: std::marker::Send + std::marker::Sync + 'static {
210        /// 通用请求-响应(覆盖所有行情/交易/系统接口)
211        async fn request(
212            &self,
213            request: tonic::Request<super::FutuRequest>,
214        ) -> std::result::Result<tonic::Response<super::FutuResponse>, tonic::Status>;
215        /// Server streaming response type for the SubscribePush method.
216        type SubscribePushStream: tonic::codegen::tokio_stream::Stream<
217                Item = std::result::Result<super::PushEvent, tonic::Status>,
218            >
219            + std::marker::Send
220            + 'static;
221        /// 流式推送(行情更新、订单更新等)
222        async fn subscribe_push(
223            &self,
224            request: tonic::Request<super::SubscribePushRequest>,
225        ) -> std::result::Result<
226            tonic::Response<Self::SubscribePushStream>,
227            tonic::Status,
228        >;
229    }
230    /// ── 通用服务 ──
231    /// 单一 RPC 方法处理所有请求,通过 proto_id 区分
232    #[derive(Debug)]
233    pub struct FutuOpenDServer<T> {
234        inner: Arc<T>,
235        accept_compression_encodings: EnabledCompressionEncodings,
236        send_compression_encodings: EnabledCompressionEncodings,
237        max_decoding_message_size: Option<usize>,
238        max_encoding_message_size: Option<usize>,
239    }
240    impl<T> FutuOpenDServer<T> {
241        pub fn new(inner: T) -> Self {
242            Self::from_arc(Arc::new(inner))
243        }
244        pub fn from_arc(inner: Arc<T>) -> Self {
245            Self {
246                inner,
247                accept_compression_encodings: Default::default(),
248                send_compression_encodings: Default::default(),
249                max_decoding_message_size: None,
250                max_encoding_message_size: None,
251            }
252        }
253        pub fn with_interceptor<F>(
254            inner: T,
255            interceptor: F,
256        ) -> InterceptedService<Self, F>
257        where
258            F: tonic::service::Interceptor,
259        {
260            InterceptedService::new(Self::new(inner), interceptor)
261        }
262        /// Enable decompressing requests with the given encoding.
263        #[must_use]
264        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
265            self.accept_compression_encodings.enable(encoding);
266            self
267        }
268        /// Compress responses with the given encoding, if the client supports it.
269        #[must_use]
270        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
271            self.send_compression_encodings.enable(encoding);
272            self
273        }
274        /// Limits the maximum size of a decoded message.
275        ///
276        /// Default: `4MB`
277        #[must_use]
278        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
279            self.max_decoding_message_size = Some(limit);
280            self
281        }
282        /// Limits the maximum size of an encoded message.
283        ///
284        /// Default: `usize::MAX`
285        #[must_use]
286        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
287            self.max_encoding_message_size = Some(limit);
288            self
289        }
290    }
291    impl<T, B> tonic::codegen::Service<http::Request<B>> for FutuOpenDServer<T>
292    where
293        T: FutuOpenD,
294        B: Body + std::marker::Send + 'static,
295        B::Error: Into<StdError> + std::marker::Send + 'static,
296    {
297        type Response = http::Response<tonic::body::Body>;
298        type Error = std::convert::Infallible;
299        type Future = BoxFuture<Self::Response, Self::Error>;
300        fn poll_ready(
301            &mut self,
302            _cx: &mut Context<'_>,
303        ) -> Poll<std::result::Result<(), Self::Error>> {
304            Poll::Ready(Ok(()))
305        }
306        fn call(&mut self, req: http::Request<B>) -> Self::Future {
307            match req.uri().path() {
308                "/futu.service.FutuOpenD/Request" => {
309                    #[allow(non_camel_case_types)]
310                    struct RequestSvc<T: FutuOpenD>(pub Arc<T>);
311                    impl<T: FutuOpenD> tonic::server::UnaryService<super::FutuRequest>
312                    for RequestSvc<T> {
313                        type Response = super::FutuResponse;
314                        type Future = BoxFuture<
315                            tonic::Response<Self::Response>,
316                            tonic::Status,
317                        >;
318                        fn call(
319                            &mut self,
320                            request: tonic::Request<super::FutuRequest>,
321                        ) -> Self::Future {
322                            let inner = Arc::clone(&self.0);
323                            let fut = async move {
324                                <T as FutuOpenD>::request(&inner, request).await
325                            };
326                            Box::pin(fut)
327                        }
328                    }
329                    let accept_compression_encodings = self.accept_compression_encodings;
330                    let send_compression_encodings = self.send_compression_encodings;
331                    let max_decoding_message_size = self.max_decoding_message_size;
332                    let max_encoding_message_size = self.max_encoding_message_size;
333                    let inner = self.inner.clone();
334                    let fut = async move {
335                        let method = RequestSvc(inner);
336                        let codec = tonic::codec::ProstCodec::default();
337                        let mut grpc = tonic::server::Grpc::new(codec)
338                            .apply_compression_config(
339                                accept_compression_encodings,
340                                send_compression_encodings,
341                            )
342                            .apply_max_message_size_config(
343                                max_decoding_message_size,
344                                max_encoding_message_size,
345                            );
346                        let res = grpc.unary(method, req).await;
347                        Ok(res)
348                    };
349                    Box::pin(fut)
350                }
351                "/futu.service.FutuOpenD/SubscribePush" => {
352                    #[allow(non_camel_case_types)]
353                    struct SubscribePushSvc<T: FutuOpenD>(pub Arc<T>);
354                    impl<
355                        T: FutuOpenD,
356                    > tonic::server::ServerStreamingService<super::SubscribePushRequest>
357                    for SubscribePushSvc<T> {
358                        type Response = super::PushEvent;
359                        type ResponseStream = T::SubscribePushStream;
360                        type Future = BoxFuture<
361                            tonic::Response<Self::ResponseStream>,
362                            tonic::Status,
363                        >;
364                        fn call(
365                            &mut self,
366                            request: tonic::Request<super::SubscribePushRequest>,
367                        ) -> Self::Future {
368                            let inner = Arc::clone(&self.0);
369                            let fut = async move {
370                                <T as FutuOpenD>::subscribe_push(&inner, request).await
371                            };
372                            Box::pin(fut)
373                        }
374                    }
375                    let accept_compression_encodings = self.accept_compression_encodings;
376                    let send_compression_encodings = self.send_compression_encodings;
377                    let max_decoding_message_size = self.max_decoding_message_size;
378                    let max_encoding_message_size = self.max_encoding_message_size;
379                    let inner = self.inner.clone();
380                    let fut = async move {
381                        let method = SubscribePushSvc(inner);
382                        let codec = tonic::codec::ProstCodec::default();
383                        let mut grpc = tonic::server::Grpc::new(codec)
384                            .apply_compression_config(
385                                accept_compression_encodings,
386                                send_compression_encodings,
387                            )
388                            .apply_max_message_size_config(
389                                max_decoding_message_size,
390                                max_encoding_message_size,
391                            );
392                        let res = grpc.server_streaming(method, req).await;
393                        Ok(res)
394                    };
395                    Box::pin(fut)
396                }
397                _ => {
398                    Box::pin(async move {
399                        let mut response = http::Response::new(
400                            tonic::body::Body::default(),
401                        );
402                        let headers = response.headers_mut();
403                        headers
404                            .insert(
405                                tonic::Status::GRPC_STATUS,
406                                (tonic::Code::Unimplemented as i32).into(),
407                            );
408                        headers
409                            .insert(
410                                http::header::CONTENT_TYPE,
411                                tonic::metadata::GRPC_CONTENT_TYPE,
412                            );
413                        Ok(response)
414                    })
415                }
416            }
417        }
418    }
419    impl<T> Clone for FutuOpenDServer<T> {
420        fn clone(&self) -> Self {
421            let inner = self.inner.clone();
422            Self {
423                inner,
424                accept_compression_encodings: self.accept_compression_encodings,
425                send_compression_encodings: self.send_compression_encodings,
426                max_decoding_message_size: self.max_decoding_message_size,
427                max_encoding_message_size: self.max_encoding_message_size,
428            }
429        }
430    }
431    /// Generated gRPC service name
432    pub const SERVICE_NAME: &str = "futu.service.FutuOpenD";
433    impl<T> tonic::server::NamedService for FutuOpenDServer<T> {
434        const NAME: &'static str = SERVICE_NAME;
435    }
436}