Struct bybit::ws::Stream

source ·
pub struct Stream {
    pub client: Client,
}

Fields§

§client: Client

Implementations§

source§

impl Stream

source

pub async fn ws_ping(&self, private: bool) -> Result<(), BybitError>

source

pub async fn ws_priv_subscribe<'a, F>( &self, req: Subscription<'a>, handler: F, ) -> Result<(), BybitError>
where F: FnMut(WebsocketEvents) -> Result<(), BybitError> + 'static + Send,

source

pub async fn ws_subscribe<'a, F>( &self, req: Subscription<'a>, category: Category, handler: F, ) -> Result<(), BybitError>
where F: FnMut(WebsocketEvents) -> Result<(), BybitError> + 'static + Send,

source

pub fn build_subscription(action: Subscription<'_>) -> String

source

pub fn build_trade_subscription( orders: RequestType<'_>, recv_window: Option<u64>, ) -> String

source

pub async fn ws_orderbook( &self, subs: Vec<(i32, &str)>, category: Category, sender: UnboundedSender<OrderBookUpdate>, ) -> Result<(), BybitError>

Subscribes to the specified order book updates and handles the order book events

§Arguments
  • subs - A vector of tuples containing the order book ID and symbol
  • category - The category of the order book
§Example
use your_crate_name::Category;
let subs = vec![(1, "BTC"), (2, "ETH")];
source

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 subscriptions
  • category - The category of the trades
§Example
use your_crate_name::Category;
let subs = vec!["BTCUSD", "ETHUSD"];
let category = Category::Linear;
ws_trades(subs, category);
source

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);
source

pub async fn ws_liquidations( &self, subs: Vec<&str>, category: Category, sender: UnboundedSender<LiquidationData>, ) -> Result<(), BybitError>

source

pub async fn ws_klines( &self, subs: Vec<(&str, &str)>, category: Category, sender: UnboundedSender<WsKline>, ) -> Result<(), BybitError>

source

pub async fn ws_position( &self, cat: Option<Category>, sender: UnboundedSender<PositionData>, ) -> Result<(), BybitError>

source

pub async fn ws_executions( &self, cat: Option<Category>, sender: UnboundedSender<ExecutionData>, ) -> Result<(), BybitError>

source

pub async fn ws_fast_exec( &self, sender: UnboundedSender<FastExecData>, ) -> Result<(), BybitError>

source

pub async fn ws_orders( &self, cat: Option<Category>, sender: UnboundedSender<OrderData>, ) -> Result<(), BybitError>

source

pub async fn ws_wallet( &self, sender: UnboundedSender<WalletData>, ) -> Result<(), BybitError>

source

pub async fn ws_trade_stream<'a, F>( &self, req: UnboundedReceiver<RequestType<'a>>, handler: F, ) -> Result<(), BybitError>
where F: FnMut(WebsocketEvents) -> Result<(), BybitError> + 'static + Send, 'a: 'static,

source

pub async fn event_loop<'a, H>( stream: WebSocketStream<MaybeTlsStream<TcpStream>>, handler: H, order_sender: Option<UnboundedReceiver<RequestType<'a>>>, ) -> Result<(), BybitError>

Trait Implementations§

source§

impl Bybit for Stream

source§

fn new(api_key: Option<String>, secret_key: Option<String>) -> Stream

source§

fn new_with_config( config: &Config, api_key: Option<String>, secret_key: Option<String>, ) -> Stream

source§

impl Clone for Stream

source§

fn clone(&self) -> Stream

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Stream

§

impl !RefUnwindSafe for Stream

§

impl Send for Stream

§

impl Sync for Stream

§

impl Unpin for Stream

§

impl !UnwindSafe for Stream

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more