diff options
author | 2024-04-13 12:21:12 +0200 | |
---|---|---|
committer | 2024-04-13 12:21:12 +0200 | |
commit | 5af8a69942aeed85b5cd2bd84cb5f33169834690 (patch) | |
tree | d3910ffc83037fd931d665112b076070f01b9295 /src/main.rs | |
parent | 82a9d2f0708c7f3754d5c40a60fa291bb320301b (diff) |
✨ (Cargo.toml): Bump package version to 0.1.8 for new changes
♻️ (item_update.rs): Refactor ItemUpdate struct and related methods to store only non-null changed fields
♻️ (ls_client.rs): Refactor data update handling to store updates in a HashMap and call on_item_update for each listener
🐛 (ls_client.rs): Fix item index off-by-one error in data update handling
🐛 (main.rs): Update on_item_update implementation to handle new ItemUpdate structure
♻️ (subscription_listener.rs): Refactor on_item_update method to take a reference to ItemUpdate
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 4959652..c284605 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,11 +43,34 @@ async fn setup_signal_hook(shutdown_signal: Arc<Notify>) { pub struct MySubscriptionListener {} impl SubscriptionListener for MySubscriptionListener { - fn on_item_update(&mut self, update: ItemUpdate) { + fn on_item_update(&self, update: &ItemUpdate) { println!( - "UPDATE {} {}", - update.get_value("stock_name").unwrap(), - update.get_value("last_price").unwrap() + "UPDATE for item '{}' => '{}': {}, '{}': {}, '{}': {}, '{}': {}, '{}': {}, '{}': {}, '{}': {}, '{}': {}, '{}': {}, '{}': {}, '{}': {}, '{}': {}", + update.item_name.as_ref().unwrap_or(&"N/A".to_string()), + "stock_name", + update.get_value("stock_name").unwrap_or(&"N/A".to_string()), + "last_price", + update.get_value("last_price").unwrap_or(&"N/A".to_string()), + "time", + update.get_value("time").unwrap_or(&"N/A".to_string()), + "pct_change", + update.get_value("pct_change").unwrap_or(&"N/A".to_string()), + "bid_quantity", + update.get_value("bid_quantity").unwrap_or(&"N/A".to_string()), + "bid", + update.get_value("bid").unwrap_or(&"N/A".to_string()), + "ask", + update.get_value("ask").unwrap_or(&"N/A".to_string()), + "ask_quantity", + update.get_value("ask_quantity").unwrap_or(&"N/A".to_string()), + "min", + update.get_value("min").unwrap_or(&"N/A".to_string()), + "max", + update.get_value("max").unwrap_or(&"N/A".to_string()), + "ref_price", + update.get_value("ref_price").unwrap_or(&"N/A".to_string()), + "open_price", + update.get_value("open_price").unwrap_or(&"N/A".to_string()), ); } } |