diff options
author | 2024-03-30 20:59:54 +0100 | |
---|---|---|
committer | 2024-03-30 20:59:58 +0100 | |
commit | 7af7a7626a8e83fe3f9c3b0d2ad7d2b32da41d45 (patch) | |
tree | 319b9976f6274f42e748d1b501229bb219584f66 /src/connection_options.rs | |
parent | c6745a22e79f0556a19b0d44a181fb9d8ed78f90 (diff) |
WARNING: unstable commit.
🔧 Update .gitignore to exclude .vscode directory
✨ Add futures-util and url dependencies to Cargo.toml
♻️ Refactor error handling into separate error module in Rust project
💡 Add get_password method documentation in connection_details.rs
♻️ Replace String with Transport enum for forced_transport in connection_options.rs
✨ Implement WebSocket connection logic in ls_client.rs with async support
✨ Add ClientStatus, ConnectionType, and DisconnectionType enums to manage client states in ls_client.rs
✨ (main.rs): add Transport enum to LightstreamerClient imports for WebSocket support
♻️ (main.rs): refactor signal handling to use SharedState struct for clean shutdown
✨ (main.rs): implement AtomicBool for graceful disconnect handling
📝 (main.rs): update comments to reflect new signal handling logic
✨ (main.rs): set forced transport to WebSocket streaming in Lightstreamer client options
✨ (util.rs): create new util module with clean_message function for message sanitization
Diffstat (limited to 'src/connection_options.rs')
-rw-r--r-- | src/connection_options.rs | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/src/connection_options.rs b/src/connection_options.rs index c143fb9..e3218df 100644 --- a/src/connection_options.rs +++ b/src/connection_options.rs @@ -1,9 +1,9 @@ +use crate::error::IllegalArgumentException; +use crate::ls_client::Transport; use crate::proxy::Proxy; -use crate::IllegalArgumentException; use std::collections::HashMap; use std::fmt::{self, Debug, Formatter}; -use std::hash::DefaultHasher; /// Used by LightstreamerClient to provide an extra connection properties data object. /// Data struct that contains the policy settings used to connect to a Lightstreamer Server. @@ -13,7 +13,7 @@ use std::hash::DefaultHasher; pub struct ConnectionOptions { content_length: Option<u64>, first_retry_max_delay: u64, - forced_transport: Option<String>, + forced_transport: Option<Transport>, http_extra_headers: Option<HashMap<String, String>>, http_extra_headers_on_session_creation_only: bool, idle_timeout: u64, @@ -97,7 +97,7 @@ impl ConnectionOptions { /// The forced transport or `None` /// /// See also `setForcedTransport()` - pub fn get_forced_transport(&self) -> Option<&String> { + pub fn get_forced_transport(&self) -> Option<&Transport> { self.forced_transport.as_ref() } @@ -423,25 +423,8 @@ impl ConnectionOptions { /// # Raises /// /// * `IllegalArgumentException`: if the given value is not in the list of the admitted ones. - pub fn set_forced_transport(&mut self, forced_transport: Option<String>) -> Result<(), IllegalArgumentException> { - let valid_transports = vec![ - None, - Some("WS".to_string()), - Some("HTTP".to_string()), - Some("WS-STREAMING".to_string()), - Some("HTTP-STREAMING".to_string()), - Some("WS-POLLING".to_string()), - Some("HTTP-POLLING".to_string()), - ]; - - if !valid_transports.contains(&forced_transport) { - return Err(IllegalArgumentException::new( - "Invalid forced transport value", - )); - } - + pub fn set_forced_transport(&mut self, forced_transport: Option<Transport>) { self.forced_transport = forced_transport; - Ok(()) } /// Setter method that enables/disables the setting of extra HTTP headers to all the request @@ -1157,4 +1140,4 @@ impl Default for ConnectionOptions { supported_diffs: None, } } -}
\ No newline at end of file +} |