From 5c80b291fc776a7114572cebff898a7b3bf0671b Mon Sep 17 00:00:00 2001 From: Daniel López Azaña Date: Thu, 28 Mar 2024 20:21:52 +0100 Subject: ✨ (lib.rs): introduce `ls_client` module as a cleaner naming convention ✨ (ls_client.rs): add `LightstreamerClient` struct and associated methods for managing communication with Lightstreamer Server ✨ (main.rs): update imports to use new `ls_client` module and add data adapter and snapshot configuration to subscription ♻️ (lib.rs): refactor `lightstreamer_client` to `ls_client` for consistency with new module name 📝 (ls_client.rs): add comprehensive documentation for `LightstreamerClient` and its methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✨ (subscription.rs): add Snapshot enum to define snapshot delivery preferences ♻️ (subscription.rs): refactor requested_snapshot to use Snapshot enum for clarity 💡 (subscription.rs): update comments to reflect changes in snapshot handling --- src/main.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 2dddb0d..5c2acc5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,10 @@ -use crate::item_update::ItemUpdate; -use crate::subscription::{Subscription, SubscriptionMode}; -use crate::subscription_listener::SubscriptionListener; +use lightstreamer_client::item_update::ItemUpdate; +use lightstreamer_client::ls_client::LightstreamerClient; +use lightstreamer_client::subscription::{Snapshot, Subscription, SubscriptionMode}; +use lightstreamer_client::subscription_listener::SubscriptionListener; use futures::stream::StreamExt; use futures::SinkExt; -use lightstreamer_client::lightstreamer_client::LightstreamerClient; use reqwest::Client; use serde_urlencoded; use std::error::Error; @@ -12,10 +12,6 @@ use std::sync::Arc; use tokio::sync::Mutex; use tokio_tungstenite::{connect_async, tungstenite::protocol::Message}; -mod item_update; -mod subscription; -mod subscription_listener; - async fn establish_persistent_http_connection( session_id_shared: Arc>, ) -> Result<(), reqwest::Error> { @@ -225,6 +221,8 @@ async fn main() -> Result<(), Box> { )?; subscription.add_listener(Box::new(MySubscriptionListener {})); + subscription.set_data_adapter(Some(String::from("QUOTE_ADAPTER")))?; + subscription.set_requested_snapshot(Some(Snapshot::Yes))?; let client = LightstreamerClient::new( Some("http://push.lightstreamer.com/lightstreamer"), -- cgit v1.2.3