pub struct MarketStreamClient { /* private fields */ }Expand description
Client for the market-data socket (/v1/ws/markets).
Implementations§
Source§impl MarketStreamClient
impl MarketStreamClient
Sourcepub fn new(auth: Option<UsAuth>) -> Self
pub fn new(auth: Option<UsAuth>) -> Self
Connect to the default markets endpoint.
Auth is optional here so the same client can be used before credentials are configured, but note that the live endpoint has been observed to reject unauthenticated upgrades with 401.
Sourcepub fn with_base_url(base_url: impl Into<String>, auth: Option<UsAuth>) -> Self
pub fn with_base_url(base_url: impl Into<String>, auth: Option<UsAuth>) -> Self
Point the client at a non-default host or path — a staging venue, or a local server in tests.
A URL with no path gets the endpoint’s default path appended; a URL that already has one is used as given.
pub fn base_url(&self) -> &str
pub async fn connect( &self, subscriptions: Vec<MarketSubscription>, ) -> Result<MarketStream, PolymarketUsError>
pub async fn connect_with_config( &self, subscriptions: Vec<MarketSubscription>, config: StreamConnectConfig, ) -> Result<MarketStream, PolymarketUsError>
Sourcepub async fn run<F, Fut>(
&self,
subscriptions: Vec<MarketSubscription>,
config: StreamConnectConfig,
on_message: F,
) -> Result<(), PolymarketUsError>
pub async fn run<F, Fut>( &self, subscriptions: Vec<MarketSubscription>, config: StreamConnectConfig, on_message: F, ) -> Result<(), PolymarketUsError>
Connect and drive a callback until the stream closes.
Trait Implementations§
Source§impl Clone for MarketStreamClient
impl Clone for MarketStreamClient
Source§fn clone(&self) -> MarketStreamClient
fn clone(&self) -> MarketStreamClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MarketStreamClient
impl RefUnwindSafe for MarketStreamClient
impl Send for MarketStreamClient
impl Sync for MarketStreamClient
impl Unpin for MarketStreamClient
impl UnsafeUnpin for MarketStreamClient
impl UnwindSafe for MarketStreamClient
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