Skip to main content

longbridge_proto/
longbridge.control.v1.rs

1// This file is @generated by prost-build.
2#[derive(serde::Serialize, serde::Deserialize)]
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct Close {
5    #[prost(enumeration = "close::Code", tag = "1")]
6    pub code: i32,
7    #[prost(string, tag = "2")]
8    pub reason: ::prost::alloc::string::String,
9}
10/// Nested message and enum types in `Close`.
11pub mod close {
12    #[derive(serde::Serialize, serde::Deserialize)]
13    #[derive(
14        Clone,
15        Copy,
16        Debug,
17        PartialEq,
18        Eq,
19        Hash,
20        PartialOrd,
21        Ord,
22        ::prost::Enumeration
23    )]
24    #[repr(i32)]
25    pub enum Code {
26        /// 心跳超时
27        HeartbeatTimeout = 0,
28        /// 服务端错误
29        ServerError = 1,
30        /// 服务端关闭
31        ServerShutdown = 2,
32        /// 数据截取错误
33        UnpackError = 3,
34        /// 鉴权失败
35        AuthError = 4,
36        /// session 过期
37        SessExpired = 5,
38        /// 单个 session 重复连接
39        ConnectDuplicate = 6,
40    }
41    impl Code {
42        /// String value of the enum field names used in the ProtoBuf definition.
43        ///
44        /// The values are not transformed in any way and thus are considered stable
45        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
46        pub fn as_str_name(&self) -> &'static str {
47            match self {
48                Self::HeartbeatTimeout => "HeartbeatTimeout",
49                Self::ServerError => "ServerError",
50                Self::ServerShutdown => "ServerShutdown",
51                Self::UnpackError => "UnpackError",
52                Self::AuthError => "AuthError",
53                Self::SessExpired => "SessExpired",
54                Self::ConnectDuplicate => "ConnectDuplicate",
55            }
56        }
57        /// Creates an enum from field names used in the ProtoBuf definition.
58        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
59            match value {
60                "HeartbeatTimeout" => Some(Self::HeartbeatTimeout),
61                "ServerError" => Some(Self::ServerError),
62                "ServerShutdown" => Some(Self::ServerShutdown),
63                "UnpackError" => Some(Self::UnpackError),
64                "AuthError" => Some(Self::AuthError),
65                "SessExpired" => Some(Self::SessExpired),
66                "ConnectDuplicate" => Some(Self::ConnectDuplicate),
67                _ => None,
68            }
69        }
70    }
71}
72#[derive(serde::Serialize, serde::Deserialize)]
73#[derive(Clone, Copy, PartialEq, ::prost::Message)]
74pub struct Heartbeat {
75    #[prost(int64, tag = "1")]
76    pub timestamp: i64,
77    #[prost(int32, optional, tag = "2")]
78    pub heartbeat_id: ::core::option::Option<i32>,
79}
80#[derive(serde::Serialize, serde::Deserialize)]
81#[derive(Clone, PartialEq, ::prost::Message)]
82pub struct AuthRequest {
83    #[prost(string, tag = "1")]
84    pub token: ::prost::alloc::string::String,
85    #[prost(map = "string, string", tag = "2")]
86    pub metadata: ::std::collections::HashMap<
87        ::prost::alloc::string::String,
88        ::prost::alloc::string::String,
89    >,
90}
91#[derive(serde::Serialize, serde::Deserialize)]
92#[derive(Clone, PartialEq, ::prost::Message)]
93pub struct AuthResponse {
94    #[prost(string, tag = "1")]
95    pub session_id: ::prost::alloc::string::String,
96    #[prost(int64, tag = "2")]
97    pub expires: i64,
98    #[prost(uint32, tag = "3")]
99    pub limit: u32,
100    #[prost(uint32, tag = "4")]
101    pub online: u32,
102}
103#[derive(serde::Serialize, serde::Deserialize)]
104#[derive(Clone, PartialEq, ::prost::Message)]
105pub struct ReconnectRequest {
106    #[prost(string, tag = "1")]
107    pub session_id: ::prost::alloc::string::String,
108    #[prost(map = "string, string", tag = "2")]
109    pub metadata: ::std::collections::HashMap<
110        ::prost::alloc::string::String,
111        ::prost::alloc::string::String,
112    >,
113}
114#[derive(serde::Serialize, serde::Deserialize)]
115#[derive(Clone, PartialEq, ::prost::Message)]
116pub struct ReconnectResponse {
117    #[prost(string, tag = "1")]
118    pub session_id: ::prost::alloc::string::String,
119    #[prost(int64, tag = "2")]
120    pub expires: i64,
121    #[prost(uint32, tag = "3")]
122    pub limit: u32,
123    #[prost(uint32, tag = "4")]
124    pub online: u32,
125}
126/// control command, see document: <https://open.longbridgeapp.com/docs/socket/control-command>
127#[derive(serde::Serialize, serde::Deserialize)]
128#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
129#[repr(i32)]
130pub enum Command {
131    CmdClose = 0,
132    CmdHeartbeat = 1,
133    CmdAuth = 2,
134    CmdReconnect = 3,
135}
136impl Command {
137    /// String value of the enum field names used in the ProtoBuf definition.
138    ///
139    /// The values are not transformed in any way and thus are considered stable
140    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
141    pub fn as_str_name(&self) -> &'static str {
142        match self {
143            Self::CmdClose => "CMD_CLOSE",
144            Self::CmdHeartbeat => "CMD_HEARTBEAT",
145            Self::CmdAuth => "CMD_AUTH",
146            Self::CmdReconnect => "CMD_RECONNECT",
147        }
148    }
149    /// Creates an enum from field names used in the ProtoBuf definition.
150    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
151        match value {
152            "CMD_CLOSE" => Some(Self::CmdClose),
153            "CMD_HEARTBEAT" => Some(Self::CmdHeartbeat),
154            "CMD_AUTH" => Some(Self::CmdAuth),
155            "CMD_RECONNECT" => Some(Self::CmdReconnect),
156            _ => None,
157        }
158    }
159}