ecbt_exchange/stream/
subscriptions.rs1use crate::model::websocket::Subscription;
2
3pub struct Subscriptions<T: From<Subscription>> {
4 inner: Vec<T>,
5}
6
7impl<T: From<Subscription>> Subscriptions<T> {
8 pub fn as_slice(&self) -> &[T] {
9 &self.inner[..]
10 }
11}
12
13impl<T: From<Subscription>> IntoIterator for Subscriptions<T> {
14 type Item = T;
15 type IntoIter = std::vec::IntoIter<Self::Item>;
16
17 fn into_iter(self) -> Self::IntoIter {
18 self.inner.into_iter()
19 }
20}
21
22impl<T: From<Subscription>, U: Into<T> + Clone> From<&[U]> for Subscriptions<T> {
23 fn from(s: &[U]) -> Self {
24 let v = s.iter().cloned().map(U::into).collect::<Vec<_>>();
25
26 Subscriptions { inner: v }
27 }
28}