std_modrpc/roles/
stream_receiver.rs

1#![allow(unused_variables)]
2
3use crate::interface::StreamInterface;
4use crate::proto::{StreamInitState, StreamItem, StreamReceiverConfig};
5use modrpc::{EventRxBuilder, InterfaceRole, RoleSetup};
6
7pub struct StreamReceiverHooks<T> {
8    _phantom: std::marker::PhantomData<T>,
9}
10
11pub struct StreamReceiverStubs<T> {
12    pub item: EventRxBuilder<StreamItem<T>>,
13    _phantom: std::marker::PhantomData<T>,
14}
15
16pub struct StreamReceiverRole<T> {
17    _phantom: std::marker::PhantomData<T>,
18}
19
20impl<T: mproto::Owned> InterfaceRole for StreamReceiverRole<T> {
21    type Interface = StreamInterface<T>;
22    type Config = StreamReceiverConfig;
23    type Init = StreamInitState;
24    type Stubs = StreamReceiverStubs<T>;
25    type Hooks = StreamReceiverHooks<T>;
26
27    fn setup_worker(
28        i: &Self::Interface,
29        setup: &mut RoleSetup,
30        config: &Self::Config,
31        init: &Self::Init,
32    ) -> (Self::Stubs, Self::Hooks) {
33        (
34            Self::Stubs {
35                item: setup.event_rx(i.item),
36                _phantom: std::marker::PhantomData,
37            },
38            Self::Hooks {
39                _phantom: std::marker::PhantomData,
40            },
41        )
42    }
43}
44
45impl<T> Clone for StreamReceiverHooks<T> {
46    fn clone(&self) -> Self {
47        Self {
48            _phantom: std::marker::PhantomData,
49        }
50    }
51}