[][src]Struct cbpro::websocket::WebSocketFeed

pub struct WebSocketFeed { /* fields omitted */ }

Stream with private or public access to Coinbase's Websocket Feed

Methods

impl WebSocketFeed[src]

pub async fn connect<'_>(url: &'_ str) -> Result<WebSocketFeed>[src]

Example

use cbpro::websocket::{WebSocketFeed, SANDBOX_FEED_URL, Channels};
use futures::TryStreamExt;

let mut feed = WebSocketFeed::connect(SANDBOX_FEED_URL).await?;
feed.subscribe(&["BTC-USD"], &[Channels::LEVEL2]).await?;

while let Some(value) = feed.try_next().await? {
    println!("{}", serde_json::to_string_pretty(&value).unwrap());
}

pub async fn connect_auth<'_>(
    key: String,
    pass: String,
    secret: String,
    url: &'_ str
) -> Result<WebSocketFeed>
[src]

Example

use cbpro::websocket::{WebSocketFeed, SANDBOX_FEED_URL, Channels};
use futures::TryStreamExt;

let mut feed = WebSocketFeed::connect_auth(String::new(), String::new(), String::new(), SANDBOX_FEED_URL).await?;
feed.subscribe(&["BTC-USD"], &[Channels::LEVEL2]).await?;

while let Some(value) = feed.try_next().await? {
    println!("{}", serde_json::to_string_pretty(&value).unwrap());
}

pub async fn subscribe<'_, '_, '_, '_, '_>(
    &'_ mut self,
    product_ids: &'_ [&'_ str],
    channels: &'_ [&'_ str]
) -> Result<()>
[src]

Subscribe to a list of channels and products.

pub async fn unsubscribe<'_, '_, '_, '_, '_>(
    &'_ mut self,
    product_ids: &'_ [&'_ str],
    channels: &'_ [&'_ str]
) -> Result<()>
[src]

Unsubscribe to a list of channels and products.

pub fn get_ref(
    &self
) -> &WebSocketStream<StreamSwitcher<TokioAdapter<TcpStream>, TokioAdapter<TlsStream<TokioAdapter<TokioAdapter<TcpStream>>>>>>
[src]

Returns a shared reference to the inner stream.

pub fn get_mut(
    &mut self
) -> &mut WebSocketStream<StreamSwitcher<TokioAdapter<TcpStream>, TokioAdapter<TlsStream<TokioAdapter<TokioAdapter<TcpStream>>>>>>
[src]

Returns a mutable reference to the inner stream.

pub fn response(&self) -> &Response[src]

Returns a shared reference to the feed response.

pub async fn close(__arg0: Self) -> Result<()>[src]

Sends a close frame

Trait Implementations

impl Sink<Message> for WebSocketFeed[src]

type Error = Error

The type of value produced by the sink when an error occurs.

impl Stream for WebSocketFeed[src]

type Item = Result<Value>

Values yielded by the stream.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, Item> SinkExt<Item> for T where
    T: Sink<Item> + ?Sized
[src]

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<S, T, E> TryStream for S where
    S: Stream<Item = Result<T, E>> + ?Sized
[src]

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<S> TryStreamExt for S where
    S: TryStream + ?Sized
[src]

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