binance_sdk/cms/mod.rs
1pub mod websocket_streams;
2
3use crate::common::{
4 config::ConfigurationWebsocketStreams, constants::CMS_WS_STREAMS_PROD_URL,
5 utils::build_user_agent,
6};
7
8/// Represents the Cms WebSocket Streams client for interacting with the Binance Cms WebSocket Streams.
9///
10/// This struct provides methods to create WebSocket Streams clients for production environments.
11pub struct CmsWsStreams {}
12
13impl CmsWsStreams {
14 /// Creates a WebSocket streams client configured with the given settings.
15 ///
16 /// If no WS URL is specified in the configuration, defaults to the production Cms WebSocket Streams URL.
17 ///
18 /// # Arguments
19 ///
20 /// * `config` - Configuration for the WebSocket streams client
21 ///
22 /// # Returns
23 ///
24 /// A new WebSocket streams client configured with the provided settings
25 #[must_use]
26 pub fn from_config(
27 mut config: ConfigurationWebsocketStreams,
28 ) -> websocket_streams::WebsocketStreamsHandle {
29 config.user_agent = build_user_agent("cms");
30 if config.ws_url.is_none() {
31 config.ws_url = Some(CMS_WS_STREAMS_PROD_URL.to_string());
32 }
33 websocket_streams::WebsocketStreamsHandle::new(config)
34 }
35
36 /// Creates a WebSocket streams client configured for the production environment.
37 ///
38 /// # Arguments
39 ///
40 /// * `config` - Configuration for the WebSocket streams client
41 ///
42 /// # Returns
43 ///
44 /// A new WebSocket streams client configured for the production environment
45 #[must_use]
46 pub fn production(
47 mut config: ConfigurationWebsocketStreams,
48 ) -> websocket_streams::WebsocketStreamsHandle {
49 config.ws_url = Some(CMS_WS_STREAMS_PROD_URL.to_string());
50 CmsWsStreams::from_config(config)
51 }
52}