Skip to content

Commit

Permalink
added accessor for client id (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
wboayue authored Jan 28, 2025
1 parent 252845c commit 9d0cd68
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ibapi"
version = "1.0.13"
version = "1.0.14"
edition = "2021"
authors = ["Wil Boayue <[email protected]>"]
description = "A Rust implementation of the Interactive Brokers TWS API, providing a reliable and user friendly interface for TWS and IB Gateway. Designed with a focus on simplicity and performance."
Expand Down
5 changes: 5 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ impl Client {
Ok(client)
}

/// Returns the ID assigned to the [Client].
pub fn client_id(&self) -> i32 {
self.client_id
}

/// Returns the next request ID.
pub fn next_request_id(&self) -> i32 {
self.next_request_id.fetch_add(1, Ordering::Relaxed)
Expand Down
16 changes: 16 additions & 0 deletions src/client/tests.rs
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
use std::sync::Arc;

use crate::{stubs::MessageBusStub, transport::ConnectionMetadata};

use super::Client;


#[test]
fn test_client_id() {
let client_id = 500;
let connection_metadata = ConnectionMetadata{client_id, ..ConnectionMetadata::default()};
let message_bus = Arc::new(MessageBusStub::default());

let client = Client::new(connection_metadata, message_bus).unwrap();

assert_eq!(client.client_id(), client_id);
}

0 comments on commit 9d0cd68

Please sign in to comment.