use crate::contracts::Contract;
use crate::market_data::realtime::MarketDepths;
use crate::market_data::SmartDepth;
use crate::Error;
#[cfg(test)]
#[path = "market_depth_tests.rs"]
mod tests;
#[must_use = "MarketDepthBuilder does nothing until you call .subscribe()"]
pub struct MarketDepthBuilder<'a, C> {
client: &'a C,
contract: &'a Contract,
number_of_rows: i32,
smart_depth: SmartDepth,
}
impl<'a, C> MarketDepthBuilder<'a, C> {
pub(crate) fn new(client: &'a C, contract: &'a Contract, number_of_rows: i32) -> Self {
Self {
client,
contract,
number_of_rows,
smart_depth: SmartDepth::default(),
}
}
pub fn smart_depth(mut self, smart_depth: SmartDepth) -> Self {
self.smart_depth = smart_depth;
self
}
}
#[cfg(feature = "sync")]
impl<'a> MarketDepthBuilder<'a, crate::client::sync::Client> {
pub fn subscribe(self) -> Result<crate::subscriptions::sync::Subscription<MarketDepths>, Error> {
crate::market_data::realtime::sync::market_depth(self.client, self.contract, self.number_of_rows, self.smart_depth)
}
}
#[cfg(feature = "async")]
impl<'a> MarketDepthBuilder<'a, crate::client::r#async::Client> {
pub async fn subscribe(self) -> Result<crate::subscriptions::Subscription<MarketDepths>, Error> {
crate::market_data::realtime::r#async::market_depth(self.client, self.contract, self.number_of_rows, self.smart_depth).await
}
}