pub struct ConnectionOptions { /* private fields */ }Expand description
Callback for handling unsolicited messages during connection setup.
When TWS sends messages like OpenOrder or OrderStatus during the connection
handshake, this callback is invoked to allow the application to process them
instead of discarding them.
§Example
ⓘ
use ibapi::{Client, StartupMessageCallback};
use ibapi::messages::IncomingMessages;
use std::sync::{Arc, Mutex};
#[tokio::main]
async fn main() {
let orders = Arc::new(Mutex::new(Vec::new()));
let orders_clone = orders.clone();
let callback: StartupMessageCallback = Box::new(move |msg| {
match msg.message_type() {
IncomingMessages::OpenOrder | IncomingMessages::OrderStatus => {
orders_clone.lock().unwrap().push(msg);
}
_ => {}
}
});
let client = Client::connect_with_callback("127.0.0.1:4002", 100, Some(callback))
.await
.expect("connection failed");
println!("Received {} startup orders", orders.lock().unwrap().len());
}Options for configuring a connection to TWS or IB Gateway.
Use the builder methods to configure options, then pass to
Client::connect_with_options.
§Examples
use ibapi::ConnectionOptions;
let options = ConnectionOptions::default()
.tcp_no_delay(true);Implementations§
Source§impl ConnectionOptions
impl ConnectionOptions
Sourcepub fn tcp_no_delay(self, enabled: bool) -> Self
pub fn tcp_no_delay(self, enabled: bool) -> Self
Enable or disable TCP_NODELAY on the connection socket.
When enabled, disables Nagle’s algorithm for lower latency.
Default: false.
Sourcepub fn startup_callback(
self,
callback: impl Fn(ResponseMessage) + Send + Sync + 'static,
) -> Self
pub fn startup_callback( self, callback: impl Fn(ResponseMessage) + Send + Sync + 'static, ) -> Self
Set a callback for unsolicited messages during connection setup.
When TWS sends messages like OpenOrder or OrderStatus during the
connection handshake, this callback processes them instead of discarding.
Trait Implementations§
Source§impl Clone for ConnectionOptions
impl Clone for ConnectionOptions
Source§fn clone(&self) -> ConnectionOptions
fn clone(&self) -> ConnectionOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConnectionOptions
impl Debug for ConnectionOptions
Source§impl Default for ConnectionOptions
impl Default for ConnectionOptions
Source§fn default() -> ConnectionOptions
fn default() -> ConnectionOptions
Returns the “default value” for a type. Read more
Source§impl From<Option<Box<dyn Fn(ResponseMessage) + Sync + Send>>> for ConnectionOptions
impl From<Option<Box<dyn Fn(ResponseMessage) + Sync + Send>>> for ConnectionOptions
Source§fn from(callback: Option<StartupMessageCallback>) -> Self
fn from(callback: Option<StartupMessageCallback>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ConnectionOptions
impl !RefUnwindSafe for ConnectionOptions
impl Send for ConnectionOptions
impl Sync for ConnectionOptions
impl Unpin for ConnectionOptions
impl UnsafeUnpin for ConnectionOptions
impl !UnwindSafe for ConnectionOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more