Skip to main content

futu_gateway_core/bridge/
client_identity_runtime.rs

1//! Client identity runtime boundary for [`super::GatewayBridge`].
2//!
3//! App language and client type are set during HTTP auth phase and then read by
4//! QOT/TRD handler registration plus push callback wiring. Keeping them behind a
5//! narrow runtime avoids scattering raw bridge fields across surfaces.
6
7#[derive(Clone, Copy, Debug, Eq, PartialEq)]
8pub struct ClientIdentityRuntime {
9    app_lang: i32,
10    client_type: u8,
11}
12
13impl ClientIdentityRuntime {
14    pub fn new(app_lang: i32, client_type: u8) -> Self {
15        Self {
16            app_lang,
17            client_type,
18        }
19    }
20
21    pub fn default_futunn() -> Self {
22        // Defaults match the pre-initialize Futunn test identity:
23        // app_lang=0 (简体), client_type=40 (牛牛 FTNN).
24        Self::new(0, 40)
25    }
26
27    pub fn update(&mut self, app_lang: i32, client_type: u8) {
28        self.app_lang = app_lang;
29        self.client_type = client_type;
30    }
31
32    pub fn app_lang(&self) -> i32 {
33        self.app_lang
34    }
35
36    pub fn client_type(&self) -> u8 {
37        self.client_type
38    }
39}
40
41impl Default for ClientIdentityRuntime {
42    fn default() -> Self {
43        Self::default_futunn()
44    }
45}