Struct barter_data::streams::builder::StreamBuilder
source · pub struct StreamBuilder<Kind>where
Kind: SubscriptionKind,{
pub channels: HashMap<ExchangeId, ExchangeChannel<MarketEvent<Instrument, 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<MarketEvent<Instrument, Kind::Event>>>§futures: Vec<SubscribeFuture>Implementations§
source§impl<Kind> StreamBuilder<Kind>where
Kind: SubscriptionKind,
impl<Kind> StreamBuilder<Kind>where
Kind: SubscriptionKind,
sourcepub fn subscribe<SubIter, Sub, Exchange>(self, subscriptions: SubIter) -> Selfwhere
SubIter: IntoIterator<Item = Sub>,
Sub: Into<Subscription<Exchange, Instrument, Kind>>,
Exchange: StreamSelector<Instrument, Kind> + Ord + Send + Sync + 'static,
Kind: Ord + Send + Sync + 'static,
Kind::Event: Send,
Subscription<Exchange, Instrument, Kind>: Identifier<Exchange::Channel> + Identifier<Exchange::Market>,
pub fn subscribe<SubIter, Sub, Exchange>(self, subscriptions: SubIter) -> Selfwhere
SubIter: IntoIterator<Item = Sub>,
Sub: Into<Subscription<Exchange, Instrument, Kind>>,
Exchange: StreamSelector<Instrument, Kind> + Ord + Send + Sync + 'static,
Kind: Ord + Send + Sync + 'static,
Kind::Event: 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<MarketEvent<Instrument, Kind::Event>>, DataError>
pub async fn init( self, ) -> Result<Streams<MarketEvent<Instrument, 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<Kind> Debug for StreamBuilder<Kind>where
Kind: SubscriptionKind,
impl<Kind> Debug for StreamBuilder<Kind>where
Kind: SubscriptionKind,
source§impl<Kind> Default for StreamBuilder<Kind>
impl<Kind> Default for StreamBuilder<Kind>
source§fn default() -> StreamBuilder<Kind>
fn default() -> StreamBuilder<Kind>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<Kind> Freeze for StreamBuilder<Kind>
impl<Kind> !RefUnwindSafe for StreamBuilder<Kind>
impl<Kind> !Send for StreamBuilder<Kind>
impl<Kind> !Sync for StreamBuilder<Kind>
impl<Kind> Unpin for StreamBuilder<Kind>
impl<Kind> !UnwindSafe for StreamBuilder<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