StreamBuilder

Struct StreamBuilder 

Source
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,

Source

pub fn new() -> Self

Construct a new Self.

Source

pub fn subscribe<SubIter, Sub, Exchange, Instrument>( self, subscriptions: SubIter, ) -> Self
where 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.

Source

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,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<InstrumentKey: Default, Kind> Default for StreamBuilder<InstrumentKey, Kind>
where Kind: SubscriptionKind + Default, Kind::Event: Default,

Source§

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> 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> 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,