pub struct StreamBuilder<InstrumentKey, Kind>where
Kind: SubscriptionKind,{
pub channels: HashMap<ExchangeId, ExchangeChannel<MarketStreamResult<InstrumentKey, Kind::Event>>>,
pub futures: Vec<SubscribeFuture>,
}Expand description
Builder to configure and initialise a Streams<MarketEvent<SubscriptionKind::Event> instance
for a specific SubscriptionKind.
Fields§
§channels: HashMap<ExchangeId, ExchangeChannel<MarketStreamResult<InstrumentKey, Kind::Event>>>§futures: Vec<SubscribeFuture>Implementations§
Source§impl<InstrumentKey, Kind> StreamBuilder<InstrumentKey, Kind>where
Kind: SubscriptionKind,
impl<InstrumentKey, Kind> StreamBuilder<InstrumentKey, Kind>where
Kind: SubscriptionKind,
Sourcepub fn subscribe<SubIter, Sub, Exchange, Instrument>(
self,
subscriptions: SubIter,
) -> Selfwhere
SubIter: IntoIterator<Item = Sub>,
Sub: Into<Subscription<Exchange, Instrument, Kind>>,
Exchange: StreamSelector<Instrument, Kind> + Ord + Send + Sync + 'static,
Instrument: InstrumentData<Key = InstrumentKey> + Ord + 'static,
Instrument::Key: Clone + Send + 'static,
Kind: Ord + Send + Sync + 'static,
Kind::Event: Clone + Send,
Subscription<Exchange, Instrument, Kind>: Identifier<Exchange::Channel> + Identifier<Exchange::Market>,
pub fn subscribe<SubIter, Sub, Exchange, Instrument>(
self,
subscriptions: SubIter,
) -> Selfwhere
SubIter: IntoIterator<Item = Sub>,
Sub: Into<Subscription<Exchange, Instrument, Kind>>,
Exchange: StreamSelector<Instrument, Kind> + Ord + Send + Sync + 'static,
Instrument: InstrumentData<Key = InstrumentKey> + Ord + 'static,
Instrument::Key: Clone + Send + 'static,
Kind: Ord + Send + Sync + 'static,
Kind::Event: Clone + Send,
Subscription<Exchange, Instrument, Kind>: Identifier<Exchange::Channel> + Identifier<Exchange::Market>,
Add a collection of Subscriptions to the StreamBuilder that will be actioned on
a distinct WebSocket connection.
Note that Subscriptions are not actioned until the
init() method is invoked.
Sourcepub async fn init(
self,
) -> Result<Streams<MarketStreamResult<InstrumentKey, Kind::Event>>, DataError>
pub async fn init( self, ) -> Result<Streams<MarketStreamResult<InstrumentKey, Kind::Event>>, DataError>
Spawn a MarketEvent<SubscriptionKind::Event> consumer loop for each collection of
Subscriptions added to StreamBuilder via the
subscribe() method.
Each consumer loop distributes consumed MarketEvent<SubscriptionKind::Event>s to
the Streams HashMap returned by this method.
Trait Implementations§
Source§impl<InstrumentKey, Kind> Debug for StreamBuilder<InstrumentKey, Kind>where
InstrumentKey: Debug,
Kind: SubscriptionKind,
impl<InstrumentKey, Kind> Debug for StreamBuilder<InstrumentKey, Kind>where
InstrumentKey: Debug,
Kind: SubscriptionKind,
Source§impl<InstrumentKey: Default, Kind> Default for StreamBuilder<InstrumentKey, Kind>
impl<InstrumentKey: Default, Kind> Default for StreamBuilder<InstrumentKey, Kind>
Source§fn default() -> StreamBuilder<InstrumentKey, Kind>
fn default() -> StreamBuilder<InstrumentKey, Kind>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<InstrumentKey, Kind> Freeze for StreamBuilder<InstrumentKey, Kind>
impl<InstrumentKey, Kind> !RefUnwindSafe for StreamBuilder<InstrumentKey, Kind>
impl<InstrumentKey, Kind> !Send for StreamBuilder<InstrumentKey, Kind>
impl<InstrumentKey, Kind> !Sync for StreamBuilder<InstrumentKey, Kind>
impl<InstrumentKey, Kind> Unpin for StreamBuilder<InstrumentKey, Kind>
impl<InstrumentKey, Kind> !UnwindSafe for StreamBuilder<InstrumentKey, Kind>
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more