pub struct SubscriptionSet { /* private fields */ }Expand description
The full set of subscriptions the consumer wants: the input of
BrokerCore::apply.
It is a plain list in the order given. The set does not check for duplicates: two entries with
the same id both stay, and find returns the first.
§Examples
use brokapi_core::{InstrumentId, InstrumentKey, NativeId, SubscriptionId};
use brokapi_sansio::{DesiredSubscription, SubscriptionKind, SubscriptionSet};
let sber = InstrumentId::new(
InstrumentKey::new("SBER", "TQBR"),
NativeId::TickerClass { ticker: "SBER".into(), class_code: "TQBR".into() },
);
let quotes = DesiredSubscription {
id: SubscriptionId::new(1),
kind: SubscriptionKind::Quotes { instrument: sber.clone() },
};
let book = DesiredSubscription {
id: SubscriptionId::new(2),
kind: SubscriptionKind::OrderBook { instrument: sber, depth: 10 },
};
let set = SubscriptionSet::with_subscriptions(vec![quotes.clone(), book]);
assert_eq!(set.subs().len(), 2);
assert_eq!(set.find(SubscriptionId::new(1)), Some("es));
assert!(set.find(SubscriptionId::new(9)).is_none());
assert!(SubscriptionSet::new().is_empty());Implementations§
Source§impl SubscriptionSet
impl SubscriptionSet
Sourcepub fn with_subscriptions(subs: Vec<DesiredSubscription>) -> Self
pub fn with_subscriptions(subs: Vec<DesiredSubscription>) -> Self
Creates a set from a list, keeping its order.
Sourcepub fn subs(&self) -> &[DesiredSubscription]
pub fn subs(&self) -> &[DesiredSubscription]
The subscriptions, in the order given.
Sourcepub fn iter(&self) -> impl Iterator<Item = &DesiredSubscription>
pub fn iter(&self) -> impl Iterator<Item = &DesiredSubscription>
Iterates over the subscriptions, in the order given.
Sourcepub fn find(&self, id: SubscriptionId) -> Option<&DesiredSubscription>
pub fn find(&self, id: SubscriptionId) -> Option<&DesiredSubscription>
The subscription with this id, or None.
Trait Implementations§
Source§impl Clone for SubscriptionSet
impl Clone for SubscriptionSet
Source§fn clone(&self) -> SubscriptionSet
fn clone(&self) -> SubscriptionSet
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 moreSource§impl Debug for SubscriptionSet
impl Debug for SubscriptionSet
Source§impl Default for SubscriptionSet
impl Default for SubscriptionSet
Source§fn default() -> SubscriptionSet
fn default() -> SubscriptionSet
Returns the “default value” for a type. Read more
impl Eq for SubscriptionSet
Source§impl PartialEq for SubscriptionSet
impl PartialEq for SubscriptionSet
Source§fn eq(&self, other: &SubscriptionSet) -> bool
fn eq(&self, other: &SubscriptionSet) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for SubscriptionSet
Auto Trait Implementations§
impl Freeze for SubscriptionSet
impl RefUnwindSafe for SubscriptionSet
impl Send for SubscriptionSet
impl Sync for SubscriptionSet
impl Unpin for SubscriptionSet
impl UnsafeUnpin for SubscriptionSet
impl UnwindSafe for SubscriptionSet
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