From 7af7a7626a8e83fe3f9c3b0d2ad7d2b32da41d45 Mon Sep 17 00:00:00 2001 From: Daniel López Azaña Date: Sat, 30 Mar 2024 20:59:54 +0100 Subject: 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✨ (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 --- src/connection_details.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/connection_details.rs') diff --git a/src/connection_details.rs b/src/connection_details.rs index 06b6d15..228a597 100644 --- a/src/connection_details.rs +++ b/src/connection_details.rs @@ -1,7 +1,5 @@ -use hyper::server; - use crate::client_listener::ClientListener; -use crate::IllegalArgumentException; +use crate::error::IllegalArgumentException; use std::fmt::{self, Debug, Formatter}; @@ -64,6 +62,22 @@ impl ConnectionDetails { self.client_ip.as_ref() } + /// Retrieves a reference to the password, if set. + /// + /// This method is crucial for accessing sensitive information in a controlled manner. It returns + /// an immutable reference to the password, encapsulated within an `Option`. The use of `Option` + /// signifies that the password may or may not be present, thus providing flexibility in scenarios + /// where a password is optional. By returning a reference, we avoid unnecessary cloning of the + /// password data, which could have security implications and also incur a performance cost. + /// + /// # Returns + /// An `Option` containing a reference to the password `String` if it exists, or `None` if the + /// password has not been set. This allows calling code to handle the presence or absence of a + /// password appropriately without risking exposure of the password itself. + pub fn get_password(&self) -> Option<&String> { + self.password.as_ref() + } + /// Inquiry method that gets the configured address of Lightstreamer Server. /// /// # Returns -- cgit v1.2.3