pub struct Stream<'a> {
pub client: Client<'a>,
}Fields§
§client: Client<'a>Implementations§
source§impl<'a> Stream<'_>
impl<'a> Stream<'_>
sourcepub async fn ws_ping(&self, private: bool) -> Result<(), BybitError>
pub async fn ws_ping(&self, private: bool) -> Result<(), BybitError>
Tests for connectivity by sending a ping request to the Bybit server.
§Returns
Returns a Result containing a String with the response message if successful,
privateis set totrueif the request is for a private endpoint or aBybitErrorif an error occurs.
pub async fn ws_priv_subscribe<'b, F>( &self, req: Subscription<'_>, handler: F, ) -> Result<(), BybitError>
pub async fn ws_subscribe<'b, F>( &self, req: Subscription<'_>, category: Category, handler: F, ) -> Result<(), BybitError>
pub fn build_subscription(action: Subscription<'_>) -> String
pub fn build_trade_subscription( orders: RequestType<'_>, recv_window: Option<u64>, ) -> String
sourcepub async fn ws_orderbook(
&self,
subs: Vec<(i32, &str)>,
category: Category,
sender: UnboundedSender<OrderBookUpdate>,
) -> Result<(), BybitError>
pub async fn ws_orderbook( &self, subs: Vec<(i32, &str)>, category: Category, sender: UnboundedSender<OrderBookUpdate>, ) -> Result<(), BybitError>
sourcepub async fn ws_trades(
&self,
subs: Vec<&str>,
category: Category,
sender: UnboundedSender<WsTrade>,
) -> Result<(), BybitError>
pub async fn ws_trades( &self, subs: Vec<&str>, category: Category, sender: UnboundedSender<WsTrade>, ) -> Result<(), BybitError>
This function subscribes to the specified trades and handles the trade events.
§Arguments
subs- A vector of trade subscriptionscategory- The category of the trades
§Example
use your_crate_name::Category;
let subs = vec!["BTCUSD", "ETHUSD"];
let category = Category::Linear;
ws_trades(subs, category);sourcepub async fn ws_tickers(
&self,
subs: Vec<&str>,
category: Category,
sender: UnboundedSender<Tickers>,
) -> Result<(), BybitError>
pub async fn ws_tickers( &self, subs: Vec<&str>, category: Category, sender: UnboundedSender<Tickers>, ) -> Result<(), BybitError>
Subscribes to ticker events for the specified symbols and category.
§Arguments
subs- A vector of symbols for which ticker events are subscribed.category- The category for which ticker events are subscribed.
§Examples
use your_crate_name::Category;
let subs = vec!["BTCUSD", "ETHUSD"];
let category = Category::Linear;
let sender = UnboundedSender<Tickers>;
ws_tickers(subs, category, sender);pub async fn ws_liquidations( &self, subs: Vec<&str>, category: Category, sender: UnboundedSender<LiquidationData>, ) -> Result<(), BybitError>
pub async fn ws_klines( &self, subs: Vec<(&str, &str)>, category: Category, sender: UnboundedSender<WsKline>, ) -> Result<(), BybitError>
pub async fn ws_position( &self, cat: Option<Category>, sender: UnboundedSender<PositionData>, ) -> Result<(), BybitError>
pub async fn ws_executions( &self, cat: Option<Category>, sender: UnboundedSender<ExecutionData>, ) -> Result<(), BybitError>
pub async fn ws_fast_exec( &self, sender: UnboundedSender<FastExecData>, ) -> Result<(), BybitError>
pub async fn ws_orders( &self, cat: Option<Category>, sender: UnboundedSender<OrderData>, ) -> Result<(), BybitError>
pub async fn ws_wallet( &self, sender: UnboundedSender<WalletData>, ) -> Result<(), BybitError>
pub async fn ws_trade_stream<'b, F>( &self, req: UnboundedReceiver<RequestType<'_>>, handler: F, ) -> Result<(), BybitError>
pub async fn event_loop<'b, H>(
stream: WebSocketStream<MaybeTlsStream<TcpStream>>,
handler: H,
order_sender: Option<UnboundedReceiver<RequestType<'_>>>,
) -> Result<(), BybitError>where
H: WebSocketHandler,
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Stream<'a>
impl<'a> !RefUnwindSafe for Stream<'a>
impl<'a> Send for Stream<'a>
impl<'a> Sync for Stream<'a>
impl<'a> Unpin for Stream<'a>
impl<'a> !UnwindSafe for Stream<'a>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)