Crates.io | lightstreamer-client |
lib.rs | lightstreamer-client |
version | 0.1.9 |
source | src |
created_at | 2024-03-23 12:34:38.640227 |
updated_at | 2024-04-13 19:25:07.417137 |
description | A Rust client for Lightstreamer, designed to facilitate real-time communication with Lightstreamer servers. |
homepage | |
repository | https://github.com/daniloaz/lightstreamer-client |
max_upload_size | |
id | 1183515 |
size | 323,544 |
This project is a partial implementation of the Lightstreamer TLCP (Text-based Live Connections Protocol) in Rust. It provides a client SDK to interact with Lightstreamer servers, focused on supporting the specific needs of the ig_trading_api project.
Please note that this SDK currently does not support all the features and capabilities of the full Lightstreamer protocol. It has been developed to cover the requirements of the ig_trading_api project mentioned above. Features like other connection modes, subscription modes (DISTINCT, RAW, COMMAND), and some other advanced options are not implemented at this time.
To use this SDK in your Rust project, add the following dependency to your Cargo.toml
:
[dependencies]
lightstreamer-client = "0.1.9"
Here's a minimal example of how to use the Lightstreamer Rust Client SDK:
use lightstreamer_client::ls_client::LightstreamerClient;
use lightstreamer_client::subscription::{Subscription, SubscriptionMode};
#[tokio::main]
async fn main() {
// Create a Lightstreamer client
let client = LightstreamerClient::new(
Some("http://push.lightstreamer.com/lightstreamer"), // Lightstreamer server
Some("DEMO"), // adapter set
None, // username
None, // password
).unwrap();
// Create a subscription
let mut subscription = Subscription::new(
SubscriptionMode::Merge,
Some(vec!["item1".to_string(), "item2".to_string()]),
Some(vec!["field1".to_string(), "field2".to_string()]),
).unwrap();
// Subscribe and connect
client.subscribe(subscription);
client.connect(None).await.unwrap();
}
For a more advanced example of how to use the SDK to subscribe to item updates, refer to the main.rs file in the project source code. It demonstrates creating a Lightstreamer client, setting up subscriptions, handling item updates, and managing the connection lifecycle with a configurable number of connection attempts.
For more details on using the SDK, please refer to the reference documentation.
The full SDK documentation is available at docs.rs.
Although this SDK does not provide a complete implementation of the Lightstreamer protocol, it has been built with a solid structure and scaffolding, similar to the official Lightstreamer libraries. The code is documented, and the project is designed to facilitate contributions from the community to add support for missing features.
This project is licensed under the GPL-3.0 License. See the LICENSE file for details.
Contributions are welcome. Please open an issue or submit a pull request to propose changes and help complete the SDK with additional Lightstreamer features.